Skip to content

Commit 4f47ce8

Browse files
n3wscottVille Aikas
authored and
Ville Aikas
committed
Embed etcd in the integration tests directly. (#1570)
* Updating etcd. * Adding deps for etcd. * Revert delete of comments. * Fix paste, * Move etcd port for current integration tests. * Move etcd port for current integration tests. * Use embed ectd for intergration tests. * Always use a open port for integration ectd service. * Remove the test that starts ectd with MainTest also starting etcd. * Now time to panic.
1 parent d02ac34 commit 4f47ce8

File tree

1,267 files changed

+344064
-6570
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

1,267 files changed

+344064
-6570
lines changed

glide.lock

+46-23
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

glide.yaml

+2
Original file line numberDiff line numberDiff line change
@@ -94,3 +94,5 @@ import:
9494
version: 215affda49addc4c8ef7e2534915df2c8c35c6cd
9595
- package: github.com/pmorie/go-open-service-broker-client
9696
version: 31d8027f493f8f23f850415d171c7c52a972a6f2
97+
- package: github.com/coreos/etcd
98+
version: ^3.2.9

test/integration.sh

+2-2
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ source "${KUBE_ROOT}/hack/lib/init.sh"
2424
GOROOT=$(go env GOROOT)
2525

2626
runTests() {
27-
kube::etcd::start
27+
# kube::etcd::start
2828

2929
if [[ -w ${GOROOT}/pkg ]]; then
3030
FLAGS="-i"
@@ -39,7 +39,7 @@ runTests() {
3939
}
4040

4141
# Run cleanup to stop etcd on interrupt or other kill signal.
42-
trap kube::etcd::cleanup EXIT
42+
# trap kube::etcd::cleanup EXIT
4343

4444
runTests $@
4545

test/integration/etcd_test.go

+76
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,76 @@
1+
/*
2+
Copyright 2017 The Kubernetes Authors.
3+
4+
Licensed under the Apache License, Version 2.0 (the "License");
5+
you may not use this file except in compliance with the License.
6+
You may obtain a copy of the License at
7+
8+
http://www.apache.org/licenses/LICENSE-2.0
9+
10+
Unless required by applicable law or agreed to in writing, software
11+
distributed under the License is distributed on an "AS IS" BASIS,
12+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
See the License for the specific language governing permissions and
14+
limitations under the License.
15+
*/
16+
17+
package integration
18+
19+
import (
20+
"fmt"
21+
"github.com/coreos/etcd/embed"
22+
"github.com/golang/glog"
23+
"io/ioutil"
24+
"os"
25+
"testing"
26+
"time"
27+
)
28+
29+
type EtcdContext struct {
30+
etcd *embed.Etcd
31+
dir string
32+
Endpoint string
33+
}
34+
35+
var etcdContext = EtcdContext{}
36+
37+
func startEtcd() error {
38+
var err error
39+
if etcdContext.dir, err = ioutil.TempDir(os.TempDir(), "service_catalog_integration_test"); err != nil {
40+
return fmt.Errorf("could not create TempDir: %v", err)
41+
}
42+
cfg := embed.NewConfig()
43+
cfg.Dir = etcdContext.dir
44+
45+
if etcdContext.etcd, err = embed.StartEtcd(cfg); err != nil {
46+
return fmt.Errorf("Failed starting etcd: %+v", err)
47+
}
48+
49+
select {
50+
case <-etcdContext.etcd.Server.ReadyNotify():
51+
glog.Info("server is ready!")
52+
case <-time.After(60 * time.Second):
53+
etcdContext.etcd.Server.Stop() // trigger a shutdown
54+
glog.Error("server took too long to start!")
55+
}
56+
return nil
57+
}
58+
59+
func stopEtcd() {
60+
etcdContext.etcd.Server.Stop()
61+
os.RemoveAll(etcdContext.dir)
62+
}
63+
64+
func TestMain(m *testing.M) {
65+
// Setup
66+
if err := startEtcd(); err != nil {
67+
panic(fmt.Sprintf("Failed to start etcd, %v", err))
68+
}
69+
70+
// Tests
71+
result := m.Run()
72+
73+
// Teardown
74+
stopEtcd()
75+
os.Exit(result)
76+
}

vendor/github.com/boltdb/bolt/.gitignore

+4
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

vendor/github.com/boltdb/bolt/LICENSE

+20
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

vendor/github.com/boltdb/bolt/Makefile

+18
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)