vitess.io/vitess@v0.16.2/go/test/endtoend/vtgate/mysql80/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 vtgate
    18  
    19  import (
    20  	"flag"
    21  	"os"
    22  	"testing"
    23  
    24  	querypb "vitess.io/vitess/go/vt/proto/query"
    25  
    26  	"vitess.io/vitess/go/mysql"
    27  	"vitess.io/vitess/go/test/endtoend/cluster"
    28  )
    29  
    30  var (
    31  	clusterInstance *cluster.LocalProcessCluster
    32  	vtParams        mysql.ConnParams
    33  	KeyspaceName    = "ks"
    34  	Cell            = "test"
    35  )
    36  
    37  func TestMain(m *testing.M) {
    38  	defer cluster.PanicHandler(nil)
    39  	flag.Parse()
    40  
    41  	exitCode := func() int {
    42  		clusterInstance = cluster.NewCluster(Cell, "localhost")
    43  		defer clusterInstance.Teardown()
    44  
    45  		// Start topo server
    46  		err := clusterInstance.StartTopo()
    47  		if err != nil {
    48  			return 1
    49  		}
    50  
    51  		// Start keyspace
    52  		keyspace := &cluster.Keyspace{
    53  			Name: KeyspaceName,
    54  		}
    55  		err = clusterInstance.StartUnshardedKeyspace(*keyspace, 0, false)
    56  		if err != nil {
    57  			return 1
    58  		}
    59  
    60  		clusterInstance.VtGatePlannerVersion = querypb.ExecuteOptions_Gen4
    61  		clusterInstance.VtGateExtraArgs = append(clusterInstance.VtGateExtraArgs,
    62  			"--enable_system_settings=true",
    63  			"--mysql_server_version=8.0.16-7",
    64  		)
    65  		// Start vtgate
    66  		err = clusterInstance.StartVtgate()
    67  		if err != nil {
    68  			return 1
    69  		}
    70  		vtParams = mysql.ConnParams{
    71  			Host: clusterInstance.Hostname,
    72  			Port: clusterInstance.VtgateMySQLPort,
    73  		}
    74  		return m.Run()
    75  	}()
    76  	os.Exit(exitCode)
    77  }