Skip to content
This repository has been archived by the owner on Jun 29, 2022. It is now read-only.

Commit

Permalink
aws: Add test for taints and labels
Browse files Browse the repository at this point in the history
This checks whether taints are labels get applied succesfully after
cluster creation.

Signed-off-by: knrt10 <kautilya@kinvolk.io>
  • Loading branch information
knrt10 committed Aug 24, 2020
1 parent 9b0ed9b commit 874099f
Show file tree
Hide file tree
Showing 4 changed files with 84 additions and 2 deletions.
28 changes: 28 additions & 0 deletions ci/aws/aws-cluster.lokocfg.envsubst
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,34 @@ EOF
]
}

worker_pool "$CLUSTER_ID-wp-2" {
count = 1
ssh_pubkeys = ["$PUB_KEY"]
disk_size = 30
instance_type = "t2.small"
spot_price = "0.01"
labels = "testing.io=yes,roleofnode=testing"
taints = "nodeType=storage:NoSchedule"
tags = {
"deployment" = "ci"
}
clc_snippets = [
<<EOF
storage:
files:
- path: /opt/clc_snippet_hello
filesystem: root
contents:
inline: Hello, world!
mode: 0644
user:
id: 500
group:
id: 500
EOF
]
}

# Adds oidc flags to API server with default values.
# Acts as a smoke test to check if API server is functional after addition
# of extra flags.
Expand Down
2 changes: 1 addition & 1 deletion test/components/kubernetes/kubelet_disruptive_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
// See the License for the specific language governing permissions and
// limitations under the License.

// +build packet baremetal
// +build packet baremetal aws
// +build disruptivee2e

package kubernetes
Expand Down
2 changes: 1 addition & 1 deletion test/components/kubernetes/kubelet_labels_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
// See the License for the specific language governing permissions and
// limitations under the License.

// +build packet baremetal
// +build packet baremetal aws
// +build e2e

package kubernetes //nolint:testpackage
Expand Down
54 changes: 54 additions & 0 deletions test/components/kubernetes/kubelet_taint_test.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
// Copyright 2020 The Lokomotive Authors
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.

// +build aws
// +build e2e

package kubernetes_test

import (
"context"
"testing"

metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"

testutil "github.com/kinvolk/lokomotive/test/components/util"
)

func TestNodeHasTaints(t *testing.T) {
client := testutil.CreateKubeClient(t)

nodes, err := client.CoreV1().Nodes().List(context.TODO(), metav1.ListOptions{
LabelSelector: "testing.io=yes,roleofnode=testing",
})
if err != nil {
t.Errorf("could not list nodes: %v", err)
}

if len(nodes.Items) == 0 {
t.Fatalf("no worker nodes found")
}

for _, items := range nodes.Items {
for _, taint := range items.Spec.Taints {
taintKey := taint.Key
taintValue := taint.Value
taintEffect := taint.Effect

if taintKey != "nodeType" || taintValue != "storage" || taintEffect != "NoSchedule" {
t.Fatalf("expected taint: %s, got: %s=%s:%s", "nodeType=storage:NoSchedule", taintKey, taintValue, taintEffect)
}
}
}
}

0 comments on commit 874099f

Please sign in to comment.