mirror of
https://github.com/etcd-io/etcd.git
synced 2024-09-27 06:25:44 +00:00
tests: Extract flag init from main_test.go
This commit is contained in:
parent
5b226e0abf
commit
4bcdee5c65
@ -24,7 +24,6 @@ import (
|
||||
"time"
|
||||
|
||||
"go.etcd.io/etcd/server/v3/etcdserver"
|
||||
"go.etcd.io/etcd/tests/v3/integration"
|
||||
"go.uber.org/zap"
|
||||
"go.uber.org/zap/zaptest"
|
||||
)
|
||||
@ -33,10 +32,6 @@ const etcdProcessBasePort = 20000
|
||||
|
||||
type clientConnType int
|
||||
|
||||
var (
|
||||
fixturesDir = integration.MustAbsPath("../fixtures")
|
||||
)
|
||||
|
||||
const (
|
||||
clientNonTLS clientConnType = iota
|
||||
clientTLS
|
||||
|
72
tests/e2e/flags.go
Normal file
72
tests/e2e/flags.go
Normal file
@ -0,0 +1,72 @@
|
||||
// Copyright 2021 The etcd Authors
|
||||
//
|
||||
// Licensed under the Apache License, Version 2.0 (the "License");
|
||||
// you may not use this file except in compliance with the License.
|
||||
// You may obtain a copy of the License at
|
||||
//
|
||||
// http://www.apache.org/licenses/LICENSE-2.0
|
||||
//
|
||||
// Unless required by applicable law or agreed to in writing, software
|
||||
// distributed under the License is distributed on an "AS IS" BASIS,
|
||||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
// See the License for the specific language governing permissions and
|
||||
// limitations under the License.
|
||||
|
||||
package e2e
|
||||
|
||||
import (
|
||||
"flag"
|
||||
"os"
|
||||
"runtime"
|
||||
|
||||
"go.etcd.io/etcd/tests/v3/integration"
|
||||
)
|
||||
|
||||
var (
|
||||
binDir string
|
||||
certDir string
|
||||
|
||||
certPath string
|
||||
privateKeyPath string
|
||||
caPath string
|
||||
|
||||
certPath2 string
|
||||
privateKeyPath2 string
|
||||
|
||||
certPath3 string
|
||||
privateKeyPath3 string
|
||||
|
||||
crlPath string
|
||||
revokedCertPath string
|
||||
revokedPrivateKeyPath string
|
||||
|
||||
fixturesDir = integration.MustAbsPath("../fixtures")
|
||||
)
|
||||
|
||||
func InitFlags() {
|
||||
os.Setenv("ETCD_UNSUPPORTED_ARCH", runtime.GOARCH)
|
||||
os.Unsetenv("ETCDCTL_API")
|
||||
|
||||
binDirDef := integration.MustAbsPath("../../bin")
|
||||
certDirDef := fixturesDir
|
||||
|
||||
flag.StringVar(&binDir, "bin-dir", binDirDef, "The directory for store etcd and etcdctl binaries.")
|
||||
flag.StringVar(&certDir, "cert-dir", certDirDef, "The directory for store certificate files.")
|
||||
flag.Parse()
|
||||
|
||||
binPath = binDir + "/etcd"
|
||||
ctlBinPath = binDir + "/etcdctl"
|
||||
utlBinPath = binDir + "/etcdutl"
|
||||
certPath = certDir + "/server.crt"
|
||||
privateKeyPath = certDir + "/server.key.insecure"
|
||||
caPath = certDir + "/ca.crt"
|
||||
revokedCertPath = certDir + "/server-revoked.crt"
|
||||
revokedPrivateKeyPath = certDir + "/server-revoked.key.insecure"
|
||||
crlPath = certDir + "/revoke.crl"
|
||||
|
||||
certPath2 = certDir + "/server2.crt"
|
||||
privateKeyPath2 = certDir + "/server2.key.insecure"
|
||||
|
||||
certPath3 = certDir + "/server3.crt"
|
||||
privateKeyPath3 = certDir + "/server3.key.insecure"
|
||||
}
|
@ -5,61 +5,15 @@
|
||||
package e2e
|
||||
|
||||
import (
|
||||
"flag"
|
||||
"os"
|
||||
"runtime"
|
||||
"testing"
|
||||
|
||||
"go.etcd.io/etcd/client/pkg/v3/testutil"
|
||||
"go.etcd.io/etcd/tests/v3/integration"
|
||||
)
|
||||
|
||||
var (
|
||||
binDir string
|
||||
certDir string
|
||||
|
||||
certPath string
|
||||
privateKeyPath string
|
||||
caPath string
|
||||
|
||||
certPath2 string
|
||||
privateKeyPath2 string
|
||||
|
||||
certPath3 string
|
||||
privateKeyPath3 string
|
||||
|
||||
crlPath string
|
||||
revokedCertPath string
|
||||
revokedPrivateKeyPath string
|
||||
)
|
||||
|
||||
func TestMain(m *testing.M) {
|
||||
os.Setenv("ETCD_UNSUPPORTED_ARCH", runtime.GOARCH)
|
||||
os.Unsetenv("ETCDCTL_API")
|
||||
|
||||
binDirDef := integration.MustAbsPath("../../bin")
|
||||
certDirDef := fixturesDir
|
||||
|
||||
flag.StringVar(&binDir, "bin-dir", binDirDef, "The directory for store etcd and etcdctl binaries.")
|
||||
flag.StringVar(&certDir, "cert-dir", certDirDef, "The directory for store certificate files.")
|
||||
flag.Parse()
|
||||
|
||||
binPath = binDir + "/etcd"
|
||||
ctlBinPath = binDir + "/etcdctl"
|
||||
utlBinPath = binDir + "/etcdutl"
|
||||
certPath = certDir + "/server.crt"
|
||||
privateKeyPath = certDir + "/server.key.insecure"
|
||||
caPath = certDir + "/ca.crt"
|
||||
revokedCertPath = certDir + "/server-revoked.crt"
|
||||
revokedPrivateKeyPath = certDir + "/server-revoked.key.insecure"
|
||||
crlPath = certDir + "/revoke.crl"
|
||||
|
||||
certPath2 = certDir + "/server2.crt"
|
||||
privateKeyPath2 = certDir + "/server2.key.insecure"
|
||||
|
||||
certPath3 = certDir + "/server3.crt"
|
||||
privateKeyPath3 = certDir + "/server3.key.insecure"
|
||||
|
||||
InitFlags()
|
||||
v := m.Run()
|
||||
if v == 0 && testutil.CheckLeakedGoroutine() {
|
||||
os.Exit(1)
|
||||
|
Loading…
x
Reference in New Issue
Block a user