diff --git a/test/pkg/environment/environment.go b/test/pkg/environment/environment.go index 5a15a4a13446..1549c9f65e0b 100644 --- a/test/pkg/environment/environment.go +++ b/test/pkg/environment/environment.go @@ -2,7 +2,6 @@ package environment import ( "context" - "flag" "fmt" "testing" "time" @@ -25,8 +24,6 @@ import ( "github.com/aws/karpenter/pkg/utils/project" ) -var clusterNameFlag = *flag.String("cluster-name", env.WithDefaultString("CLUSTER_NAME", ""), "Cluster name enables discovery of the testing environment") - type Environment struct { context.Context ClusterName string @@ -63,10 +60,10 @@ func NewEnvironment(t *testing.T) (*Environment, error) { } func DiscoverClusterName(config *rest.Config) (string, error) { - if clusterNameFlag != "" { - return clusterNameFlag, nil + if clusterName := env.WithDefaultString("CLUSTER_NAME", ""); clusterName != "" { + return clusterName, nil } - if len(config.ExecProvider.Args) > 5 { + if config.ExecProvider != nil && len(config.ExecProvider.Args) > 5 { return config.ExecProvider.Args[5], nil } return "", fmt.Errorf("-cluster-name is not set and could not be discovered") diff --git a/test/pkg/environment/expectations.go b/test/pkg/environment/expectations.go index ec408edb58c7..0e4c133da25f 100644 --- a/test/pkg/environment/expectations.go +++ b/test/pkg/environment/expectations.go @@ -2,7 +2,6 @@ package environment import ( "bytes" - "context" "fmt" "io" "strings" @@ -124,7 +123,6 @@ func (env *Environment) eventuallyExpectScaleDown() { // expect the current node count to be what it was when the test started g.Expect(env.Monitor.NodeCount()).To(Equal(env.Monitor.NodeCountAtReset())) }).Should(Succeed(), fmt.Sprintf("expected scale down to %d nodes, had %d", env.Monitor.NodeCountAtReset(), env.Monitor.NodeCount())) - logging.FromContext(context.Background()).Info(env.Monitor.NodeCountAtReset()) } func (env *Environment) ExpectCreatedNodeCount(comparator string, nodeCount int) { diff --git a/test/suites/common/run-test.yaml b/test/suites/common/run-test.yaml index f8ee4816309c..2d6823152e61 100644 --- a/test/suites/common/run-test.yaml +++ b/test/suites/common/run-test.yaml @@ -1,4 +1,3 @@ - apiVersion: tekton.dev/v1beta1 kind: Task metadata: @@ -30,4 +29,4 @@ spec: workingDir: $(workspaces.ws.path) script: | aws eks update-kubeconfig --name $(params.cluster-name) - TEST_FILTER=$(params.test-filter) make e2etests + KUBECONFIG=/root/.kube/config TEST_FILTER=$(params.test-filter) make e2etests diff --git a/test/suites/common/setup.yaml b/test/suites/common/setup.yaml index a4e828745b4c..4aac85cb07f4 100644 --- a/test/suites/common/setup.yaml +++ b/test/suites/common/setup.yaml @@ -91,10 +91,8 @@ spec: workingDir: $(workspaces.ws.path) script: | aws eks update-kubeconfig --name $(params.cluster-name) - helm repo add karpenter https://charts.karpenter.sh/ - helm repo update helm upgrade --install --kubeconfig /root/.kube/config --namespace karpenter --create-namespace \ - karpenter karpenter/karpenter \ + karpenter oci://public.ecr.aws/karpenter/karpenter \ --version v0-$(git rev-parse HEAD) \ --set serviceAccount.annotations."eks\.amazonaws\.com/role-arn"="arn:aws:iam::$(cat $(results.account-id.path)):role/$(params.cluster-name)-karpenter" \ --set clusterName=$(params.cluster-name) \ diff --git a/test/suites/integration/launchtemplates_test.go b/test/suites/integration/launchtemplates_test.go index d7e64ec1d687..a29f491477ee 100644 --- a/test/suites/integration/launchtemplates_test.go +++ b/test/suites/integration/launchtemplates_test.go @@ -32,7 +32,7 @@ var _ = Describe("LaunchTemplates", func() { SubnetSelector: map[string]string{"karpenter.sh/discovery": env.ClusterName}, AMIFamily: &awsv1alpha1.AMIFamilyAL2, }, - AMISelector: map[string]string{"aws-ids": customAMI}, + AMISelector: map[string]string{"aws-ids": customAMI}, }) provisioner := test.Provisioner(test.ProvisionerOptions{ProviderRef: &v1alpha5.ProviderRef{Name: provider.Name}}) pod := test.Pod() diff --git a/test/tools/Dockerfile b/test/tools/Dockerfile index faa73938398c..d421e7743238 100644 --- a/test/tools/Dockerfile +++ b/test/tools/Dockerfile @@ -46,3 +46,8 @@ RUN aws --version # Install eksctl RUN curl --silent --location "https://github.com/weaveworks/eksctl/releases/download/v0.105.0/eksctl_$(uname -s)_amd64.tar.gz" | tar xz -C /tmp RUN mv /tmp/eksctl /usr/local/bin + +# Cache modules to speed up test execution +RUN git clone https://github.com/aws/karpenter.git /karpenter +WORKDIR /karpenter +RUN GOPROXY=direct go mod tidy diff --git a/test/tools/README.md b/test/tools/README.md index adfb33a7067b..34684bc02b07 100644 --- a/test/tools/README.md +++ b/test/tools/README.md @@ -2,6 +2,6 @@ Tools is an image that contains binaries useful for testing karpenter. ``` aws ecr-public get-login-password --region us-east-1 | docker login --username AWS --password-stdin public.ecr.aws -docker build ./test/tools -t public.ecr.aws/karpenter-testing/tools:latest -docker push public.ecr.aws/karpenter-testing/tools:latest +docker build ./test/tools --progress plain -t public.ecr.aws/karpenter-testing/tools:latest +docker push public.ecr.aws/karpenter-testing/tools:latest ```