go.etcd.io/etcd@v3.3.27+incompatible/functional/cmd/etcd-tester/main.go (about)

     1  // Copyright 2018 The etcd Authors
     2  //
     3  // Licensed under the Apache License, Version 2.0 (the "License");
     4  // you may not use this file except in compliance with the License.
     5  // You may obtain a copy of the License at
     6  //
     7  //     http://www.apache.org/licenses/LICENSE-2.0
     8  //
     9  // Unless required by applicable law or agreed to in writing, software
    10  // distributed under the License is distributed on an "AS IS" BASIS,
    11  // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
    12  // See the License for the specific language governing permissions and
    13  // limitations under the License.
    14  
    15  // etcd-tester is a program that runs functional-tester client.
    16  package main
    17  
    18  import (
    19  	"flag"
    20  
    21  	"github.com/coreos/etcd/functional/tester"
    22  
    23  	"go.uber.org/zap"
    24  )
    25  
    26  var logger *zap.Logger
    27  
    28  func init() {
    29  	var err error
    30  	logger, err = zap.NewProduction()
    31  	if err != nil {
    32  		panic(err)
    33  	}
    34  }
    35  
    36  func main() {
    37  	config := flag.String("config", "", "path to tester configuration")
    38  	flag.Parse()
    39  
    40  	defer logger.Sync()
    41  
    42  	clus, err := tester.NewCluster(logger, *config)
    43  	if err != nil {
    44  		logger.Fatal("failed to create a cluster", zap.Error(err))
    45  	}
    46  
    47  	err = clus.Send_INITIAL_START_ETCD()
    48  	if err != nil {
    49  		logger.Fatal("Bootstrap failed", zap.Error(err))
    50  	}
    51  	defer clus.Send_SIGQUIT_ETCD_AND_REMOVE_DATA_AND_STOP_AGENT()
    52  
    53  	logger.Info("wait health after bootstrap")
    54  	err = clus.WaitHealth()
    55  	if err != nil {
    56  		logger.Fatal("WaitHealth failed", zap.Error(err))
    57  	}
    58  
    59  	clus.Run()
    60  }