Skip to content

Commit

Permalink
update-etcd-scaling-test
Browse files Browse the repository at this point in the history
  • Loading branch information
Elbehery committed Mar 9, 2023
1 parent 2971fc9 commit 75f666c
Showing 1 changed file with 23 additions and 24 deletions.
47 changes: 23 additions & 24 deletions test/extended/etcd/helpers/helpers.go
Original file line number Diff line number Diff line change
Expand Up @@ -184,37 +184,36 @@ func recoverClusterToInitialStateIfNeeded(ctx context.Context, t TestingT, machi
}

func DeleteSingleMachine(ctx context.Context, t TestingT, machineClient machinev1beta1client.MachineInterface) (string, error) {
waitPollInterval := 15 * time.Second
waitPollInterval := 30 * time.Second
waitPollTimeout := 5 * time.Minute
t.Logf("Waiting up to %s to delete a machine", waitPollTimeout.String())

machineToDelete := ""
err := wait.Poll(waitPollInterval, waitPollTimeout, func() (bool, error) {
machineList, err := machineClient.List(ctx, metav1.ListOptions{LabelSelector: masterMachineLabelSelector})
if err != nil {
return isTransientAPIError(t, err)
}

// Machine names are suffixed with an index number (e.g "ci-op-xlbdrkvl-6a467-qcbkh-master-0")
// so we sort to pick the lowest index, e.g master-0 in this example
machineNames := []string{}
for _, m := range machineList.Items {
machineNames = append(machineNames, m.Name)
}
sort.Strings(machineNames)
machineToDelete = machineNames[0]
t.Logf("attempting to delete machine %q", machineToDelete)
machineList, err := machineClient.List(ctx, metav1.ListOptions{LabelSelector: masterMachineLabelSelector})
if err != nil {
return "", fmt.Errorf("error listing master machines: '%w'", err)
}

// Machine names are suffixed with an index number (e.g "ci-op-xlbdrkvl-6a467-qcbkh-master-0")
// so we sort to pick the lowest index, e.g master-0 in this example
machineNames := []string{}
for _, m := range machineList.Items {
machineNames = append(machineNames, m.Name)
}
sort.Strings(machineNames)
machineToDelete = machineNames[0]

t.Logf("Waiting up to %s to delete a machine", waitPollTimeout.String())

err = wait.Poll(waitPollInterval, waitPollTimeout, func() (bool, error) {
t.Logf("attempting to delete machine '%q'", machineToDelete)
if err := machineClient.Delete(ctx, machineToDelete, metav1.DeleteOptions{}); err != nil {
// The machine we just listed should be present but if not, error out
if apierrors.IsNotFound(err) {
t.Logf("machine %q was listed but not found or already deleted", machineToDelete)
return false, fmt.Errorf("machine %q was listed but not found or already deleted", machineToDelete)
t.Logf("machine '%q' was listed but not found or already deleted", machineToDelete)
return false, nil
}
return isTransientAPIError(t, err)
return false, err
}
t.Logf("successfully deleted machine %q", machineToDelete)

t.Logf("successfully deleted machine '%q'", machineToDelete)
return true, nil
})

Expand Down Expand Up @@ -247,7 +246,7 @@ func IsCPMSActive(ctx context.Context, t TestingT, cpmsClient machinev1client.Co
// EnsureReadyReplicasOnCPMS checks if status.readyReplicas on the cluster CPMS is n
// this effectively counts the number of control-plane machines with the provider state as running
func EnsureReadyReplicasOnCPMS(ctx context.Context, t TestingT, expectedReplicaCount int, cpmsClient machinev1client.ControlPlaneMachineSetInterface) error {
waitPollInterval := 5 * time.Second
waitPollInterval := 2 * time.Second
waitPollTimeout := 18 * time.Minute
t.Logf("Waiting up to %s for the CPMS to have status.readyReplicas = %v", waitPollTimeout.String(), expectedReplicaCount)

Expand Down

0 comments on commit 75f666c

Please sign in to comment.