Skip to content

Commit

Permalink
Create aws credential in controller test, remove old test artifacts a…
Browse files Browse the repository at this point in the history
…ctions

Signed-off-by: Kyle Squizzato <[email protected]>
  • Loading branch information
squizzi committed Aug 29, 2024
1 parent 9bc115e commit 9732d36
Show file tree
Hide file tree
Showing 5 changed files with 12 additions and 11 deletions.
4 changes: 0 additions & 4 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down
6 changes: 5 additions & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -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 \
Expand Down Expand Up @@ -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.

Expand Down
5 changes: 3 additions & 2 deletions test/e2e/e2e_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down Expand Up @@ -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
Expand Down
6 changes: 3 additions & 3 deletions test/kubeclient/kubeclient.go
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand All @@ -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{})
Expand Down
2 changes: 1 addition & 1 deletion test/utils/utils.go
Original file line number Diff line number Diff line change
Expand Up @@ -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))
}
}

Expand Down

0 comments on commit 9732d36

Please sign in to comment.