Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix e2e test #115

Merged
merged 4 commits into from
Aug 18, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 1 addition & 2 deletions hack/functest.sh
Original file line number Diff line number Diff line change
Expand Up @@ -31,10 +31,9 @@ else
# so we create a fake etcd-quorum-guard PDB with maxUnavailable = 0, which will always result in disruptionsAllowed = 0 without a corresponding deployment
# that will make node maintenance requests for master nodes always fail
$CLUSTER_COMMAND apply -f test/manifests/fake-etcd-quorum-guard.yaml
OPERATOR_NS=node-maintenance
fi

OPERATOR_NS=node-maintenance

fi

# Run tests
Expand Down
4 changes: 4 additions & 0 deletions hack/sync-deploy.sh
Original file line number Diff line number Diff line change
Expand Up @@ -108,6 +108,10 @@ until [[ $success -eq 1 ]] || [[ $iterations -eq $max_iterations ]]; do
else
# All resources deployed successfully
success=1
# Fixme Webhook setup is slow... service needs to be created, endpoint needs to be created, and webhook server must be running
# Didn't find an easy but good solution yet, so just wait a bit for now
echo "[INFO] Giving the webhook some time to setup"
sleep 30s
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

A timeout is fine for now, but perhaps creating/deleting an invalid CRD in a loop until it fails would tell you when it's finally set up?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

good idea 👍

fi
set -e

Expand Down
14 changes: 9 additions & 5 deletions test/e2e/nodemaintenance_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -44,8 +44,8 @@ func getCurrentOperatorPods() (*corev1.Pod, error) {
return nil, err
}

if pods.Size() == 0 {
return nil, fmt.Errorf("There are no pods deployed in cluster to run the operator")
if len(pods.Items) == 0 {
return nil, fmt.Errorf("no NMO pod found in ns %s", ns)
}

return &pods.Items[0], nil
Expand Down Expand Up @@ -88,8 +88,8 @@ func showDeploymentStatus(t *testing.T, callerError error) {

func checkValidLease(t *testing.T, nodeName string) error {

// FIXME this won't work: nmo.LeaseNamespace is overwritten by the operator during runtime, and we will never see that here...
nName := types.NamespacedName{Namespace: nmo.LeaseNamespace, Name: nodeName}
ns := os.Getenv("OPERATOR_NS")
nName := types.NamespacedName{Namespace: ns, Name: nodeName}
lease := &coordv1beta1.Lease{}
err := Client.Get(context.TODO(), nName, lease)
if err != nil {
Expand Down Expand Up @@ -122,7 +122,8 @@ func checkValidLease(t *testing.T, nodeName string) error {
}

func checkInvalidLease(t *testing.T, nodeName string) error {
nName := types.NamespacedName{Namespace: nmo.LeaseNamespace, Name: nodeName}
ns := os.Getenv("OPERATOR_NS")
nName := types.NamespacedName{Namespace: ns, Name: nodeName}
lease := &coordv1beta1.Lease{}
err := Client.Get(context.TODO(), nName, lease)
if err != nil {
Expand Down Expand Up @@ -234,7 +235,10 @@ func enterAndExitMaintenanceMode(t *testing.T) error {
}
} else {
t.Fatalf("unexpexted nr of master nodes, can't run master quorum validation test")
break
}
// the etcd-quorum-guard PDB needs some time to be updated...
time.Sleep(10 * time.Second)
}

err = createSimpleDeployment(t, namespace)
Expand Down