mirror of
https://github.com/cunnie/sslip.io.git
synced 2025-10-05 15:46:50 +08:00
🐞 Don't run etcd tests without etcd
Now we check first to see if etcd is running before diving in & testing against it. fixes: ``` Unexpected error: <*fmt.wrapError | 0xc0003bc8e0>: { msg: "couldn't GET \"my-key\": context deadline exceeded", err: <context.deadlineExceededError>{}, } ```
This commit is contained in:
@@ -4,7 +4,7 @@
|
||||
#
|
||||
DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" >/dev/null 2>&1 && pwd )"
|
||||
cd $DIR/../src/sslip.io-dns-server
|
||||
ldflags="-X xip/xip.VersionSemantic=2.3.0 \
|
||||
ldflags="-X xip/xip.VersionSemantic=2.4.0 \
|
||||
-X xip/xip.VersionDate=$(date +%Y/%m/%d-%H:%M:%S%z) \
|
||||
-X xip/xip.VersionGitHash=$(git rev-parse --short HEAD)"
|
||||
export GOOS GOARCH
|
||||
|
@@ -201,20 +201,28 @@ var _ = Describe("Xip", func() {
|
||||
When("there's no etcd, just local, in-memory key-value", func() {
|
||||
txtTests()
|
||||
})
|
||||
When(`etcd is backing the kv store`, func() {
|
||||
BeforeEach(func() {
|
||||
etcdCli, err := clientv3.New(clientv3.Config{
|
||||
Endpoints: []string{"localhost:2379"},
|
||||
DialTimeout: 250 * time.Millisecond,
|
||||
etcdURI := "localhost:2379"
|
||||
// make sure there's an etcd listening before we run our tests
|
||||
conn, err := net.DialTimeout("tcp", etcdURI, 250*time.Millisecond)
|
||||
if err == nil {
|
||||
err = conn.Close()
|
||||
Expect(err).ToNot(HaveOccurred())
|
||||
When(`etcd is backing the kv store`, func() {
|
||||
BeforeEach(func() {
|
||||
etcdCli, err := clientv3.New(clientv3.Config{
|
||||
Endpoints: []string{etcdURI},
|
||||
DialTimeout: 250 * time.Millisecond,
|
||||
})
|
||||
Expect(err).ToNot(HaveOccurred())
|
||||
x.Etcd = etcdCli
|
||||
})
|
||||
Expect(err).ToNot(HaveOccurred())
|
||||
x.Etcd = etcdCli
|
||||
AfterEach(func() {
|
||||
err = x.Etcd.Close()
|
||||
Expect(err).ToNot(HaveOccurred())
|
||||
})
|
||||
txtTests()
|
||||
})
|
||||
AfterEach(func() {
|
||||
x.Etcd.Close()
|
||||
})
|
||||
txtTests()
|
||||
})
|
||||
}
|
||||
})
|
||||
})
|
||||
|
||||
|
Reference in New Issue
Block a user