Skip to content

Commit

Permalink
Merge pull request etcd-io#6317 from gyuho/release-test
Browse files Browse the repository at this point in the history
e2e: add 'TestReleaseUpgradeWithRestart'
  • Loading branch information
gyuho authored Aug 31, 2016
2 parents 2d55292 + a1598d7 commit a6d22b9
Showing 1 changed file with 68 additions and 0 deletions.
68 changes: 68 additions & 0 deletions e2e/etcd_release_upgrade_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ package e2e
import (
"fmt"
"os"
"sync"
"testing"
"time"

Expand Down Expand Up @@ -86,3 +87,70 @@ func TestReleaseUpgrade(t *testing.T) {
}
}
}

func TestReleaseUpgradeWithRestart(t *testing.T) {
lastReleaseBinary := binDir + "/etcd-last-release"
if !fileutil.Exist(lastReleaseBinary) {
t.Skipf("%q does not exist", lastReleaseBinary)
}

defer testutil.AfterTest(t)

copiedCfg := configNoTLS
copiedCfg.execPath = lastReleaseBinary
copiedCfg.snapCount = 10
copiedCfg.baseScheme = "unix"

epc, err := newEtcdProcessCluster(&copiedCfg)
if err != nil {
t.Fatalf("could not start etcd process cluster (%v)", err)
}
defer func() {
if errC := epc.Close(); errC != nil {
t.Fatalf("error closing etcd processes (%v)", errC)
}
}()

os.Setenv("ETCDCTL_API", "3")
defer os.Unsetenv("ETCDCTL_API")
cx := ctlCtx{
t: t,
cfg: configNoTLS,
dialTimeout: 7 * time.Second,
quorum: true,
epc: epc,
}
var kvs []kv
for i := 0; i < 50; i++ {
kvs = append(kvs, kv{key: fmt.Sprintf("foo%d", i), val: "bar"})
}
for i := range kvs {
if err := ctlV3Put(cx, kvs[i].key, kvs[i].val, ""); err != nil {
cx.t.Fatalf("#%d: ctlV3Put error (%v)", i, err)
}
}

for i := range epc.procs {
if err := epc.procs[i].Stop(); err != nil {
t.Fatalf("#%d: error closing etcd process (%v)", i, err)
}
}

var wg sync.WaitGroup
wg.Add(len(epc.procs))
for i := range epc.procs {
go func(i int) {
epc.procs[i].cfg.execPath = binDir + "/etcd"
epc.procs[i].cfg.keepDataDir = true
if err := epc.procs[i].Restart(); err != nil {
t.Fatalf("error restarting etcd process (%v)", err)
}
wg.Done()
}(i)
}
wg.Wait()

if err := ctlV3Get(cx, []string{kvs[0].key}, []kv{kvs[0]}...); err != nil {
t.Fatal(err)
}
}

0 comments on commit a6d22b9

Please sign in to comment.