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

Commit

Permalink
functional: export Keyspace() method for tests running etcdctl
Browse files Browse the repository at this point in the history
  • Loading branch information
Dongsu Park committed Mar 23, 2016
1 parent 42e5f99 commit 628ee52
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 9 deletions.
2 changes: 2 additions & 0 deletions functional/platform/cluster.go
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,8 @@ type Cluster interface {
EtcdctlWithInput(m Member, input string, args ...string) (string, string, error)
WaitForNActiveUnits(Member, int) (map[string][]util.UnitState, error)
WaitForNMachines(Member, int) ([]string, error)

Keyspace() string
}

func CreateNClusterMembers(cl Cluster, count int) ([]Member, error) {
Expand Down
6 changes: 3 additions & 3 deletions functional/platform/nspawn.go
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,7 @@ func (nc *nspawnCluster) nextID() string {
return strconv.Itoa(nc.maxID)
}

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

etcd := "http://172.18.0.1:4001"
return util.BuildCloudConfig(userFile, ip, etcd, nc.keyspace())
return util.BuildCloudConfig(userFile, ip, etcd, nc.Keyspace())
}

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

run("ip link del fleet0")

Expand Down
13 changes: 7 additions & 6 deletions functional/unit_action_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -299,11 +299,10 @@ func TestUnitDestroyFromRegistry(t *testing.T) {
}

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

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

var stdout string
Expand Down

0 comments on commit 628ee52

Please sign in to comment.