vitess.io/vitess@v0.16.2/go/test/endtoend/vtgate/queries/aggregation/main_test.go (about) 1 /* 2 Copyright 2021 The Vitess Authors. 3 4 Licensed under the Apache License, Version 2.0 (the "License"); 5 you may not use this file except in compliance with the License. 6 You may obtain a copy of the License at 7 8 http://www.apache.org/licenses/LICENSE-2.0 9 10 Unless required by applicable law or agreed to in writing, software 11 distributed under the License is distributed on an "AS IS" BASIS, 12 WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 See the License for the specific language governing permissions and 14 limitations under the License. 15 */ 16 17 package aggregation 18 19 import ( 20 _ "embed" 21 "flag" 22 "fmt" 23 "os" 24 "testing" 25 26 "vitess.io/vitess/go/test/endtoend/utils" 27 28 "vitess.io/vitess/go/mysql" 29 "vitess.io/vitess/go/test/endtoend/cluster" 30 ) 31 32 var ( 33 clusterInstance *cluster.LocalProcessCluster 34 vtParams mysql.ConnParams 35 mysqlParams mysql.ConnParams 36 keyspaceName = "ks_aggr" 37 cell = "test_aggr" 38 39 //go:embed schema.sql 40 schemaSQL string 41 42 //go:embed vschema.json 43 vschema string 44 ) 45 46 func TestMain(m *testing.M) { 47 defer cluster.PanicHandler(nil) 48 flag.Parse() 49 50 exitCode := func() int { 51 clusterInstance = cluster.NewCluster(cell, "localhost") 52 defer clusterInstance.Teardown() 53 54 // Start topo server 55 err := clusterInstance.StartTopo() 56 if err != nil { 57 return 1 58 } 59 60 // Start keyspace 61 keyspace := &cluster.Keyspace{ 62 Name: keyspaceName, 63 SchemaSQL: schemaSQL, 64 VSchema: vschema, 65 } 66 clusterInstance.VtGateExtraArgs = []string{"--schema_change_signal"} 67 clusterInstance.VtTabletExtraArgs = []string{"--queryserver-config-schema-change-signal", "--queryserver-config-schema-change-signal-interval", "0.1"} 68 err = clusterInstance.StartKeyspace(*keyspace, []string{"-80", "80-"}, 0, false) 69 if err != nil { 70 return 1 71 } 72 73 clusterInstance.VtGateExtraArgs = append(clusterInstance.VtGateExtraArgs, "--enable_system_settings=true") 74 // Start vtgate 75 err = clusterInstance.StartVtgate() 76 if err != nil { 77 return 1 78 } 79 80 vtParams = clusterInstance.GetVTParams(keyspaceName) 81 82 // create mysql instance and connection parameters 83 conn, closer, err := utils.NewMySQL(clusterInstance, keyspaceName, schemaSQL) 84 if err != nil { 85 fmt.Println(err) 86 return 1 87 } 88 defer closer() 89 mysqlParams = conn 90 91 return m.Run() 92 }() 93 os.Exit(exitCode) 94 }