github.com/cockroachdb/cockroach@v20.2.0-alpha.1+incompatible/pkg/compose/compose_test.go (about) 1 // Copyright 2020 The Cockroach Authors. 2 // 3 // Use of this software is governed by the Business Source License 4 // included in the file licenses/BSL.txt. 5 // 6 // As of the Change Date specified in that file, in accordance with 7 // the Business Source License, use of this software will be governed 8 // by the Apache License, Version 2.0, included in the file 9 // licenses/APL.txt. 10 11 // "make test" would normally test this file, but it should only be tested 12 // during nightlies or when invoked by "make compose". 13 14 // +build compose 15 16 // Package compose contains nightly tests that need docker-compose. 17 package compose 18 19 import ( 20 "flag" 21 "fmt" 22 "os/exec" 23 "path/filepath" 24 "testing" 25 "time" 26 ) 27 28 var ( 29 flagEach = flag.Duration("each", 10*time.Minute, "individual test timeout") 30 flagTests = flag.String("tests", ".", "tests within docker compose to run") 31 ) 32 33 func TestComposeCompare(t *testing.T) { 34 cmd := exec.Command( 35 "docker-compose", 36 "-f", filepath.Join("compare", "docker-compose.yml"), 37 "--no-ansi", 38 "up", 39 "--force-recreate", 40 "--exit-code-from", "test", 41 ) 42 cmd.Env = []string{ 43 fmt.Sprintf("EACH=%s", *flagEach), 44 fmt.Sprintf("TESTS=%s", *flagTests), 45 } 46 out, err := cmd.CombinedOutput() 47 if err != nil { 48 t.Log(string(out)) 49 t.Fatal(err) 50 } 51 }