Skip to content

Commit 191a020

Browse files
Tests for Cluster and FargateProfile (#2)
Partly accomplishes: aws-controllers-k8s/community#858 Description of changes: Add initial smoke tests for creating and then deleting a `Cluster` Add smoke test for creating and deleting a `FargateProfile` - using a `Cluster` as the fixture By submitting this pull request, I confirm that my contribution is made under the terms of the Apache 2.0 license.
1 parent 6d7cf6b commit 191a020

14 files changed

+277
-30
lines changed

.gitignore

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,4 +4,5 @@
44
.idea
55
/docs/site
66
bin
7-
build
7+
build
8+
.env

test/e2e/.gitignore

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
11
__pycache__/
22
*.py[cod]
3-
**/bootstrap.yaml
3+
**/bootstrap.yaml
4+
**/bootstrap.pkl

test/e2e/bootstrap_resources.py

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -16,19 +16,21 @@
1616
"""
1717

1818
from dataclasses import dataclass
19-
from acktest.resources import read_bootstrap_config
19+
from acktest.bootstrapping import Resources
20+
from acktest.bootstrapping.iam import Role
21+
from acktest.bootstrapping.vpc import VPC
2022
from e2e import bootstrap_directory
2123

2224
@dataclass
23-
class TestBootstrapResources:
24-
pass
25+
class TestBootstrapResources(Resources):
26+
ClusterVPC: VPC
27+
ClusterRole: Role
28+
FargatePodRole: Role
2529

2630
_bootstrap_resources = None
2731

28-
def get_bootstrap_resources(bootstrap_file_name: str = "bootstrap.yaml"):
32+
def get_bootstrap_resources(bootstrap_file_name: str = "bootstrap.pkl") -> TestBootstrapResources:
2933
global _bootstrap_resources
3034
if _bootstrap_resources is None:
31-
_bootstrap_resources = TestBootstrapResources(
32-
**read_bootstrap_config(bootstrap_directory, bootstrap_file_name=bootstrap_file_name),
33-
)
35+
_bootstrap_resources = TestBootstrapResources.deseralize(bootstrap_directory, bootstrap_file_name=bootstrap_file_name)
3436
return _bootstrap_resources

test/e2e/common/__init__.py

Whitespace-only changes.

test/e2e/common/types.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
CLUSTER_RESOURCE_PLURAL = 'clusters'

test/e2e/conftest.py

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@
1212
# permissions and limitations under the License.
1313

1414
import os
15+
import boto3
1516
import pytest
1617

1718
from acktest import k8s
@@ -44,3 +45,7 @@ def pytest_collection_modifyitems(config, items):
4445
@pytest.fixture(scope='class')
4546
def k8s_client():
4647
return k8s._get_k8s_api_client()
48+
49+
@pytest.fixture(scope='module')
50+
def eks_client():
51+
return boto3.client('eks')

test/e2e/replacement_values.py

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,5 +14,15 @@
1414
EKS-specific test variables.
1515
"""
1616

17+
from e2e.bootstrap_resources import get_bootstrap_resources
18+
19+
1720
REPLACEMENT_VALUES = {
18-
}
21+
"CLUSTER_ROLE": get_bootstrap_resources().ClusterRole.arn,
22+
"FARGATE_POD_ROLE": get_bootstrap_resources().FargatePodRole.arn,
23+
24+
"PUBLIC_SUBNET_1": get_bootstrap_resources().ClusterVPC.public_subnets.subnet_ids[0],
25+
"PUBLIC_SUBNET_2": get_bootstrap_resources().ClusterVPC.public_subnets.subnet_ids[1],
26+
"PRIVATE_SUBNET_1": get_bootstrap_resources().ClusterVPC.private_subnets.subnet_ids[0],
27+
"PRIVATE_SUBNET_2": get_bootstrap_resources().ClusterVPC.private_subnets.subnet_ids[1]
28+
}

test/e2e/requirements.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
acktest @ git+https://github.com/aws-controllers-k8s/test-infra.git@955d7831ee374a212250179e95a5f3b75e555fd9
1+
acktest @ git+https://github.com/aws-controllers-k8s/test-infra.git@955d7831ee374a212250179e95a5f3b75e555fd9
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
apiVersion: eks.services.k8s.aws/v1alpha1
2+
kind: Cluster
3+
metadata:
4+
name: $CLUSTER_NAME
5+
spec:
6+
name: $CLUSTER_NAME
7+
roleARN: $CLUSTER_ROLE
8+
resourcesVPCConfig:
9+
endpointPrivateAccess: true
10+
endpointPublicAccess: true
11+
subnetIDs:
12+
- "$PUBLIC_SUBNET_1"
13+
- "$PUBLIC_SUBNET_2"
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
apiVersion: eks.services.k8s.aws/v1alpha1
2+
kind: FargateProfile
3+
metadata:
4+
name: $PROFILE_NAME
5+
spec:
6+
name: $PROFILE_NAME
7+
clusterName: $CLUSTER_NAME
8+
podExecutionRoleARN: $FARGATE_POD_ROLE
9+
subnets:
10+
- "$PRIVATE_SUBNET_1"
11+
- "$PRIVATE_SUBNET_2"
12+
selectors:
13+
- namespace: default

0 commit comments

Comments
 (0)