diff --git a/functional/platform/cluster.go b/functional/platform/cluster.go index 2320b1fde..c354871d9 100644 --- a/functional/platform/cluster.go +++ b/functional/platform/cluster.go @@ -35,7 +35,7 @@ type Cluster interface { // client operations Fleetctl(m Member, args ...string) (string, string, error) FleetctlWithInput(m Member, input string, args ...string) (string, string, error) - WaitForNAllUnits(Member, int) error + WaitForNUnits(Member, int) error WaitForNActiveUnits(Member, int) (map[string][]util.UnitState, error) WaitForNMachines(Member, int) ([]string, error) } diff --git a/functional/platform/nspawn.go b/functional/platform/nspawn.go index 4758d0252..8da62b2d2 100644 --- a/functional/platform/nspawn.go +++ b/functional/platform/nspawn.go @@ -104,7 +104,7 @@ func (nc *nspawnCluster) FleetctlWithInput(m Member, input string, args ...strin return util.RunFleetctlWithInput(input, args...) } -func (nc *nspawnCluster) WaitForNAllUnits(m Member, count int) error { +func (nc *nspawnCluster) WaitForNUnits(m Member, count int) error { timeout := 15 * time.Second alarm := time.After(timeout) diff --git a/functional/unit_action_test.go b/functional/unit_action_test.go index 7cf751c5f..07f7bbb92 100644 --- a/functional/unit_action_test.go +++ b/functional/unit_action_test.go @@ -356,14 +356,10 @@ func replaceUnitCommon(cmd string) error { return fmt.Errorf("Failed to destroy unit: %v", err) } - if err := cluster.WaitForNAllUnits(m, 0); err != nil { + if err := cluster.WaitForNUnits(m, 0); err != nil { return fmt.Errorf("Failed to get every unit to be cleaned up: %v", err) } - if err := waitForActiveUnitsReplaceCmds(cluster, m, cmd, 0); err != nil { - return err - } - return nil } @@ -486,16 +482,12 @@ func replaceUnitMultiple(cmd string, n int) error { os.Remove(curHelloService) } - if err := cluster.WaitForNAllUnits(m, 0); err != nil { + if err := cluster.WaitForNUnits(m, 0); err != nil { return fmt.Errorf("Failed to get every unit to be cleaned up: %v", err) } os.Remove(tmpFixtures) - if err := waitForActiveUnitsReplaceCmds(cluster, m, cmd, 0); err != nil { - return err - } - return nil } @@ -534,32 +526,3 @@ func genNewFleetService(newFile, oldFile, newVal, oldVal string) error { } return nil } - -// waitForActiveUnitsReplaceCmds() is a wrapper for waiting for N active units. -// The expected number of active units are given as a parameter "count". -// If cmd is "start", it expects that "count" active units are active. -// Otherwise, for "load" or "submit", it expects no active unit. -func waitForActiveUnitsReplaceCmds(cluster platform.Cluster, m platform.Member, cmd string, count int) error { - if cmd == "start" { - units, err := cluster.WaitForNActiveUnits(m, count) - if err != nil { - fmt.Errorf("%v", err) - } - _, found := units["hello.service"] - if len(units) != count || !found { - fmt.Errorf("Expected hello.service to be sole active unit, got %v", units) - } - } else { - // cmd is "load" or "submit", then there's no active unit - units, err := cluster.WaitForNActiveUnits(m, 0) - if err != nil { - fmt.Errorf("%v", err) - } - _, found := units["hello.service"] - if len(units) != 0 || !found { - fmt.Errorf("Expected hello.service to be sole active unit, got %v", units) - } - } - - return nil -}