integration/fixtures: Move the 'tests/integration/fixtures' directory up and update references.

I moved the files up as they are shared between e2e & integrational tests.
release-3.5
Piotr Tabor 2020-10-07 15:38:28 +02:00
parent bb9703820c
commit be4e8b7013
76 changed files with 86 additions and 79 deletions

View File

@ -64,7 +64,7 @@ The command should show that the handshake succeed. Since we use self-signed cer
**OSX 10.9+ Users**: curl 7.30.0 on OSX 10.9+ doesn't understand certificates passed in on the command line.
Instead, import the dummy ca.crt directly into the keychain or add the `-k` flag to curl to ignore errors.
To test without the `-k` flag, run `open ./fixtures/ca/ca.crt` and follow the prompts.
To test without the `-k` flag, run `open ./tests/fixtures/ca/ca.crt` and follow the prompts.
Please remove this certificate after testing!
If there is a workaround, let us know.

View File

@ -23,11 +23,11 @@ import (
)
const (
jwtRSAPubKey = "../integration/fixtures/server.crt"
jwtRSAPrivKey = "../integration/fixtures/server.key.insecure"
jwtRSAPubKey = "../tests/fixtures/server.crt"
jwtRSAPrivKey = "../tests/fixtures/server.key.insecure"
jwtECPubKey = "../integration/fixtures/server-ecdsa.crt"
jwtECPrivKey = "../integration/fixtures/server-ecdsa.key.insecure"
jwtECPubKey = "../tests/fixtures/server-ecdsa.crt"
jwtECPrivKey = "../tests/fixtures/server-ecdsa.key.insecure"
)
func TestJWTInfo(t *testing.T) {

View File

@ -25,9 +25,9 @@ import (
)
var (
certPath = "../../tests/integration/fixtures/server.crt"
privateKeyPath = "../../tests/integration/fixtures/server.key.insecure"
caPath = "../../tests/integration/fixtures/ca.crt"
certPath = "../../tests/fixtures/server.crt"
privateKeyPath = "../../tests/fixtures/server.key.insecure"
caPath = "../../tests/fixtures/ca.crt"
)
func TestConfigFromFile(t *testing.T) {

View File

@ -38,9 +38,9 @@ import (
var testLogger = zap.NewExample()
var testTLSInfo = transport.TLSInfo{
KeyFile: "./fixtures/server.key.insecure",
CertFile: "./fixtures/server.crt",
TrustedCAFile: "./fixtures/ca.crt",
KeyFile: "../../tests/fixtures/server.key.insecure",
CertFile: "../../tests/fixtures/server.crt",
TrustedCAFile: "../../tests/fixtures/ca.crt",
ClientCertAuth: true,
}

View File

@ -267,10 +267,10 @@ func newProxyV3Proc(cfg *etcdServerProcessConfig) *proxyV3Proc {
// Configure certificates for connection proxy ---> server.
// This certificate must NOT have CN set.
tlsArgs = append(tlsArgs,
"--cert", "../../integration/fixtures/client-nocn.crt",
"--key", "../../integration/fixtures/client-nocn.key.insecure",
"--cacert", "../../integration/fixtures/ca.crt",
"--client-crl-file", "../../integration/fixtures/revoke.crl")
"--cert", "../fixtures/client-nocn.crt",
"--key", "../fixtures/client-nocn.key.insecure",
"--cacert", "../fixtures/ca.crt",
"--client-crl-file", "../fixtures/revoke.crl")
}
return &proxyV3Proc{
proxyProc{

View File

@ -90,7 +90,7 @@ var (
configJWT = etcdProcessClusterConfig{
clusterSize: 1,
initialToken: "new",
authTokenOpts: "jwt,pub-key=../../integration/fixtures/server.crt,priv-key=../../integration/fixtures/server.key.insecure,sign-method=RS256,ttl=1s",
authTokenOpts: "jwt,pub-key=../fixtures/server.crt,priv-key=../fixtures/server.key.insecure,sign-method=RS256,ttl=1s",
}
)

View File

@ -37,7 +37,7 @@ func TestMain(m *testing.M) {
os.Unsetenv("ETCDCTL_API")
flag.StringVar(&binDir, "bin-dir", "../../bin", "The directory for store etcd and etcdctl binaries.")
flag.StringVar(&certDir, "cert-dir", "../../integration/fixtures", "The directory for store certificate files.")
flag.StringVar(&certDir, "cert-dir", "../fixtures", "The directory for store certificate files.")
flag.Parse()
binPath = binDir + "/etcd"

View File

@ -14,7 +14,7 @@
// +build !cluster_proxy
package integration
package clientv3test
import (
"context"

View File

@ -12,7 +12,7 @@
// See the License for the specific language governing permissions and
// limitations under the License.
package integration
package clientv3test
import (
"context"

View File

@ -12,7 +12,7 @@
// See the License for the specific language governing permissions and
// limitations under the License.
package integration
package clientv3test
import (
"context"
@ -31,16 +31,16 @@ import (
var (
testTLSInfo = transport.TLSInfo{
KeyFile: "../../integration/fixtures/server.key.insecure",
CertFile: "../../integration/fixtures/server.crt",
TrustedCAFile: "../../integration/fixtures/ca.crt",
KeyFile: "../../fixtures/server.key.insecure",
CertFile: "../../fixtures/server.crt",
TrustedCAFile: "../../fixtures/ca.crt",
ClientCertAuth: true,
}
testTLSInfoExpired = transport.TLSInfo{
KeyFile: "../../integration/fixtures-expired/server.key.insecure",
CertFile: "../../integration/fixtures-expired/server.crt",
TrustedCAFile: "../../integration/fixtures-expired/ca.crt",
KeyFile: "../fixtures-expired/server.key.insecure",
CertFile: "../fixtures-expired/server.crt",
TrustedCAFile: "../fixtures-expired/ca.crt",
ClientCertAuth: true,
}
)

View File

@ -12,7 +12,7 @@
// See the License for the specific language governing permissions and
// limitations under the License.
package clientv3_test
package clientv3test
import (
"context"

View File

@ -12,7 +12,7 @@
// See the License for the specific language governing permissions and
// limitations under the License.
package clientv3_test
package clientv3test
import (
"context"

View File

@ -12,7 +12,7 @@
// See the License for the specific language governing permissions and
// limitations under the License.
package clientv3_test
package clientv3test
import (
"context"

View File

@ -12,7 +12,7 @@
// See the License for the specific language governing permissions and
// limitations under the License.
package clientv3_test
package clientv3test
import (
"context"

View File

@ -12,7 +12,7 @@
// See the License for the specific language governing permissions and
// limitations under the License.
package clientv3_test
package clientv3test
import (
"context"

View File

@ -12,7 +12,7 @@
// See the License for the specific language governing permissions and
// limitations under the License.
package clientv3_test
package clientv3test
import (
"context"

View File

@ -12,7 +12,7 @@
// See the License for the specific language governing permissions and
// limitations under the License.
package clientv3_test
package clientv3test
import (
"context"

View File

@ -12,7 +12,7 @@
// See the License for the specific language governing permissions and
// limitations under the License.
package clientv3_test
package clientv3test
import (
"context"

View File

@ -12,7 +12,7 @@
// See the License for the specific language governing permissions and
// limitations under the License.
package clientv3_test
package clientv3test
import (
"fmt"

View File

@ -12,7 +12,7 @@
// See the License for the specific language governing permissions and
// limitations under the License.
package naming_test
package clientv3test
import (
"context"

View File

@ -12,7 +12,7 @@
// See the License for the specific language governing permissions and
// limitations under the License.
package integration
package clientv3test
import (
"bytes"

View File

@ -12,7 +12,7 @@
// See the License for the specific language governing permissions and
// limitations under the License.
package integration
package clientv3test
import (
"context"

View File

@ -12,7 +12,7 @@
// See the License for the specific language governing permissions and
// limitations under the License.
package integration
package clientv3test
import (
"context"

View File

@ -12,7 +12,7 @@
// See the License for the specific language governing permissions and
// limitations under the License.
package integration
package clientv3test
import (
"io/ioutil"

View File

@ -2,7 +2,7 @@
// Use of this source code is governed by a BSD-style
// license that can be found in the LICENSE file.
package integration
package clientv3test
import (
"testing"

View File

@ -12,7 +12,7 @@
// See the License for the specific language governing permissions and
// limitations under the License.
package integration
package clientv3test
import (
"bytes"

View File

@ -12,7 +12,7 @@
// See the License for the specific language governing permissions and
// limitations under the License.
package integration
package clientv3test
import (
"bufio"

View File

@ -12,7 +12,7 @@
// See the License for the specific language governing permissions and
// limitations under the License.
package integration
package clientv3test
import (
"context"

View File

@ -12,7 +12,7 @@
// See the License for the specific language governing permissions and
// limitations under the License.
package integration
package clientv3test
import (
"context"

View File

@ -14,7 +14,7 @@
// +build !cluster_proxy
package integration
package clientv3test
import (
"context"

View File

@ -12,7 +12,7 @@
// See the License for the specific language governing permissions and
// limitations under the License.
package integration
package clientv3test
import (
"context"

View File

@ -12,7 +12,7 @@
// See the License for the specific language governing permissions and
// limitations under the License.
package ordering
package clientv3test
import (
"context"
@ -21,6 +21,7 @@ import (
"go.etcd.io/etcd/tests/v3/integration"
"go.etcd.io/etcd/v3/clientv3"
"go.etcd.io/etcd/v3/clientv3/ordering"
"go.etcd.io/etcd/v3/pkg/testutil"
)
@ -38,6 +39,7 @@ func TestEndpointSwitchResolvesViolation(t *testing.T) {
if err != nil {
t.Fatal(err)
}
defer cli.Close()
ctx := context.TODO()
@ -64,7 +66,7 @@ func TestEndpointSwitchResolvesViolation(t *testing.T) {
// NewOrderViolationSwitchEndpointClosure will be able to
// access the full list of endpoints.
cli.SetEndpoints(eps...)
OrderingKv := NewKV(cli.KV, NewOrderViolationSwitchEndpointClosure(*cli))
OrderingKv := ordering.NewKV(cli.KV, ordering.NewOrderViolationSwitchEndpointClosure(*cli))
// set prevRev to the second member's revision of "foo" such that
// the revision is higher than the third member's revision of "foo"
_, err = OrderingKv.Get(ctx, "foo")
@ -97,6 +99,7 @@ func TestUnresolvableOrderViolation(t *testing.T) {
if err != nil {
t.Fatal(err)
}
defer cli.Close()
eps := cli.Endpoints()
ctx := context.TODO()
@ -123,7 +126,7 @@ func TestUnresolvableOrderViolation(t *testing.T) {
// access the full list of endpoints.
cli.SetEndpoints(eps...)
time.Sleep(1 * time.Second) // give enough time for operation
OrderingKv := NewKV(cli.KV, NewOrderViolationSwitchEndpointClosure(*cli))
OrderingKv := ordering.NewKV(cli.KV, ordering.NewOrderViolationSwitchEndpointClosure(*cli))
// set prevRev to the first member's revision of "foo" such that
// the revision is higher than the fourth and fifth members' revision of "foo"
_, err = OrderingKv.Get(ctx, "foo")
@ -147,7 +150,7 @@ func TestUnresolvableOrderViolation(t *testing.T) {
time.Sleep(5 * time.Second) // give enough time for operation
_, err = OrderingKv.Get(ctx, "foo", clientv3.WithSerializable())
if err != ErrNoGreaterRev {
t.Fatalf("expected %v, got %v", ErrNoGreaterRev, err)
if err != ordering.ErrNoGreaterRev {
t.Fatalf("expected %v, got %v", ordering.ErrNoGreaterRev, err)
}
}

View File

@ -12,7 +12,7 @@
// See the License for the specific language governing permissions and
// limitations under the License.
package integration
package clientv3test
import (
"context"

View File

@ -12,7 +12,7 @@
// See the License for the specific language governing permissions and
// limitations under the License.
package integration
package clientv3test
import (
"bytes"

View File

@ -12,7 +12,7 @@
// See the License for the specific language governing permissions and
// limitations under the License.
package integration
package clientv3test
import (
"context"

View File

@ -12,7 +12,7 @@
// See the License for the specific language governing permissions and
// limitations under the License.
package integration
package clientv3test
import (
"context"

View File

@ -12,7 +12,7 @@
// See the License for the specific language governing permissions and
// limitations under the License.
package integration
package clientv3test
import (
"context"

View File

@ -14,7 +14,7 @@
// +build !cluster_proxy
package integration
package clientv3test
import (
"context"

View File

@ -12,7 +12,7 @@
// See the License for the specific language governing permissions and
// limitations under the License.
package integration
package clientv3test
import (
"context"

View File

@ -81,16 +81,16 @@ var (
localListenCount = int64(0)
testTLSInfo = transport.TLSInfo{
KeyFile: "./fixtures/server.key.insecure",
CertFile: "./fixtures/server.crt",
TrustedCAFile: "./fixtures/ca.crt",
KeyFile: "../fixtures/server.key.insecure",
CertFile: "../fixtures/server.crt",
TrustedCAFile: "../fixtures/ca.crt",
ClientCertAuth: true,
}
testTLSInfoIP = transport.TLSInfo{
KeyFile: "./fixtures/server-ip.key.insecure",
CertFile: "./fixtures/server-ip.crt",
TrustedCAFile: "./fixtures/ca.crt",
KeyFile: "../fixtures/server-ip.key.insecure",
CertFile: "../fixtures/server-ip.crt",
TrustedCAFile: "../fixtures/ca.crt",
ClientCertAuth: true,
}
@ -108,7 +108,7 @@ var (
ClientCertAuth: true,
}
defaultTokenJWT = "jwt,pub-key=./fixtures/server.crt,priv-key=./fixtures/server.key.insecure,sign-method=RS256,ttl=1s"
defaultTokenJWT = "jwt,pub-key=../fixtures/server.crt,priv-key=../fixtures/server.key.insecure,sign-method=RS256,ttl=1s"
lg = zap.NewNop()
)

View File

@ -37,9 +37,9 @@ import (
var (
testTLSInfo = transport.TLSInfo{
KeyFile: "../fixtures/server.key.insecure",
CertFile: "../fixtures/server.crt",
TrustedCAFile: "../fixtures/ca.crt",
KeyFile: "../../fixtures/server.key.insecure",
CertFile: "../../fixtures/server.crt",
TrustedCAFile: "../../fixtures/ca.crt",
ClientCertAuth: true,
}
)

View File

@ -24,6 +24,7 @@ import (
"go.etcd.io/etcd/tests/v3/integration"
"go.etcd.io/etcd/v3/clientv3"
"go.etcd.io/etcd/v3/pkg/testutil"
"go.etcd.io/etcd/v3/proxy/grpcproxy"
"go.uber.org/zap"
"google.golang.org/grpc"
@ -114,8 +115,8 @@ func newClusterProxyServer(lg *zap.Logger, endpoints []string, t *testing.T) *cl
cts.server.Serve(cts.l)
}()
Register(lg, client, "test-prefix", cts.l.Addr().String(), 7)
cts.cp, cts.donec = NewClusterProxy(lg, client, cts.l.Addr().String(), "test-prefix")
grpcproxy.Register(lg, client, "test-prefix", cts.l.Addr().String(), 7)
cts.cp, cts.donec = grpcproxy.NewClusterProxy(lg, client, cts.l.Addr().String(), "test-prefix")
cts.caddr = cts.l.Addr().String()
pb.RegisterClusterServer(cts.server, cts.cp)
close(servec)

View File

@ -24,6 +24,7 @@ import (
"go.etcd.io/etcd/tests/v3/integration"
"go.etcd.io/etcd/v3/clientv3"
"go.etcd.io/etcd/v3/pkg/testutil"
"go.etcd.io/etcd/v3/proxy/grpcproxy"
"google.golang.org/grpc"
)
@ -76,7 +77,7 @@ func newKVProxyServer(endpoints []string, t *testing.T) *kvproxyTestServer {
t.Fatal(err)
}
kvp, _ := NewKvProxy(client)
kvp, _ := grpcproxy.NewKvProxy(client)
kvts := &kvproxyTestServer{
kp: kvp,

View File

@ -22,6 +22,7 @@ import (
"go.etcd.io/etcd/v3/clientv3"
"go.etcd.io/etcd/v3/clientv3/naming"
"go.etcd.io/etcd/v3/pkg/testutil"
"go.etcd.io/etcd/v3/proxy/grpcproxy"
"go.uber.org/zap"
gnaming "google.golang.org/grpc/naming"
@ -45,7 +46,7 @@ func TestRegister(t *testing.T) {
t.Fatalf("len(ups) expected 0, got %d (%v)", len(ups), ups)
}
donec := Register(zap.NewExample(), cli, testPrefix, paddr, 5)
donec := grpcproxy.Register(zap.NewExample(), cli, testPrefix, paddr, 5)
ups, err = wa.Next()
if err != nil {

View File

@ -26,6 +26,7 @@ import (
"time"
"go.etcd.io/etcd/v3/clientv3"
"go.etcd.io/etcd/v3/clientv3/snapshot"
"go.etcd.io/etcd/v3/embed"
"go.etcd.io/etcd/v3/pkg/fileutil"
"go.etcd.io/etcd/v3/pkg/testutil"
@ -55,12 +56,12 @@ func TestSnapshotV3RestoreSingle(t *testing.T) {
cfg.InitialCluster = fmt.Sprintf("%s=%s", cfg.Name, pURLs[0].String())
cfg.Dir = filepath.Join(os.TempDir(), fmt.Sprint(time.Now().Nanosecond()))
sp := NewV3(zap.NewExample())
sp := snapshot.NewV3(zap.NewExample())
pss := make([]string, 0, len(pURLs))
for _, p := range pURLs {
pss = append(pss, p.String())
}
if err := sp.Restore(RestoreConfig{
if err := sp.Restore(snapshot.RestoreConfig{
SnapshotPath: dbPath,
Name: cfg.Name,
OutputDataDir: cfg.Dir,
@ -168,7 +169,7 @@ func TestCorruptedBackupFileCheck(t *testing.T) {
t.Fatalf("test file [%s] does not exist: %v", dbPath, err)
}
sp := NewV3(zap.NewExample())
sp := snapshot.NewV3(zap.NewExample())
_, err := sp.Status(dbPath)
expectedErrKeywords := "snapshot file integrity check failed"
/* example error message:
@ -236,7 +237,7 @@ func createSnapshotFile(t *testing.T, kvs []kv) string {
}
}
sp := NewV3(zap.NewExample())
sp := snapshot.NewV3(zap.NewExample())
dpPath := filepath.Join(os.TempDir(), fmt.Sprintf("snapshot%d.db", time.Now().Nanosecond()))
if err = sp.Save(context.Background(), ccfg, dpPath); err != nil {
t.Fatal(err)
@ -275,8 +276,8 @@ func restoreCluster(t *testing.T, clusterN int, dbPath string) (
cfg.InitialCluster = ics
cfg.Dir = filepath.Join(os.TempDir(), fmt.Sprint(time.Now().Nanosecond()+i))
sp := NewV3(zap.NewExample())
if err := sp.Restore(RestoreConfig{
sp := snapshot.NewV3(zap.NewExample())
if err := sp.Restore(snapshot.RestoreConfig{
SnapshotPath: dbPath,
Name: cfg.Name,
OutputDataDir: cfg.Dir,