Skip to content

Commit

Permalink
Test: Add explicit tolerations in test setup since snapshot releases …
Browse files Browse the repository at this point in the history
…do not use latest yaml (yet)
  • Loading branch information
ellistarn committed Jul 25, 2022
1 parent 4d97adf commit f73cf83
Show file tree
Hide file tree
Showing 8 changed files with 21 additions and 15 deletions.
2 changes: 1 addition & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ battletest: ## Run randomized, racing, code coveraged, tests
-tags random_test_delay

e2etests: ## Run the e2e suite against your local cluster
go test -p 1 -timeout 60m -v ./test/suites/... -run=${TEST_FILTER}
go test -p 1 -timeout 60m -v ./test/suites/... -run=${TEST_FILTER} -cluster-name ${CLUSTER_NAME}

benchmark:
go test -tags=test_performance -run=NoTests -bench=. ./...
Expand Down
12 changes: 5 additions & 7 deletions test/pkg/environment/environment.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ import (
clientgoscheme "k8s.io/client-go/kubernetes/scheme"
"k8s.io/client-go/rest"
loggingtesting "knative.dev/pkg/logging/testing"
"knative.dev/pkg/ptr"
controllerruntime "sigs.k8s.io/controller-runtime"
"sigs.k8s.io/controller-runtime/pkg/client"

Expand All @@ -25,7 +26,7 @@ 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")
var clusterNameFlag = flag.String("cluster-name", env.WithDefaultString("CLUSTER_NAME", ""), "Cluster name enables discovery of the testing environment")

type Environment struct {
context.Context
Expand Down Expand Up @@ -63,13 +64,10 @@ func NewEnvironment(t *testing.T) (*Environment, error) {
}

func DiscoverClusterName(config *rest.Config) (string, error) {
if clusterNameFlag != "" {
return clusterNameFlag, nil
if ptr.StringValue(clusterNameFlag) != "" {
return ptr.StringValue(clusterNameFlag), nil
}
if len(config.ExecProvider.Args) > 5 {
return config.ExecProvider.Args[5], nil
}
return "", fmt.Errorf("-cluster-name is not set and could not be discovered")
return "", fmt.Errorf("-cluster-name is not set")
}

func NewConfig() *rest.Config {
Expand Down
2 changes: 0 additions & 2 deletions test/pkg/environment/expectations.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@ package environment

import (
"bytes"
"context"
"fmt"
"io"
"strings"
Expand Down Expand Up @@ -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) {
Expand Down
3 changes: 1 addition & 2 deletions test/suites/common/run-test.yaml
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@

apiVersion: tekton.dev/v1beta1
kind: Task
metadata:
Expand Down Expand Up @@ -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
2 changes: 2 additions & 0 deletions test/suites/common/setup.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -96,6 +96,8 @@ spec:
helm upgrade --install --kubeconfig /root/.kube/config --namespace karpenter --create-namespace \
karpenter karpenter/karpenter \
--version v0-$(git rev-parse HEAD) \
--set tolerations[0].key="CriticalAddonsOnly" \
--set tolerations[0].operator="Exists" \
--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) \
--set clusterEndpoint=$(cat /root/.kube/config | grep server | awk '{print $2}') \
Expand Down
6 changes: 5 additions & 1 deletion test/suites/integration/launchtemplates_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -26,13 +26,15 @@ var _ = Describe("LaunchTemplates", func() {
})

It("should use the AMI defined by the AMI Selector", func() {
Skip("Disabled until v0.14.0 is released")

provider := test.AWSNodeTemplate(v1alpha1.AWSNodeTemplateSpec{
AWS: awsv1alpha1.AWS{
SecurityGroupSelector: map[string]string{"karpenter.sh/discovery": env.ClusterName},
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()
Expand All @@ -44,6 +46,8 @@ var _ = Describe("LaunchTemplates", func() {
ExpectInstance(pod.Spec.NodeName).To(HaveField("ImageId", HaveValue(Equal(customAMI))))
})
It("should support Custom AMIFamily with AMI Selectors", func() {
Skip("Disabled until v0.14.0 is released")

provider := test.AWSNodeTemplate(v1alpha1.AWSNodeTemplateSpec{AWS: awsv1alpha1.AWS{
SecurityGroupSelector: map[string]string{"karpenter.sh/discovery": env.ClusterName},
SubnetSelector: map[string]string{"karpenter.sh/discovery": env.ClusterName},
Expand Down
5 changes: 5 additions & 0 deletions test/tools/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -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

# Install toolchain
RUN git clone https://github.com/aws/karpenter.git /karpenter
WORKDIR /karpenter
RUN GOPRIVATE=* go mod tidy
4 changes: 2 additions & 2 deletions test/tools/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
```

0 comments on commit f73cf83

Please sign in to comment.