Skip to content

Commit 547bf9f

Browse files
Add integration tests for Nodegroups and Addons (#13)
Description of changes: Add create/delete tests for Nodegroup and Addon types By submitting this pull request, I confirm that my contribution is made under the terms of the Apache 2.0 license.
1 parent 34da725 commit 547bf9f

File tree

9 files changed

+246
-1
lines changed

9 files changed

+246
-1
lines changed

go.local.mod

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ go 1.14
55
replace github.com/aws-controllers-k8s/runtime => ../runtime
66

77
require (
8-
github.com/aws-controllers-k8s/runtime v0.12.0
8+
github.com/aws-controllers-k8s/runtime v0.15.2
99
github.com/aws/aws-sdk-go v1.38.67
1010
github.com/go-logr/logr v0.1.0
1111
github.com/spf13/pflag v1.0.5

go.local.sum

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -66,6 +66,7 @@ github.com/evanphx/json-patch v4.2.0+incompatible/go.mod h1:50XU6AFN0ol/bzJsmQLi
6666
github.com/evanphx/json-patch v4.5.0+incompatible h1:ouOWdg56aJriqS0huScTkVXPC5IcNrDCXZ6OoTAWu7M=
6767
github.com/evanphx/json-patch v4.5.0+incompatible/go.mod h1:50XU6AFN0ol/bzJsmQLiYLvXMP4fmwYFNcr97nuDLSk=
6868
github.com/fatih/color v1.7.0/go.mod h1:Zm6kSWBoL9eyXnKyktHP6abPY2pDugNf5KwzbycvMj4=
69+
github.com/fsnotify/fsnotify v1.4.7 h1:IXs+QLmnXW2CcXuY+8Mzv/fWEsPGWxqefPtCP5CnV9I=
6970
github.com/fsnotify/fsnotify v1.4.7/go.mod h1:jwhsz4b93w/PPRr/qN1Yymfu8t87LnFCMoQvtojpjFo=
7071
github.com/ghodss/yaml v0.0.0-20150909031657-73d445a93680/go.mod h1:4dBDuWmgqj2HViK6kFavaiC9ZROes6MMH2rRYeMEF04=
7172
github.com/ghodss/yaml v1.0.0/go.mod h1:4dBDuWmgqj2HViK6kFavaiC9ZROes6MMH2rRYeMEF04=
@@ -167,13 +168,17 @@ github.com/hashicorp/golang-lru v0.5.0/go.mod h1:/m3WP610KZHVQ1SGc6re/UDhFvYD7pJ
167168
github.com/hashicorp/golang-lru v0.5.1 h1:0hERBMJE1eitiLkihrMvRVBYAkpHzc/J3QdDN+dAcgU=
168169
github.com/hashicorp/golang-lru v0.5.1/go.mod h1:/m3WP610KZHVQ1SGc6re/UDhFvYD7pJ4Ao+sR/qLZy8=
169170
github.com/hashicorp/hcl v1.0.0/go.mod h1:E5yfLk+7swimpb2L/Alb/PJmXilQ/rhwaUYs4T20WEQ=
171+
github.com/hpcloud/tail v1.0.0 h1:nfCOvKYfkgYP8hkirhJocXT2+zOD8yUNjXaWfTlyFKI=
170172
github.com/hpcloud/tail v1.0.0/go.mod h1:ab1qPbhIpdTxEkNHXyeSf5vhxWSCs/tWer42PpOxQnU=
171173
github.com/imdario/mergo v0.3.5/go.mod h1:2EnlNZ0deacrJVfApfmtdGgDfMuh/nq6Ok1EcJh5FfA=
172174
github.com/imdario/mergo v0.3.6 h1:xTNEAn+kxVO7dTZGu0CegyqKZmoWFI0rF8UxjlB2d28=
173175
github.com/imdario/mergo v0.3.6/go.mod h1:2EnlNZ0deacrJVfApfmtdGgDfMuh/nq6Ok1EcJh5FfA=
174176
github.com/inconshreveable/mousetrap v1.0.0/go.mod h1:PxqpIevigyE2G7u3NXJIT2ANytuPF1OarO4DADm73n8=
177+
github.com/jaypipes/envutil v1.0.0 h1:u6Vwy9HwruFihoZrL0bxDLCa/YNadGVwKyPElNmZWow=
178+
github.com/jaypipes/envutil v1.0.0/go.mod h1:vgIRDly+xgBq0eeZRcflOHMMobMwgC6MkMbxo/Nw65M=
175179
github.com/jmespath/go-jmespath v0.4.0 h1:BEgLn5cpjn8UN1mAw4NjwDrS35OdebyEtFe+9YPoQUg=
176180
github.com/jmespath/go-jmespath v0.4.0/go.mod h1:T8mJZnbsbmF+m6zOOFylbeCJqk5+pHWvzYPziyZiYoo=
181+
github.com/jmespath/go-jmespath/internal/testify v1.5.1 h1:shLQSRRSCCPj3f2gpwzGwWFoC7ycTf1rcQZHOlsJ6N8=
177182
github.com/jmespath/go-jmespath/internal/testify v1.5.1/go.mod h1:L3OGu8Wl2/fWfCI6z80xFu9LTZmf1ZRjMHUOPmWr69U=
178183
github.com/jonboulle/clockwork v0.1.0/go.mod h1:Ii8DK3G1RaLaWxj9trq07+26W01tbo22gdxWY5EU2bo=
179184
github.com/json-iterator/go v1.1.6/go.mod h1:+SdeFBvtyEkXs7REEP0seUULqWtbJapLOCVDaaPEHmU=
@@ -187,9 +192,11 @@ github.com/kisielk/errcheck v1.2.0/go.mod h1:/BMXB+zMLi60iA8Vv6Ksmxu/1UDYcXs4uQL
187192
github.com/kisielk/gotool v1.0.0/go.mod h1:XhKaO+MFFWcvkIS/tQcRk01m1F5IRFswLeQ+oQHNcck=
188193
github.com/konsorten/go-windows-terminal-sequences v1.0.1/go.mod h1:T0+1ngSBFLxvqU3pZ+m/2kptfBszLMUkC4ZK/EgS/cQ=
189194
github.com/kr/logfmt v0.0.0-20140226030751-b84e30acd515/go.mod h1:+0opPa2QZZtGFBFZlji/RkVcI2GknAs/DXo4wKdlNEc=
195+
github.com/kr/pretty v0.1.0 h1:L/CwN0zerZDmRFUapSPitk6f+Q3+0za1rQkzVuMiMFI=
190196
github.com/kr/pretty v0.1.0/go.mod h1:dAy3ld7l9f0ibDNOQOHHMYYIIbhfbHSm3C4ZsoJORNo=
191197
github.com/kr/pty v1.1.1/go.mod h1:pFQYn66WHrOpPYNljwOMqo10TkYh1fy3cYio2l3bCsQ=
192198
github.com/kr/pty v1.1.5/go.mod h1:9r2w37qlBe7rQ6e1fg1S/9xpWHSnaqNdHD3WcMdbPDA=
199+
github.com/kr/text v0.1.0 h1:45sCR5RtlFHMR4UwH9sdQ5TC8v0qDQCHnXt+kaKSTVE=
193200
github.com/kr/text v0.1.0/go.mod h1:4Jbv+DJW3UT/LiOwJeYQe1efqtUx/iVham/4vfdArNI=
194201
github.com/magiconair/properties v1.8.0/go.mod h1:PppfXfuXeibc/6YijjN8zIbojt8czPbwD3XqdrwzmxQ=
195202
github.com/mailru/easyjson v0.0.0-20160728113105-d5b7844b561a/go.mod h1:C1wdFJiN94OJF2b5HbByQZoLdCWB1Yqtg26g4irojpc=
@@ -218,9 +225,11 @@ github.com/mxk/go-flowrate v0.0.0-20140419014527-cca7078d478f/go.mod h1:ZdcZmHo+
218225
github.com/olekukonko/tablewriter v0.0.0-20170122224234-a0225b3f23b5/go.mod h1:vsDQFd/mU46D+Z4whnwzcISnGGzXWMclvtLoiIKAKIo=
219226
github.com/onsi/ginkgo v0.0.0-20170829012221-11459a886d9c/go.mod h1:lLunBs/Ym6LB5Z9jYTR76FiuTmxDTDusOGeTQH+WWjE=
220227
github.com/onsi/ginkgo v1.6.0/go.mod h1:lLunBs/Ym6LB5Z9jYTR76FiuTmxDTDusOGeTQH+WWjE=
228+
github.com/onsi/ginkgo v1.11.0 h1:JAKSXpt1YjtLA7YpPiqO9ss6sNXEsPfSGdwN0UHqzrw=
221229
github.com/onsi/ginkgo v1.11.0/go.mod h1:lLunBs/Ym6LB5Z9jYTR76FiuTmxDTDusOGeTQH+WWjE=
222230
github.com/onsi/gomega v0.0.0-20170829124025-dcabb60a477c/go.mod h1:C1qb7wdrVGGVU+Z6iS04AVkA3Q65CEZX59MT0QO5uiA=
223231
github.com/onsi/gomega v1.7.0/go.mod h1:ex+gbHU/CVuBBDIJjb2X0qEXbFg53c61hWP/1CpauHY=
232+
github.com/onsi/gomega v1.8.1 h1:C5Dqfs/LeauYDX0jJXIe2SWmwCbGzx9yF8C8xy3Lh34=
224233
github.com/onsi/gomega v1.8.1/go.mod h1:Ho0h+IUsWyvy1OpqCwxlQ/21gkhVunqlU8fDGcoTdcA=
225234
github.com/pborman/uuid v1.2.0/go.mod h1:X/NO0urCmaxf9VXbdlT7C2Yzkj2IKimNn4k+gtPdI/k=
226235
github.com/pelletier/go-toml v1.2.0/go.mod h1:5z9KED0ma1S8pY6P1sdut58dfprrGBbd/94hg7ilaic=
@@ -229,6 +238,7 @@ github.com/pkg/errors v0.8.0/go.mod h1:bwawxfHBFNV+L2hUp1rHADufV3IMtnDRdf1r5NINE
229238
github.com/pkg/errors v0.8.1/go.mod h1:bwawxfHBFNV+L2hUp1rHADufV3IMtnDRdf1r5NINEl0=
230239
github.com/pkg/errors v0.9.1 h1:FEBLx1zS214owpjy7qsBeixbURkuhQAwrK5UwLGTwt4=
231240
github.com/pkg/errors v0.9.1/go.mod h1:bwawxfHBFNV+L2hUp1rHADufV3IMtnDRdf1r5NINEl0=
241+
github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM=
232242
github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4=
233243
github.com/pquerna/cachecontrol v0.0.0-20171018203845-0dec1b30a021/go.mod h1:prYjPmNq4d1NPVmpShWobRqXY3q7Vp+80DqgxxUrUIA=
234244
github.com/prometheus/client_golang v0.9.1/go.mod h1:7SWBe2y4D6OKWSNQJUaRYU/AaXPKyh/dDVn+NZz0KFw=
@@ -267,10 +277,12 @@ github.com/spf13/pflag v1.0.5/go.mod h1:McXfInJRrz4CZXVZOBLb0bTZqETkiAhM9Iw0y3An
267277
github.com/spf13/viper v1.3.2/go.mod h1:ZiWeW+zYFKm7srdB9IoDzzZXaJaI5eL9QjNiN/DMA2s=
268278
github.com/stretchr/objx v0.1.0/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME=
269279
github.com/stretchr/objx v0.1.1/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME=
280+
github.com/stretchr/objx v0.2.0 h1:Hbg2NidpLE8veEBkEZTL3CvlkUIVzuU9jDplZO54c48=
270281
github.com/stretchr/objx v0.2.0/go.mod h1:qt09Ya8vawLte6SNmTgCsAVtYtaKzEcn8ATUoHMkEqE=
271282
github.com/stretchr/testify v1.2.2/go.mod h1:a8OnRcib4nhh0OaRAV+Yts87kKdq0PP7pXfy6kDkUVs=
272283
github.com/stretchr/testify v1.3.0/go.mod h1:M5WIy9Dh21IEIfnGCwXGc5bZfKNJtfHm1UVUgZn+9EI=
273284
github.com/stretchr/testify v1.4.0/go.mod h1:j7eGeouHqKxXV5pUuKE4zz7dFj8WfuZ+81PSLYec5m4=
285+
github.com/stretchr/testify v1.5.1 h1:nOGnQDM7FYENwehXlg/kFVnos3rEvtKTjRvOWSzb6H4=
274286
github.com/stretchr/testify v1.5.1/go.mod h1:5W2xD1RspED5o8YsWQXVCued0rvSQ+mT+I5cxcmMvtA=
275287
github.com/tidwall/pretty v1.0.0/go.mod h1:XNkn88O1ChpSDQmQeStsy+sBenx6DDtFZJxhVysOjyk=
276288
github.com/tmc/grpc-websocket-proxy v0.0.0-20170815181823-89b8d40f7ca8/go.mod h1:ncp9v5uamzpCO7NfCPTXjqaC+bZgJeR0sMTm6dMHP7U=
@@ -377,12 +389,14 @@ golang.org/x/tools v0.0.0-20190524140312-2c0ae7006135/go.mod h1:RgjU9mgBXZiqYHBn
377389
golang.org/x/tools v0.0.0-20190614205625-5aca471b1d59/go.mod h1:/rFqwRUd4F7ZHNgwSSTFct+R/Kf4OFW1sUzUTQQTgfc=
378390
golang.org/x/tools v0.0.0-20190617190820-da514acc4774/go.mod h1:/rFqwRUd4F7ZHNgwSSTFct+R/Kf4OFW1sUzUTQQTgfc=
379391
golang.org/x/tools v0.0.0-20190920225731-5eefd052ad72/go.mod h1:b+2E5dAYhXwXZwtnZ6UAqBI28+e2cm9otk0dWdXHAEo=
392+
golang.org/x/xerrors v0.0.0-20190717185122-a985d3407aa7 h1:9zdDQZ7Thm29KFXgAX/+yaf3eVbP7djjWp/dXAppNCc=
380393
golang.org/x/xerrors v0.0.0-20190717185122-a985d3407aa7/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0=
381394
gomodules.xyz/jsonpatch/v2 v2.0.1 h1:xyiBuvkD2g5n7cYzx6u2sxQvsAy4QJsZFCzGVdzOXZ0=
382395
gomodules.xyz/jsonpatch/v2 v2.0.1/go.mod h1:IhYNNY4jnS53ZnfE4PAmpKtDpTCj1JFXc+3mwe7XcUU=
383396
google.golang.org/api v0.4.0/go.mod h1:8k5glujaEP+g9n7WNsDg8QP6cUVNI86fCNMcbazEtwE=
384397
google.golang.org/appengine v1.1.0/go.mod h1:EbEs0AVv82hx2wNQdGPgUI5lhzA/G0D9YwlJXL52JkM=
385398
google.golang.org/appengine v1.4.0/go.mod h1:xpcJRLb0r/rnEns0DIKYYv+WjYCduHsrkT7/EB5XEv4=
399+
google.golang.org/appengine v1.5.0 h1:KxkO13IPW4Lslp2bz+KHP2E3gtFlrIGNThxkZQ3g+4c=
386400
google.golang.org/appengine v1.5.0/go.mod h1:xpcJRLb0r/rnEns0DIKYYv+WjYCduHsrkT7/EB5XEv4=
387401
google.golang.org/genproto v0.0.0-20180817151627-c66870c02cf8/go.mod h1:JiN7NxoALGmiZfu7CAH4rXhgtRTLTxftemlI0sWmxmc=
388402
google.golang.org/genproto v0.0.0-20190307195333-5fe7a883aa19/go.mod h1:VzzqZJRnGkLBvHegQrXjBqPurQTc5/KpmUdxsrq26oE=
@@ -395,6 +409,7 @@ google.golang.org/grpc v1.26.0/go.mod h1:qbnxyOmOxrQa7FizSgH+ReBfzJrCY1pSN7KXBS8
395409
gopkg.in/alecthomas/kingpin.v2 v2.2.6/go.mod h1:FMv+mEhP44yOT+4EoQTLFTRgOQ1FBLkstjWtayDeSgw=
396410
gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0=
397411
gopkg.in/check.v1 v1.0.0-20180628173108-788fd7840127/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0=
412+
gopkg.in/check.v1 v1.0.0-20190902080502-41f04d3bba15 h1:YR8cESwS4TdDjEe65xsg0ogRM/Nc3DYOhEAlW+xobZo=
398413
gopkg.in/check.v1 v1.0.0-20190902080502-41f04d3bba15/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0=
399414
gopkg.in/cheggaaa/pb.v1 v1.0.25/go.mod h1:V/YB90LKu/1FcN3WVnfiiE5oMCibMjukxqG/qStrOgw=
400415
gopkg.in/fsnotify.v1 v1.4.7 h1:xOHLXZwVvI9hhs+cLKq5+I5onOuwQLhQwiu63xxlHs4=
@@ -404,6 +419,7 @@ gopkg.in/inf.v0 v0.9.1/go.mod h1:cWUDdTG/fYaXco+Dcufb5Vnc6Gp2YChqWtbxRZE0mXw=
404419
gopkg.in/natefinch/lumberjack.v2 v2.0.0/go.mod h1:l0ndWWf7gzL7RNwBG7wST/UCcT4T24xpD6X8LsfU/+k=
405420
gopkg.in/resty.v1 v1.12.0/go.mod h1:mDo4pnntr5jdWRML875a/NmxYqAlA73dVijT2AXvQQo=
406421
gopkg.in/square/go-jose.v2 v2.2.2/go.mod h1:M9dMgbHiYLoDGQrXy7OpJDJWiKiU//h+vD76mk0e1AI=
422+
gopkg.in/tomb.v1 v1.0.0-20141024135613-dd632973f1e7 h1:uRGJdciOHaEIrze2W8Q3AKkepLTh2hOroT7a+7czfdQ=
407423
gopkg.in/tomb.v1 v1.0.0-20141024135613-dd632973f1e7/go.mod h1:dt/ZhP58zS4L8KSrWDmTeBkI65Dw0HsyUHuEVlX15mw=
408424
gopkg.in/yaml.v2 v2.0.0-20170812160011-eb3733d160e7/go.mod h1:JAlM8MvJe8wmxCU4Bli9HhUf9+ttbYbLASfIpnQbh74=
409425
gopkg.in/yaml.v2 v2.2.1/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI=

test/e2e/bootstrap_resources.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@ class BootstrapResources(Resources):
2626
ClusterVPC: VPC
2727
ClusterRole: Role
2828
FargatePodRole: Role
29+
NodegroupRole: Role
2930

3031
_bootstrap_resources = None
3132

test/e2e/replacement_values.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@
2020
REPLACEMENT_VALUES = {
2121
"CLUSTER_ROLE": get_bootstrap_resources().ClusterRole.arn,
2222
"FARGATE_POD_ROLE": get_bootstrap_resources().FargatePodRole.arn,
23+
"NODEGROUP_ROLE": get_bootstrap_resources().NodegroupRole.arn,
2324

2425
"PUBLIC_SUBNET_1": get_bootstrap_resources().ClusterVPC.public_subnets.subnet_ids[0],
2526
"PUBLIC_SUBNET_2": get_bootstrap_resources().ClusterVPC.public_subnets.subnet_ids[1],

test/e2e/resources/addon_simple.yaml

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
apiVersion: eks.services.k8s.aws/v1alpha1
2+
kind: Addon
3+
metadata:
4+
name: $CR_NAME
5+
spec:
6+
name: $ADDON_NAME
7+
addonVersion: $ADDON_VERSION
8+
clusterName: $CLUSTER_NAME
Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
apiVersion: eks.services.k8s.aws/v1alpha1
2+
kind: Nodegroup
3+
metadata:
4+
name: $NODEGROUP_NAME
5+
spec:
6+
name: $NODEGROUP_NAME
7+
clusterName: $CLUSTER_NAME
8+
subnets:
9+
- "$PUBLIC_SUBNET_1"
10+
- "$PUBLIC_SUBNET_2"
11+
nodeRole: $NODEGROUP_ROLE
12+
scalingConfig:
13+
minSize: 1
14+
maxSize: 1
15+
desiredSize: 1

test/e2e/service_bootstrap.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@ def service_bootstrap() -> Resources:
2626
resources = BootstrapResources(
2727
ClusterRole=Role("cluster-role", "eks.amazonaws.com", ["arn:aws:iam::aws:policy/AmazonEKSClusterPolicy"]),
2828
FargatePodRole=Role("fargate-pod-role", "eks-fargate-pods.amazonaws.com", ["arn:aws:iam::aws:policy/AmazonEKSFargatePodExecutionRolePolicy"]),
29+
NodegroupRole=Role("nodegroup-role", "ec2.amazonaws.com", ["arn:aws:iam::aws:policy/AmazonEKSWorkerNodePolicy", "arn:aws:iam::aws:policy/AmazonEC2ContainerRegistryReadOnly"]),
2930
ClusterVPC=VPC(name_prefix="cluster-vpc", num_public_subnet=2, num_private_subnet=2)
3031
)
3132

test/e2e/tests/test_addon.py

Lines changed: 102 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,102 @@
1+
# Copyright Amazon.com Inc. or its affiliates. All Rights Reserved.
2+
#
3+
# Licensed under the Apache License, Version 2.0 (the "License"). You may
4+
# not use this file except in compliance with the License. A copy of the
5+
# License is located at
6+
#
7+
# http://aws.amazon.com/apache2.0/
8+
#
9+
# or in the "license" file accompanying this file. This file is distributed
10+
# on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
11+
# express or implied. See the License for the specific language governing
12+
# permissions and limitations under the License.
13+
14+
"""Integration tests for the EKS Addon resource
15+
"""
16+
17+
import logging
18+
import time
19+
from typing import Dict, Tuple
20+
21+
import pytest
22+
23+
from acktest.k8s import resource as k8s
24+
from acktest.resources import random_suffix_name
25+
from e2e import CRD_VERSION, service_marker, CRD_GROUP, load_eks_resource
26+
from e2e.replacement_values import REPLACEMENT_VALUES
27+
28+
from .test_cluster import simple_cluster, wait_for_cluster_active
29+
30+
RESOURCE_PLURAL = 'addons'
31+
32+
CREATE_WAIT_AFTER_SECONDS = 10
33+
34+
def wait_for_addon_deleted(eks_client, cluster_name, addon_name):
35+
waiter = eks_client.get_waiter('addon_deleted')
36+
waiter.wait(clusterName=cluster_name, addonName=addon_name)
37+
38+
@pytest.fixture
39+
def coredns_addon(eks_client, simple_cluster) -> Tuple[k8s.CustomResourceReference, Dict]:
40+
addon_name = "coredns"
41+
addon_version = "v1.8.4-eksbuild.1"
42+
43+
(ref, cr) = simple_cluster
44+
cluster_name = cr["spec"]["name"]
45+
46+
wait_for_cluster_active(eks_client, cluster_name)
47+
48+
cr_name = random_suffix_name("addon", 32)
49+
50+
replacements = REPLACEMENT_VALUES.copy()
51+
replacements["CLUSTER_NAME"] = cluster_name
52+
replacements["CR_NAME"] = cr_name
53+
replacements["ADDON_NAME"] = addon_name
54+
replacements["ADDON_VERSION"] = addon_version
55+
56+
resource_data = load_eks_resource(
57+
"addon_simple",
58+
additional_replacements=replacements,
59+
)
60+
logging.debug(resource_data)
61+
62+
# Create the k8s resource
63+
ref = k8s.CustomResourceReference(
64+
CRD_GROUP, CRD_VERSION, RESOURCE_PLURAL,
65+
cr_name, namespace="default",
66+
)
67+
k8s.create_custom_resource(ref, resource_data)
68+
cr = k8s.wait_resource_consumed_by_controller(ref)
69+
70+
assert cr is not None
71+
assert k8s.get_resource_exists(ref)
72+
73+
time.sleep(CREATE_WAIT_AFTER_SECONDS)
74+
75+
yield (ref, cr)
76+
77+
_, deleted = k8s.delete_custom_resource(ref, 3, 10)
78+
assert deleted
79+
80+
wait_for_addon_deleted(eks_client, cluster_name, cr_name)
81+
82+
@service_marker
83+
class TestAddon:
84+
def test_create_delete_addon(self, coredns_addon, eks_client):
85+
(ref, cr) = coredns_addon
86+
87+
cluster_name = cr["spec"]["clusterName"]
88+
cr_name = ref.name
89+
90+
addon_name = cr["spec"]["name"]
91+
92+
try:
93+
aws_res = eks_client.describe_addon(
94+
clusterName=cluster_name,
95+
addonName=addon_name
96+
)
97+
assert aws_res is not None
98+
99+
assert aws_res["addon"]["addonName"] == addon_name
100+
assert aws_res["addon"]["addonArn"] is not None
101+
except eks_client.exceptions.ResourceNotFoundException:
102+
pytest.fail(f"Could not find Addon '{cr_name}' in EKS")

test/e2e/tests/test_nodegroup.py

Lines changed: 101 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,101 @@
1+
# Copyright Amazon.com Inc. or its affiliates. All Rights Reserved.
2+
#
3+
# Licensed under the Apache License, Version 2.0 (the "License"). You may
4+
# not use this file except in compliance with the License. A copy of the
5+
# License is located at
6+
#
7+
# http://aws.amazon.com/apache2.0/
8+
#
9+
# or in the "license" file accompanying this file. This file is distributed
10+
# on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
11+
# express or implied. See the License for the specific language governing
12+
# permissions and limitations under the License.
13+
14+
"""Integration tests for the EKS Nodegroup resource
15+
"""
16+
17+
import logging
18+
import time
19+
from typing import Dict, Tuple
20+
21+
import pytest
22+
23+
from acktest.k8s import resource as k8s
24+
from acktest.resources import random_suffix_name
25+
from e2e import CRD_VERSION, service_marker, CRD_GROUP, load_eks_resource
26+
from e2e.replacement_values import REPLACEMENT_VALUES
27+
28+
from .test_cluster import simple_cluster, wait_for_cluster_active
29+
30+
RESOURCE_PLURAL = 'nodegroups'
31+
32+
CREATE_WAIT_AFTER_SECONDS = 10
33+
34+
def wait_for_nodegroup_active(eks_client, cluster_name, nodegroup_name):
35+
waiter = eks_client.get_waiter('nodegroup_active')
36+
waiter.wait(clusterName=cluster_name, nodegroupName=nodegroup_name)
37+
38+
def wait_for_nodegroup_deleted(eks_client, cluster_name, nodegroup_name):
39+
waiter = eks_client.get_waiter('nodegroup_deleted')
40+
waiter.wait(clusterName=cluster_name, nodegroupName=nodegroup_name)
41+
42+
@pytest.fixture
43+
def simple_nodegroup(eks_client, simple_cluster) -> Tuple[k8s.CustomResourceReference, Dict]:
44+
(ref, cr) = simple_cluster
45+
cluster_name = cr["spec"]["name"]
46+
47+
wait_for_cluster_active(eks_client, cluster_name)
48+
49+
nodegroup_name = random_suffix_name("nodegroup", 32)
50+
51+
replacements = REPLACEMENT_VALUES.copy()
52+
replacements["CLUSTER_NAME"] = cluster_name
53+
replacements["NODEGROUP_NAME"] = nodegroup_name
54+
55+
resource_data = load_eks_resource(
56+
"nodegroup_simple",
57+
additional_replacements=replacements,
58+
)
59+
logging.debug(resource_data)
60+
61+
# Create the k8s resource
62+
ref = k8s.CustomResourceReference(
63+
CRD_GROUP, CRD_VERSION, RESOURCE_PLURAL,
64+
nodegroup_name, namespace="default",
65+
)
66+
k8s.create_custom_resource(ref, resource_data)
67+
cr = k8s.wait_resource_consumed_by_controller(ref)
68+
69+
assert cr is not None
70+
assert k8s.get_resource_exists(ref)
71+
72+
time.sleep(CREATE_WAIT_AFTER_SECONDS)
73+
74+
yield (ref, cr)
75+
76+
_, deleted = k8s.delete_custom_resource(ref, 3, 10)
77+
assert deleted
78+
79+
wait_for_nodegroup_deleted(eks_client, cluster_name, nodegroup_name)
80+
81+
@service_marker
82+
class TestNodegroup:
83+
def test_create_delete_nodegroup(self, simple_nodegroup, eks_client):
84+
(ref, cr) = simple_nodegroup
85+
86+
cluster_name = cr["spec"]["clusterName"]
87+
cr_name = ref.name
88+
89+
nodegroup_name = cr["spec"]["name"]
90+
91+
try:
92+
aws_res = eks_client.describe_nodegroup(
93+
clusterName=cluster_name,
94+
nodegroupName=nodegroup_name
95+
)
96+
assert aws_res is not None
97+
98+
assert aws_res["nodegroup"]["nodegroupName"] == nodegroup_name
99+
assert aws_res["nodegroup"]["nodegroupArn"] is not None
100+
except eks_client.exceptions.ResourceNotFoundException:
101+
pytest.fail(f"Could not find Nodegroup '{cr_name}' in EKS")

0 commit comments

Comments
 (0)