Skip to content

Commit

Permalink
test: update kubecost tests
Browse files Browse the repository at this point in the history
Signed-off-by: Tarun Gupta Akirala <[email protected]>
  • Loading branch information
takirala committed Jan 6, 2025
1 parent 642ecca commit 26e7210
Show file tree
Hide file tree
Showing 3 changed files with 33 additions and 10 deletions.
33 changes: 25 additions & 8 deletions apptests/appscenarios/kubecost.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ package appscenarios

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

"github.com/mesosphere/kommander-applications/apptests/constants"
Expand Down Expand Up @@ -68,14 +69,30 @@ func (r kubeCost) install(ctx context.Context, env *environment.Env, appPath str
return err
}

// apply the kustomization for the helmrelease
releasePath := filepath.Join(appPath, "/")
err = env.ApplyKustomizations(ctx, releasePath, map[string]string{
"releaseNamespace": kommanderNamespace,
})
if err != nil {
return err
// Kubecost has been restructured in 2.14.x. For upgrades to work, we need to handle both versions gracefully.
helmReleasePath := filepath.Join(appPath, "/release")
if _, err = os.Stat(helmReleasePath); err == nil {
// apply the kustomization for the prereqs
prereqs := filepath.Join(appPath, "/pre-install")
err = env.ApplyKustomizations(ctx, prereqs, map[string]string{
"releaseNamespace": kommanderNamespace,
})
if err != nil {
return err
}

// apply the kustomization for the helmrelease
err = env.ApplyKustomizations(ctx, helmReleasePath, map[string]string{
"releaseNamespace": kommanderNamespace,
})
if err != nil {
return err
}
return nil
}

return err
// apply the helmrelease which is at the "/" path up to 2.13.x
return env.ApplyKustomizations(ctx, filepath.Join(appPath, "/"), map[string]string{
"releaseNamespace": kommanderNamespace,
})
}
9 changes: 7 additions & 2 deletions apptests/appscenarios/kubecost_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -91,11 +91,16 @@ var _ = Describe("Kubecost Tests", Label("kubecost"), func() {
deploymentList = &appsv1.DeploymentList{}
err = k8sClient.List(ctx, deploymentList, listOptions)
Expect(err).To(BeNil())
Expect(deploymentList.Items).To(HaveLen(4))
Expect(deploymentList.Items).To(HaveLen(4), "Expected 4 deployments to be created - cost-analyzer, grafana, prometheus server and prometheus alertmanager")
Expect(err).To(BeNil())

for _, deployment := range deploymentList.Items {
Expect(deployment.Spec.Template.Spec.PriorityClassName).To(Equal(dkpHighPriority))
Expect(deployment.Spec.Template.Spec.PriorityClassName).To(
Equal(dkpHighPriority),
"Deployment %q had an unexpected PriorityClass %q",
deployment.Name,
deployment.Spec.Template.Spec.PriorityClassName,
)
}
})

Expand Down
1 change: 1 addition & 0 deletions hack/list-images.sh
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,7 @@ declare -rx releaseNamespace=unused \
tfaName=unused \
notPopulatedAnywhereAsThisIsOnlyForAirgappedBundle=unused \
caIssuerName=unused \
CLUSTER_ID=unused \
kommanderChartVersion="${kommanderChartVersion:-}"

IMAGES_FILE="$(realpath "$(mktemp .helm-list-images-XXXXXX)")"
Expand Down

0 comments on commit 26e7210

Please sign in to comment.