From 9732d36408242d6b479cf5400bfa1e55dcd60f81 Mon Sep 17 00:00:00 2001 From: Kyle Squizzato Date: Thu, 29 Aug 2024 15:13:35 -0700 Subject: [PATCH] Create aws credential in controller test, remove old test artifacts actions Signed-off-by: Kyle Squizzato --- .github/workflows/test.yml | 4 ---- Makefile | 6 +++++- test/e2e/e2e_test.go | 5 +++-- test/kubeclient/kubeclient.go | 6 +++--- test/utils/utils.go | 2 +- 5 files changed, 12 insertions(+), 11 deletions(-) diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index dcb9508fa..c5e10974d 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -72,10 +72,6 @@ jobs: - name: Run E2E tests run: | make test-e2e - - name: Get test logs - run: | - kubectl logs -n hmc-system -l app=e2e-test > test/e2e/e2e-test.log - ./bin/clusterctl describe cluster --show-conditions=all > test/e2e/clusterctl.log - name: Archive test results uses: actions/upload-artifact@v4 with: diff --git a/Makefile b/Makefile index aaaff7541..ec3a166b0 100644 --- a/Makefile +++ b/Makefile @@ -244,7 +244,7 @@ dev-undeploy: ## Undeploy controller from the K8s cluster specified in ~/.kube/c .PHONY: helm-push helm-push: helm-package - if [ ! $(REGISTRY_IS_OCI) ]; then \ + @if [ ! $(REGISTRY_IS_OCI) ]; then \ repo_flag="--repo"; \ fi; \ for chart in $(CHARTS_PACKAGE_DIR)/*.tgz; do \ @@ -310,6 +310,10 @@ test-apply: kind-deploy registry-deploy dev-push dev-deploy dev-templates .PHONY: test-destroy test-destroy: kind-undeploy registry-undeploy +.PHONY: get-local-bin +get-local-bin: + $(shell pwd)/bin + .PHONY: cli-install cli-install: clusterawsadm clusterctl cloud-nuke yq ## Install the necessary CLI tools for deployment, development and testing. diff --git a/test/e2e/e2e_test.go b/test/e2e/e2e_test.go index 6f104fb51..7dd3112a7 100644 --- a/test/e2e/e2e_test.go +++ b/test/e2e/e2e_test.go @@ -59,6 +59,7 @@ var _ = Describe("controller", Ordered, func() { It("should run successfully", func() { kc, err := kubeclient.NewFromLocal(namespace) ExpectWithOffset(1, err).NotTo(HaveOccurred()) + ExpectWithOffset(1, kc.CreateAWSCredentialsKubeSecret(context.Background())).To(Succeed()) By("validating that the hmc-controller and capi provider controllers are running") verifyControllersUp := func() error { @@ -175,14 +176,14 @@ func verifyControllerUp(kc *kubeclient.KubeClient, labelSelector string, name st // Ensure the pod is not being deleted. if controllerPod.DeletionTimestamp != nil { - return fmt.Errorf("deletion timestamp should be nil, got: %v", controllerPod) + return fmt.Errorf("controller pod: %s deletion timestamp should be nil, got: %v", controllerPod.Name, controllerPod) } // Ensure the pod is running and has the expected name. if !strings.Contains(controllerPod.Name, "controller-manager") { return fmt.Errorf("controller pod name %s does not contain 'controller-manager'", controllerPod.Name) } if controllerPod.Status.Phase != "Running" { - return fmt.Errorf("controller pod in %s status", controllerPod.Status.Phase) + return fmt.Errorf("controller pod: %s in %s status", controllerPod.Name, controllerPod.Status.Phase) } return nil diff --git a/test/kubeclient/kubeclient.go b/test/kubeclient/kubeclient.go index 8c4c5d112..b9118b126 100644 --- a/test/kubeclient/kubeclient.go +++ b/test/kubeclient/kubeclient.go @@ -124,8 +124,8 @@ func new(configBytes []byte, namespace string) (*KubeClient, error) { } // CreateAWSCredentialsKubeSecret uses clusterawsadm to encode existing AWS -// credentials and create a secret named 'aws-credentials' in the given -// namespace if one does not already exist. +// credentials and create a secret in the given namespace if one does not +// already exist. func (kc *KubeClient) CreateAWSCredentialsKubeSecret(ctx context.Context) error { _, err := kc.Client.CoreV1().Secrets(kc.Namespace).Get(ctx, awsCredentialsSecretName, metav1.GetOptions{}) if !apierrors.IsNotFound(err) { @@ -144,7 +144,7 @@ func (kc *KubeClient) CreateAWSCredentialsKubeSecret(ctx context.Context) error Name: awsCredentialsSecretName, }, Data: map[string][]byte{ - "credentials": output, + "AWS_B64ENCODED_CREDENTIALS": output, }, Type: corev1.SecretTypeOpaque, }, metav1.CreateOptions{}) diff --git a/test/utils/utils.go b/test/utils/utils.go index d4cc82587..e4f561915 100644 --- a/test/utils/utils.go +++ b/test/utils/utils.go @@ -45,7 +45,7 @@ func Run(cmd *exec.Cmd) ([]byte, error) { var exitError *exec.ExitError if errors.As(err, &exitError) { - return output, fmt.Errorf("%s failed with error: (%v) %s", command, err, string(output)) + return output, fmt.Errorf("%s failed with error: (%v): %s", command, err, string(exitError.Stderr)) } }