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

Commit

Permalink
test/components/kubernetes: add tests that nodes has configured labels
Browse files Browse the repository at this point in the history
Now that we don't run disruptive test for self-hosted kubelet, we should
have a test, that the labels configured by the user for the worker pool
are actually applied on the node objects.

Signed-off-by: Mateusz Gozdek <mateusz@kinvolk.io>
  • Loading branch information
invidian committed May 29, 2020
1 parent e852117 commit 6a2c4a8
Show file tree
Hide file tree
Showing 2 changed files with 61 additions and 0 deletions.
20 changes: 20 additions & 0 deletions test/components/kubernetes/doc.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
// 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 aws_edge packet baremetal
// +build e2e

// Package kubernetes contains e2e tests related to core Kubernetes
// services, like kubelet etc.
package kubernetes
41 changes: 41 additions & 0 deletions test/components/kubernetes/kubelet_labels_test.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
// 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 packet baremetal
// +build e2e

package kubernetes //nolint:testpackage

import (
"testing"

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

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

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

nodes, err := client.CoreV1().Nodes().List(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")
}
}

0 comments on commit 6a2c4a8

Please sign in to comment.