Skip to content

Commit

Permalink
validate ready and available node counts
Browse files Browse the repository at this point in the history
  • Loading branch information
Dhairya-Arora01 committed May 28, 2024
1 parent 089e073 commit d0f12a1
Showing 1 changed file with 65 additions and 0 deletions.
65 changes: 65 additions & 0 deletions exp/internal/controllers/machinepool_controller_noderef_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,14 @@ func TestMachinePoolGetNodeReference(t *testing.T) {
Spec: corev1.NodeSpec{
ProviderID: "aws://us-east-1/id-node-1",
},
Status: corev1.NodeStatus{
Conditions: []corev1.NodeCondition{
{
Type: corev1.NodeReady,
Status: corev1.ConditionTrue,
},
},
},
},
&corev1.Node{
ObjectMeta: metav1.ObjectMeta{
Expand All @@ -53,6 +61,14 @@ func TestMachinePoolGetNodeReference(t *testing.T) {
Spec: corev1.NodeSpec{
ProviderID: "aws://us-west-2/id-node-2",
},
Status: corev1.NodeStatus{
Conditions: []corev1.NodeCondition{
{
Type: corev1.NodeReady,
Status: corev1.ConditionTrue,
},
},
},
},
&corev1.Node{
ObjectMeta: metav1.ObjectMeta{
Expand All @@ -61,6 +77,14 @@ func TestMachinePoolGetNodeReference(t *testing.T) {
Spec: corev1.NodeSpec{
ProviderID: "gce://us-central1/gce-id-node-2",
},
Status: corev1.NodeStatus{
Conditions: []corev1.NodeCondition{
{
Type: corev1.NodeReady,
Status: corev1.ConditionTrue,
},
},
},
},
&corev1.Node{
ObjectMeta: metav1.ObjectMeta{
Expand All @@ -69,6 +93,14 @@ func TestMachinePoolGetNodeReference(t *testing.T) {
Spec: corev1.NodeSpec{
ProviderID: "azure://westus2/id-node-4",
},
Status: corev1.NodeStatus{
Conditions: []corev1.NodeCondition{
{
Type: corev1.NodeReady,
Status: corev1.ConditionTrue,
},
},
},
},
&corev1.Node{
ObjectMeta: metav1.ObjectMeta{
Expand All @@ -77,6 +109,14 @@ func TestMachinePoolGetNodeReference(t *testing.T) {
Spec: corev1.NodeSpec{
ProviderID: "azure://westus2/id-nodepool1/0",
},
Status: corev1.NodeStatus{
Conditions: []corev1.NodeCondition{
{
Type: corev1.NodeReady,
Status: corev1.ConditionTrue,
},
},
},
},
&corev1.Node{
ObjectMeta: metav1.ObjectMeta{
Expand All @@ -85,6 +125,14 @@ func TestMachinePoolGetNodeReference(t *testing.T) {
Spec: corev1.NodeSpec{
ProviderID: "azure://westus2/id-nodepool2/0",
},
Status: corev1.NodeStatus{
Conditions: []corev1.NodeCondition{
{
Type: corev1.NodeReady,
Status: corev1.ConditionTrue,
},
},
},
},
}

Expand All @@ -104,6 +152,8 @@ func TestMachinePoolGetNodeReference(t *testing.T) {
references: []corev1.ObjectReference{
{Name: "node-1"},
},
available: 1,
ready: 1,
},
},
{
Expand All @@ -113,6 +163,8 @@ func TestMachinePoolGetNodeReference(t *testing.T) {
references: []corev1.ObjectReference{
{Name: "node-2"},
},
available: 1,
ready: 1,
},
},
{
Expand All @@ -122,6 +174,8 @@ func TestMachinePoolGetNodeReference(t *testing.T) {
references: []corev1.ObjectReference{
{Name: "gce-node-2"},
},
available: 1,
ready: 1,
},
},
{
Expand All @@ -131,6 +185,8 @@ func TestMachinePoolGetNodeReference(t *testing.T) {
references: []corev1.ObjectReference{
{Name: "azure-node-4"},
},
available: 1,
ready: 1,
},
},
{
Expand All @@ -141,6 +197,8 @@ func TestMachinePoolGetNodeReference(t *testing.T) {
{Name: "node-1"},
{Name: "azure-node-4"},
},
available: 2,
ready: 2,
},
},
{
Expand All @@ -165,6 +223,8 @@ func TestMachinePoolGetNodeReference(t *testing.T) {
references: []corev1.ObjectReference{
{Name: "azure-nodepool1-0"},
},
available: 1,
ready: 1,
},
},
{
Expand All @@ -175,6 +235,8 @@ func TestMachinePoolGetNodeReference(t *testing.T) {
{Name: "azure-nodepool1-0"},
{Name: "azure-nodepool2-0"},
},
available: 2,
ready: 2,
},
},
{
Expand Down Expand Up @@ -217,6 +279,9 @@ func TestMachinePoolGetNodeReference(t *testing.T) {

g.Expect(result.references).To(HaveLen(len(test.expected.references)), "Expected NodeRef count to be %v, got %v", len(result.references), len(test.expected.references))

g.Expect(result.available).To(Equal(test.expected.available), "Expected available node count to be %v, got %v", test.expected.available, result.available)
g.Expect(result.ready).To(Equal(test.expected.ready), "Expected ready node count to be %v, got %v", test.expected.ready, result.ready)

for n := range test.expected.references {
g.Expect(result.references[n].Name).To(Equal(test.expected.references[n].Name), "Expected NodeRef's name to be %v, got %v", result.references[n].Name, test.expected.references[n].Name)
g.Expect(result.references[n].Namespace).To(Equal(test.expected.references[n].Namespace), "Expected NodeRef's namespace to be %v, got %v", result.references[n].Namespace, test.expected.references[n].Namespace)
Expand Down

0 comments on commit d0f12a1

Please sign in to comment.