mirror of
https://github.com/etcd-io/etcd.git
synced 2024-09-27 06:25:44 +00:00
Migration test.
This commit is contained in:
2
release_version.go
Normal file
2
release_version.go
Normal file
@@ -0,0 +1,2 @@
|
||||
package main
|
||||
const releaseVersion = "v0.1.2-33-g1a2a9d6"
|
||||
14
tests/fixtures/v1/README
vendored
Normal file
14
tests/fixtures/v1/README
vendored
Normal file
@@ -0,0 +1,14 @@
|
||||
README
|
||||
|
||||
The scripts in this directory should be run from the project root:
|
||||
|
||||
$ cd $GOPATH/src/github.com/coreos/etcd
|
||||
$ tests/fixtures/v1/complete.1.sh
|
||||
|
||||
Scripts with numbers should be run in separate terminal windows (in order):
|
||||
|
||||
$ tests/fixtures/v1/complete.1.sh
|
||||
$ tests/fixtures/v1/complete.2.sh
|
||||
$ tests/fixtures/v1/complete.3.sh
|
||||
|
||||
The resulting server state data can be found in tmp/node0.
|
||||
4
tests/fixtures/v1/complete.1.sh
vendored
Normal file
4
tests/fixtures/v1/complete.1.sh
vendored
Normal file
@@ -0,0 +1,4 @@
|
||||
#!/bin/sh
|
||||
|
||||
./build
|
||||
./etcd -d tmp/node0 -n node0
|
||||
3
tests/fixtures/v1/complete.2.sh
vendored
Normal file
3
tests/fixtures/v1/complete.2.sh
vendored
Normal file
@@ -0,0 +1,3 @@
|
||||
#!/bin/sh
|
||||
|
||||
./etcd -s 127.0.0.1:7002 -c 127.0.0.1:4002 -C 127.0.0.1:7001 -d tmp/node2 -n node2
|
||||
3
tests/fixtures/v1/complete.3.sh
vendored
Normal file
3
tests/fixtures/v1/complete.3.sh
vendored
Normal file
@@ -0,0 +1,3 @@
|
||||
#!/bin/sh
|
||||
|
||||
./etcd -s 127.0.0.1:7003 -c 127.0.0.1:4003 -C 127.0.0.1:7001 -d tmp/node3 -n node3
|
||||
12
tests/fixtures/v1/complete.4.sh
vendored
Normal file
12
tests/fixtures/v1/complete.4.sh
vendored
Normal file
@@ -0,0 +1,12 @@
|
||||
#!/bin/sh
|
||||
|
||||
curl -L http://127.0.0.1:4001/v1/keys/message -d value="Hello world"
|
||||
curl -L http://127.0.0.1:4001/v1/keys/message -d value="Hello etcd"
|
||||
curl -L http://127.0.0.1:4001/v1/keys/message -X DELETE
|
||||
curl -L http://127.0.0.1:4001/v1/keys/foo -d value=bar -d ttl=5
|
||||
curl -L http://127.0.0.1:4001/v1/keys/foo -d value=one
|
||||
curl -L http://127.0.0.1:4001/v1/keys/foo -d prevValue=two -d value=three
|
||||
curl -L http://127.0.0.1:4001/v1/keys/foo -d prevValue=one -d value=two
|
||||
curl -L http://127.0.0.1:4001/v1/keys/bar -d prevValue= -d value=four
|
||||
curl -L http://127.0.0.1:4001/v1/keys/bar -d prevValue= -d value=five
|
||||
curl -X DELETE http://127.0.0.1:4001/v1/keys/_etcd/machines
|
||||
1
tests/fixtures/v1/complete/conf
vendored
Normal file
1
tests/fixtures/v1/complete/conf
vendored
Normal file
@@ -0,0 +1 @@
|
||||
{"commitIndex":13,"peers":[]}
|
||||
18
tests/fixtures/v1/complete/info
vendored
Normal file
18
tests/fixtures/v1/complete/info
vendored
Normal file
@@ -0,0 +1,18 @@
|
||||
{
|
||||
"name": "node0",
|
||||
"raftURL": "http://127.0.0.1:7001",
|
||||
"etcdURL": "http://127.0.0.1:4001",
|
||||
"webURL": "",
|
||||
"raftListenHost": "127.0.0.1:7001",
|
||||
"etcdListenHost": "127.0.0.1:4001",
|
||||
"raftTLS": {
|
||||
"CertFile": "",
|
||||
"KeyFile": "",
|
||||
"CAFile": ""
|
||||
},
|
||||
"etcdTLS": {
|
||||
"CertFile": "",
|
||||
"KeyFile": "",
|
||||
"CAFile": ""
|
||||
}
|
||||
}
|
||||
BIN
tests/fixtures/v1/complete/log
vendored
Normal file
BIN
tests/fixtures/v1/complete/log
vendored
Normal file
Binary file not shown.
51
tests/functional/v1_migration_test.go
Normal file
51
tests/functional/v1_migration_test.go
Normal file
@@ -0,0 +1,51 @@
|
||||
package test
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"io/ioutil"
|
||||
"os"
|
||||
"os/exec"
|
||||
"testing"
|
||||
"time"
|
||||
|
||||
"github.com/coreos/etcd/tests"
|
||||
"github.com/stretchr/testify/assert"
|
||||
)
|
||||
|
||||
// Ensure that we can start a v2 node from the log of a v1 node.
|
||||
func TestV1Migration(t *testing.T) {
|
||||
path, _ := ioutil.TempDir("", "etcd-")
|
||||
os.RemoveAll(path)
|
||||
defer os.RemoveAll(path)
|
||||
|
||||
// Copy over fixture files.
|
||||
if err := exec.Command("cp", "-r", "../fixtures/v1/complete", path).Run(); err != nil {
|
||||
panic("Fixture initialization error")
|
||||
}
|
||||
|
||||
procAttr := new(os.ProcAttr)
|
||||
procAttr.Files = []*os.File{nil, os.Stdout, os.Stderr}
|
||||
args := []string{"etcd", fmt.Sprintf("-d=%s", path)}
|
||||
|
||||
process, err := os.StartProcess(EtcdBinPath, args, procAttr)
|
||||
if err != nil {
|
||||
t.Fatal("start process failed:" + err.Error())
|
||||
return
|
||||
}
|
||||
defer process.Kill()
|
||||
time.Sleep(time.Second)
|
||||
|
||||
|
||||
// Ensure deleted message is removed.
|
||||
resp, err := tests.Get("http://localhost:4001/v2/keys/message")
|
||||
tests.ReadBody(resp)
|
||||
assert.Nil(t, err, "")
|
||||
assert.Equal(t, resp.StatusCode, 404, "")
|
||||
|
||||
// Ensure TTL'd message is removed.
|
||||
resp, err = tests.Get("http://localhost:4001/v2/keys/foo")
|
||||
tests.ReadBody(resp)
|
||||
assert.Nil(t, err, "")
|
||||
assert.Equal(t, resp.StatusCode, 404, "")
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user