Integrate verification into e2e tests.

This commit is contained in:
Piotr Tabor 2021-04-28 23:23:45 +02:00
parent 911204cd76
commit 2ad893b110
3 changed files with 21 additions and 6 deletions

View File

@ -147,6 +147,8 @@ func (ep *ExpectProcess) Signal(sig os.Signal) error {
}
// Close waits for the expect process to exit.
// Close currently does not return error if process exited with !=0 status.
// TODO: Close should expose underlying proces failure by default.
func (ep *ExpectProcess) Close() error { return ep.close(false) }
func (ep *ExpectProcess) close(kill bool) error {
@ -162,7 +164,6 @@ func (ep *ExpectProcess) close(kill bool) error {
ep.wg.Wait()
if err != nil {
ep.err = err
if !kill && strings.Contains(err.Error(), "exit status") {
// non-zero exit code
err = nil
@ -170,6 +171,7 @@ func (ep *ExpectProcess) close(kill bool) error {
err = nil
}
}
ep.cmd = nil
return err
}
@ -178,3 +180,12 @@ func (ep *ExpectProcess) Send(command string) error {
_, err := io.WriteString(ep.fpty, command)
return err
}
func (ep *ExpectProcess) ProcessError() error {
if strings.Contains(ep.err.Error(), "input/output error") {
// TODO: The expect library should not return
// `/dev/ptmx: input/output error` when process just exits.
return nil
}
return ep.err
}

View File

@ -20,17 +20,14 @@ import (
"strings"
"testing"
"time"
"go.etcd.io/etcd/client/pkg/v3/testutil"
)
func BeforeTestV2(t testing.TB) {
skipInShortMode(t)
BeforeTest(t)
os.Setenv("ETCDCTL_API", "2")
t.Cleanup(func() {
os.Unsetenv("ETCDCTL_API")
})
testutil.BeforeTest(t)
}
func TestCtlV2Set(t *testing.T) { testCtlV2Set(t, newConfigNoTLS(), false) }
@ -493,7 +490,11 @@ func etcdctlBackup(t testing.TB, clus *etcdProcessCluster, dataDir, backupDir st
if err != nil {
return err
}
return proc.Close()
err = proc.Close()
if err != nil {
return err
}
return proc.ProcessError()
}
func setupEtcdctlTest(t *testing.T, cfg *etcdProcessClusterConfig, quorum bool) *etcdProcessCluster {

View File

@ -23,10 +23,13 @@ import (
"go.etcd.io/etcd/client/pkg/v3/testutil"
"go.etcd.io/etcd/client/v3"
"go.etcd.io/etcd/server/v3/verify"
)
func BeforeTest(t testing.TB) {
skipInShortMode(t)
testutil.BeforeTest(t)
os.Setenv(verify.ENV_VERIFY, verify.ENV_VERIFY_ALL_VALUE)
}
func TestCtlV3Migrate(t *testing.T) {