-
Notifications
You must be signed in to change notification settings - Fork 65
🏃♂️ Add a test to ensure that exactly one control plane machine initializes if there are multiple control plane machines defined #221
Conversation
@@ -970,6 +970,67 @@ func TestKubeadmConfigReconciler_ClusterToKubeadmConfigs(t *testing.T) { | |||
} | |||
} | |||
|
|||
// Exactly one control plane machine initializes if there are multiple control plane machines defined | |||
func TestKubeadmConfigReconciler_Reconcile_ExactlyOneControlPlaneMachineInitializes(t *testing.T) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
side topic: i think that _
in function names fails golint
is this file ignored from golint checks?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm not sure actually..i didn't see anything in the code that indicated tests are skipped. I'd say let's not worry about it for this PR. I've made an issue for it #223
} | ||
result, err := k.Reconcile(request) | ||
if err != nil { | ||
t.Fatal(fmt.Sprintf("Failed to reconcile:\n %+v", err)) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
use Fatalf
instead of Fatal + Sprintf
[1]
t.Fatal(fmt.Sprintf("Failed to reconcile:\n %+v", err)) | ||
} | ||
if result.Requeue == true { | ||
t.Fatal("did not expected to requeue") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
did not expect
} | ||
result, err = k.Reconcile(request) | ||
if err != nil { | ||
t.Fatal(fmt.Sprintf("Failed to reconcile:\n %+v", err)) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
[1]
t.Fatal("did not expected to requeue") | ||
} | ||
if result.RequeueAfter != time.Duration(0) { | ||
t.Fatal("did not expected to requeue after") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
did not expect
t.Fatal(fmt.Sprintf("Failed to reconcile:\n %+v", err)) | ||
} | ||
if result.Requeue == true { | ||
t.Fatal("did not expected to requeue") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
did not expect
m.locked = true | ||
return true | ||
} | ||
return false |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
should we always return true
for the fake Lock?
This looks great to me pending @neolit123's changes. The fake lock is a little bit weird, would it be possible to always return true? a simpler implementation would be better, but if this is necessary for now then let's leave it. |
165238d
to
844276a
Compare
Thanks @chuckha |
/approve thanks for the update this looks really good! /assign @neolit123 |
[APPROVALNOTIFIER] This PR is APPROVED This pull-request has been approved by: chuckha, SataQiu The full list of commands accepted by this bot can be found here. The pull request process is described here
Needs approval from an approver in each of these files:
Approvers can indicate their approval by writing |
ping @neolit123 |
…es if there are multiple control plane machines defined
844276a
to
279b3c3
Compare
Hi @ncdc |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM on the remarks i've made.
thanks.
/lgtm |
What this PR does / why we need it:
Add a test to ensure that exactly one control plane machine initializes if there are multiple control plane machines defined
Which issue(s) this PR fixes (optional, in
fixes #<issue number>(, fixes #<issue_number>, ...)
format, will close the issue(s) when PR gets merged):Ref #214