Skip to content
This repository was archived by the owner on Jan 30, 2020. It is now read-only.

Commit 628ee52

Browse files
author
Dongsu Park
committed
functional: export Keyspace() method for tests running etcdctl
1 parent 42e5f99 commit 628ee52

3 files changed

Lines changed: 12 additions & 9 deletions

File tree

functional/platform/cluster.go

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,8 @@ type Cluster interface {
3939
EtcdctlWithInput(m Member, input string, args ...string) (string, string, error)
4040
WaitForNActiveUnits(Member, int) (map[string][]util.UnitState, error)
4141
WaitForNMachines(Member, int) ([]string, error)
42+
43+
Keyspace() string
4244
}
4345

4446
func CreateNClusterMembers(cl Cluster, count int) ([]Member, error) {

functional/platform/nspawn.go

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -89,7 +89,7 @@ func (nc *nspawnCluster) nextID() string {
8989
return strconv.Itoa(nc.maxID)
9090
}
9191

92-
func (nc *nspawnCluster) keyspace() string {
92+
func (nc *nspawnCluster) Keyspace() string {
9393
// TODO(jonboulle): generate this dynamically with atomic in order keys?
9494
return fmt.Sprintf("/fleet_functional/%s", nc.name)
9595
}
@@ -262,7 +262,7 @@ func (nc *nspawnCluster) buildConfigDrive(dir, ip string) error {
262262
defer userFile.Close()
263263

264264
etcd := "http://172.18.0.1:4001"
265-
return util.BuildCloudConfig(userFile, ip, etcd, nc.keyspace())
265+
return util.BuildCloudConfig(userFile, ip, etcd, nc.Keyspace())
266266
}
267267

268268
func (nc *nspawnCluster) Members() []Member {
@@ -433,7 +433,7 @@ func (nc *nspawnCluster) Destroy() error {
433433
// TODO(bcwaldon): This returns 4 on success, but we can't easily
434434
// ignore just that return code. Ignore the returned error
435435
// altogether until this is fixed.
436-
run("etcdctl rm --recursive " + nc.keyspace())
436+
run("etcdctl rm --recursive " + nc.Keyspace())
437437

438438
run("ip link del fleet0")
439439

functional/unit_action_test.go

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -299,11 +299,10 @@ func TestUnitDestroyFromRegistry(t *testing.T) {
299299
}
300300

301301
// check for the unit being destroyed from the etcd registry
302-
etcdUnitPrefix := "/_coreos.com/fleet/unit/"
302+
//etcdUnitPrefix := "/_coreos.com/fleet/unit/"
303+
etcdUnitPrefix := path.Join(cluster.Keyspace(), "unit")
303304
etcdUnitPath := path.Join(etcdUnitPrefix, hashUnit)
304-
if stdout, _, err = cluster.Etcdctl(m, "ls", etcdUnitPath); err != nil {
305-
t.Fatalf("Failed to list a unit from the registry: %v", err)
306-
}
305+
stdout, _, err = cluster.Etcdctl(m, "ls", etcdUnitPath)
307306
units = strings.Split(strings.TrimSpace(stdout), "\n")
308307
if len(stdout) != 0 && len(units) != 1 {
309308
t.Fatalf("The unit still remains in the registry: %v", err)
@@ -313,7 +312,8 @@ func TestUnitDestroyFromRegistry(t *testing.T) {
313312
// retrieveJobObjectHash fetches the job hash value from
314313
// /_coreos.com/fleet/job/<jobName>/object in the etcd registry.
315314
func retrieveJobObjectHash(cluster platform.Cluster, m platform.Member, jobName string) (hash string, err error) {
316-
etcdJobPrefix := "/_coreos.com/fleet/job/"
315+
// etcdJobPrefix := "/_coreos.com/fleet/job/"
316+
etcdJobPrefix := path.Join(cluster.Keyspace(), "job")
317317
etcdJobPath := path.Join(etcdJobPrefix, jobName, "object")
318318

319319
var stdout string
@@ -347,7 +347,8 @@ func retrieveJobObjectHash(cluster platform.Cluster, m platform.Member, jobName
347347
// retrieveUnitBody fetches unit body from /_coreos.com/fleet/unit/<hash>
348348
// in the etcd registry.
349349
func retrieveUnitBody(cluster platform.Cluster, m platform.Member, hashUnit string) (regBody string, err error) {
350-
etcdUnitPrefix := "/_coreos.com/fleet/unit/"
350+
// etcdUnitPrefix := "/_coreos.com/fleet/unit/"
351+
etcdUnitPrefix := path.Join(cluster.Keyspace(), "unit")
351352
etcdUnitPath := path.Join(etcdUnitPrefix, hashUnit)
352353

353354
var stdout string

0 commit comments

Comments
 (0)