github.com/grailbio/bigslice@v0.0.0-20230519005545-30c4c12152ad/cmd/slicer/main.go (about) 1 // Copyright 2018 GRAIL, Inc. All rights reserved. 2 // Use of this source code is governed by the Apache 2.0 3 // license that can be found in the LICENSE file. 4 5 // Slicer is a binary used to test and stress multiple aspects of Bigslice. 6 package main 7 8 import ( 9 "flag" 10 "fmt" 11 "os" 12 13 "github.com/grailbio/base/log" 14 "github.com/grailbio/base/must" 15 "github.com/grailbio/bigslice/sliceconfig" 16 ) 17 18 func main() { 19 flag.Usage = func() { 20 fmt.Fprintf(os.Stderr, `usage: slicer [-wait] test-name args... 21 22 Command bigslicetest runs large-scale integration testing of various 23 Bigslice functionality. It's distributed as a separate binary as it 24 requires launching external clusters, and may run for a long time. 25 26 Available test are: 27 28 cogroup 29 Large-scale testing of cogroup functionality. 30 itermem 31 Testing memory leaks during iterative bigslice invocations. 32 reduce 33 Large-scale testing of reduce functionality. 34 oom 35 Trigger the OOM killer. 36 `) 37 flag.PrintDefaults() 38 os.Exit(2) 39 } 40 41 wait := flag.Bool("wait", false, "don't exit after completion") 42 sess := sliceconfig.Parse() 43 defer sess.Shutdown() 44 45 if flag.NArg() == 0 { 46 flag.Usage() 47 } 48 49 cmd, args := flag.Arg(0), flag.Args()[1:] 50 var err error 51 switch cmd { 52 default: 53 fmt.Fprintf(os.Stderr, "unknown command %s\n", cmd) 54 flag.Usage() 55 case "cogroup": 56 err = cogroup(sess, args) 57 case "memiter": 58 err = memiter(sess, args) 59 case "reduce": 60 err = reduce(sess, args) 61 case "oom": 62 err = oomer(sess, args) 63 } 64 if *wait { 65 if err != nil { 66 log.Printf("finished with error %v: waiting", err) 67 } else { 68 log.Print("done: waiting") 69 } 70 <-make(chan struct{}) 71 } 72 must.Nil(err, cmd) 73 }