Skip to content

Commit 910c044

Browse files
committed
add postgres13 standard DB param group e2e test
Adds a simple create, read, delete e2e test for a DB parameter group with PostgreSQL13 family.
1 parent 50f6f4a commit 910c044

File tree

4 files changed

+91
-2
lines changed

4 files changed

+91
-2
lines changed
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: DBParameterGroup
3+
metadata:
4+
name: $DB_PARAMETER_GROUP_NAME
5+
spec:
6+
name: $DB_PARAMETER_GROUP_NAME
7+
description: $DB_PARAMETER_GROUP_DESC
8+
family: postgres13

test/e2e/resources/db_security_group_simple.yaml

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,4 +5,3 @@ metadata:
55
spec:
66
name: $DB_SECURITY_GROUP_NAME
77
description: $DB_SECURITY_GROUP_DESC
8-
Lines changed: 83 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,83 @@
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 RDS API DBParameterGroup resource
15+
"""
16+
17+
import boto3
18+
import datetime
19+
import logging
20+
import time
21+
from typing import Dict
22+
23+
import pytest
24+
25+
from acktest.k8s import resource as k8s
26+
from e2e import service_marker, CRD_GROUP, CRD_VERSION, load_rds_resource
27+
from e2e.replacement_values import REPLACEMENT_VALUES
28+
from e2e.bootstrap_resources import get_bootstrap_resources
29+
30+
RESOURCE_PLURAL = 'dbparametergroups'
31+
32+
DELETE_WAIT_AFTER_SECONDS = 10
33+
34+
35+
@pytest.fixture(scope="module")
36+
def rds_client():
37+
return boto3.client('rds')
38+
39+
40+
@service_marker
41+
@pytest.mark.canary
42+
class TestDBParameterGroup:
43+
def test_create_delete_postgres13_standard(self, rds_client):
44+
resource_name = "pg13-standard"
45+
resource_desc = "Parameters for PostgreSQL 13"
46+
47+
replacements = REPLACEMENT_VALUES.copy()
48+
replacements["DB_PARAMETER_GROUP_NAME"] = resource_name
49+
replacements["DB_PARAMETER_GROUP_DESC"] = resource_desc
50+
51+
resource_data = load_rds_resource(
52+
"db_parameter_group_postgres13_standard",
53+
additional_replacements=replacements,
54+
)
55+
logging.debug(resource_data)
56+
57+
# Create the k8s resource
58+
ref = k8s.CustomResourceReference(
59+
CRD_GROUP, CRD_VERSION, RESOURCE_PLURAL,
60+
resource_name, namespace="default",
61+
)
62+
k8s.create_custom_resource(ref, resource_data)
63+
cr = k8s.wait_resource_consumed_by_controller(ref)
64+
65+
assert cr is not None
66+
assert k8s.get_resource_exists(ref)
67+
68+
# Let's check that the DB parameter group appears in RDS
69+
aws_res = rds_client.describe_db_parameter_groups(DBParameterGroupName=resource_name)
70+
assert aws_res is not None
71+
assert len(aws_res['DBParameterGroups']) == 1
72+
73+
# Delete the k8s resource on teardown of the module
74+
k8s.delete_custom_resource(ref)
75+
76+
time.sleep(DELETE_WAIT_AFTER_SECONDS)
77+
78+
# DB parameter group should no longer appear in RDS
79+
try:
80+
aws_res = rds_client.describe_db_parameter_groups(DBParameterGroupName=resource_name)
81+
assert False
82+
except rds_client.exceptions.DBParameterGroupNotFoundFault:
83+
pass

test/e2e/tests/test_db_security_group.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -83,4 +83,3 @@ def test_create_delete_simple(self, rds_client):
8383
assert False
8484
except rds_client.exceptions.DBSecurityGroupNotFoundFault:
8585
pass
86-

0 commit comments

Comments
 (0)