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

WIP: bare-metal: add some go tests to start to verify functionality #16896

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
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
41 changes: 41 additions & 0 deletions tests/e2e/scenarios/bare-metal/e2e_test.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
package bare_metal

import (
"context"
"os"
"path/filepath"
"testing"

metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
"k8s.io/client-go/kubernetes"
"k8s.io/client-go/tools/clientcmd"
)

func TestNodeAddresses(t *testing.T) {
ctx := context.Background()

kubeconfig := os.Getenv("KUBECONFIG")
if kubeconfig == "" {
homeDir, err := os.UserHomeDir()
if err != nil {
t.Fatalf("error getting user home dir: %v", err)
}
kubeconfig = filepath.Join(homeDir, ".kube", "config")
}
// use the current context in kubeconfig
restConfig, err := clientcmd.BuildConfigFromFlags("", kubeconfig)
if err != nil {
t.Fatalf("error building rest config: %v", err)
}

client := kubernetes.NewForConfigOrDie(restConfig)

nodes, err := client.CoreV1().Nodes().List(ctx, metav1.ListOptions{})
if err != nil {
t.Fatalf("error listing nodes: %v", err)
}

for _, node := range nodes.Items {
t.Logf("node: %s", node.Name)
}
}
5 changes: 5 additions & 0 deletions tests/e2e/scenarios/bare-metal/run-test
Original file line number Diff line number Diff line change
Expand Up @@ -213,7 +213,12 @@ echo "Waiting 30 seconds for nodes to be ready"
sleep 30

kubectl get nodes
kubectl get nodes -o yaml

kubectl get pods -A

echo "running e2e tests"
cd ${REPO_ROOT}/tests/e2e/scenarios/bare-metal
go test -v .

echo "Test successful"
Loading