Skip to content

Commit 56be995

Browse files
Migrate community e2e tests (#4)
* Migrate community e2e tests * Clean workflow and update acktest
1 parent 02752b6 commit 56be995

15 files changed

+652
-4
lines changed

.github/workflows/e2e-test.yaml

Lines changed: 67 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,67 @@
1+
name: e2e-test
2+
on:
3+
# Allow manual trigger of e2e tests
4+
workflow_dispatch:
5+
inputs:
6+
communityRepo:
7+
description: 'Git repository for checking out the community repo'
8+
required: false
9+
default: 'aws-controllers-k8s/community'
10+
communityRef:
11+
description: 'Git ref for checking out the community repo. Default is main'
12+
required: false
13+
default: ''
14+
testInfraRepo:
15+
description: 'Git repository for checking out the test-infra repo'
16+
required: false
17+
default: 'aws-controllers-k8s/test-infra'
18+
testInfraRef:
19+
description: 'Git ref for checking out the test-infra repo. Default is main'
20+
required: false
21+
default: ''
22+
23+
jobs:
24+
e2e-test:
25+
name: controller e2e test
26+
strategy:
27+
fail-fast: false
28+
matrix:
29+
service:
30+
- rds
31+
runs-on: [aws-controllers-k8s]
32+
steps:
33+
- name: Set up Go 1.15
34+
uses: actions/setup-go@v2
35+
with:
36+
go-version: ^1.15
37+
id: go
38+
39+
- name: checkout service
40+
uses: actions/checkout@v2
41+
with:
42+
path: './src/github.com/aws-controllers-k8s/${{ matrix.service }}-controller'
43+
44+
- name: checkout community
45+
uses: actions/checkout@v2
46+
with:
47+
repository: ${{ github.event.inputs.communityRepo }}
48+
ref: ${{ github.event.inputs.communityRef }}
49+
path: './src/github.com/aws-controllers-k8s/community'
50+
51+
- name: checkout test-infra
52+
uses: actions/checkout@v2
53+
with:
54+
repository: ${{ github.event.inputs.testInfraRepo }}
55+
ref: ${{ github.event.inputs.testInfraRef }}
56+
path: './src/github.com/aws-controllers-k8s/test-infra'
57+
58+
- name: execute e2e tests
59+
working-directory: './src/github.com/aws-controllers-k8s/community'
60+
run: |
61+
export AWS_ROLE_ARN=$(aws ssm get-parameter --name ACK_ROLE_ARN --query "Parameter.Value" --output text)
62+
export AWS_ROLE_ARN_ALT=$(aws ssm get-parameter --name ACK_ROLE_ARN_ALT --query "Parameter.Value" --output text)
63+
./scripts/kind-build-test.sh $SERVICE
64+
env:
65+
SERVICE: ${{ matrix.service }}
66+
GOPATH: ${{ github.workspace }}
67+
PRESERVE: 'false'
Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,24 +1,25 @@
1-
name: unit-tests
1+
name: unit-test
22
on:
3+
# Allow manual trigger
4+
workflow_dispatch:
35
pull_request:
46
branches:
57
- main
68
paths:
79
- '**.go'
810
- Makefile
9-
- '**.tpl'
1011
- go.mod
1112
- go.sum
1213

1314
jobs:
14-
unit-tests:
15+
build:
1516
name: make test
1617
runs-on: ubuntu-latest
1718
steps:
1819
- name: checkout code
1920
uses: actions/checkout@v2
2021
- uses: actions/setup-go@v2
2122
with:
22-
go-version: '1.14'
23+
go-version: '1.15'
2324
- name: make test
2425
run: make test

test/e2e/.gitignore

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
__pycache__/
2+
*.py[cod]
3+
**/bootstrap.yaml

test/e2e/__init__.py

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
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+
import pytest
15+
from typing import Dict, Any
16+
from pathlib import Path
17+
18+
from acktest.resources import load_resource_file
19+
20+
SERVICE_NAME = "rds"
21+
CRD_GROUP = "rds.services.k8s.aws"
22+
CRD_VERSION = "v1alpha1"
23+
24+
# PyTest marker for the current service
25+
service_marker = pytest.mark.service(arg=SERVICE_NAME)
26+
27+
bootstrap_directory = Path(__file__).parent
28+
resource_directory = Path(__file__).parent / "resources"
29+
def load_rds_resource(resource_name: str, additional_replacements: Dict[str, Any] = {}):
30+
""" Overrides the default `load_resource_file` to access the specific resources
31+
directory for the current service.
32+
"""
33+
return load_resource_file(resource_directory, resource_name, additional_replacements=additional_replacements)

test/e2e/bootstrap_resources.py

Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
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+
"""Declares the structure of the bootstrapped resources and provides a loader
15+
for them.
16+
"""
17+
18+
from dataclasses import dataclass
19+
from acktest.resources import read_bootstrap_config
20+
from e2e import bootstrap_directory
21+
22+
VPC_CIDR = "10.0.81.0/27"
23+
SUBNET_AZ1_CIDR = "10.0.81.0/28"
24+
SUBNET_AZ2_CIDR = "10.0.81.16/28"
25+
26+
@dataclass
27+
class TestBootstrapResources:
28+
VPCID: str
29+
SubnetAZ1: str
30+
SubnetAZ2: str
31+
32+
_bootstrap_resources = None
33+
34+
def get_bootstrap_resources(bootstrap_file_name: str = "bootstrap.yaml"):
35+
global _bootstrap_resources
36+
if _bootstrap_resources is None:
37+
_bootstrap_resources = TestBootstrapResources(
38+
**read_bootstrap_config(bootstrap_directory, bootstrap_file_name=bootstrap_file_name),
39+
)
40+
return _bootstrap_resources

test/e2e/conftest.py

Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,46 @@
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+
import os
15+
import pytest
16+
17+
from acktest import k8s
18+
19+
20+
def pytest_addoption(parser):
21+
parser.addoption("--runslow", action="store_true", default=False, help="run slow tests")
22+
23+
24+
def pytest_configure(config):
25+
config.addinivalue_line(
26+
"markers", "canary: mark test to also run in canary tests"
27+
)
28+
config.addinivalue_line(
29+
"markers", "service(arg): mark test associated with a given service"
30+
)
31+
config.addinivalue_line(
32+
"markers", "slow: mark test as slow to run"
33+
)
34+
35+
def pytest_collection_modifyitems(config, items):
36+
if config.getoption("--runslow"):
37+
return
38+
skip_slow = pytest.mark.skip(reason="need --runslow option to run")
39+
for item in items:
40+
if "slow" in item.keywords:
41+
item.add_marker(skip_slow)
42+
43+
# Provide a k8s client to interact with the integration test cluster
44+
@pytest.fixture(scope='class')
45+
def k8s_client():
46+
return k8s._get_k8s_api_client()

test/e2e/replacement_values.py

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
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+
"""Stores the values used by each of the integration tests for replacing the
14+
RDS-specific test variables.
15+
"""
16+
17+
REPLACEMENT_VALUES = {
18+
}

test/e2e/requirements.txt

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
acktest @ git+https://github.com/aws-controllers-k8s/test-infra.git@6c6d9dd4759c7bb2feecd11dc03e8516371812cc
2+
apipkg==1.5
3+
attrs==20.3.0
4+
boto3==1.16.40
5+
botocore==1.19.63
6+
cachetools==4.2.1
7+
certifi==2020.12.5
8+
chardet==4.0.0
9+
execnet==1.8.0
10+
google-auth==1.28.0
11+
idna==2.10
12+
iniconfig==1.1.1
13+
jmespath==0.10.0
14+
kubernetes==12.0.1
15+
oauthlib==3.1.0
16+
packaging==20.9
17+
pluggy==0.13.1
18+
py==1.10.0
19+
pyasn1==0.4.8
20+
pyasn1-modules==0.2.8
21+
pyparsing==2.4.7
22+
pytest==6.2.3
23+
pytest-forked==1.3.0
24+
pytest-xdist==2.2.0
25+
python-dateutil==2.8.1
26+
PyYAML==5.3.1
27+
requests==2.25.1
28+
requests-oauthlib==1.3.0
29+
rsa==4.7.2
30+
s3transfer==0.3.6
31+
six==1.15.0
32+
toml==0.10.2
33+
urllib3==1.26.4
34+
websocket-client==0.58.0
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
apiVersion: rds.services.k8s.aws/v1alpha1
2+
kind: DBSecurityGroup
3+
metadata:
4+
name: $DB_SECURITY_GROUP_NAME
5+
spec:
6+
name: $DB_SECURITY_GROUP_NAME
7+
description: $DB_SECURITY_GROUP_DESC
8+
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
apiVersion: rds.services.k8s.aws/v1alpha1
2+
kind: DBSubnetGroup
3+
metadata:
4+
name: $DB_SUBNET_GROUP_NAME
5+
spec:
6+
name: $DB_SUBNET_GROUP_NAME
7+
description: $DB_SUBNET_GROUP_DESC
8+
subnetIDs:
9+
- $SUBNET_AZ1
10+
- $SUBNET_AZ2
11+
tags:
12+
- key: key1
13+
value: value1

0 commit comments

Comments
 (0)