Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add tests for pod startup times with multiple resources #1886

Merged
merged 27 commits into from
Sep 2, 2021
Merged
Show file tree
Hide file tree
Changes from 16 commits
Commits
Show all changes
27 commits
Select commit Hold shift + click to select a range
cc8215c
Add tests for pod startup times with multiple res
vepatel Aug 20, 2021
9a35a1a
Merge branch 'master' into tests/multiple-resources
vepatel Aug 20, 2021
30f780c
Merge master into tests/multiple-resources
nginx-bot Aug 21, 2021
d3094f3
Merge master into tests/multiple-resources
nginx-bot Aug 21, 2021
f6cf6d9
Merge master into tests/multiple-resources
nginx-bot Aug 21, 2021
235e9cf
Merge master into tests/multiple-resources
nginx-bot Aug 21, 2021
8ac90ac
Merge master into tests/multiple-resources
nginx-bot Aug 21, 2021
580393a
Merge master into tests/multiple-resources
nginx-bot Aug 23, 2021
5a63df2
Merge master into tests/multiple-resources
nginx-bot Aug 23, 2021
8c0ca62
Merge master into tests/multiple-resources
nginx-bot Aug 24, 2021
0e7b221
Merge master into tests/multiple-resources
nginx-bot Aug 24, 2021
aa4623f
Merge master into tests/multiple-resources
nginx-bot Aug 25, 2021
4181d6d
Merge master into tests/multiple-resources
nginx-bot Aug 25, 2021
1e0bbba
Merge master into tests/multiple-resources
nginx-bot Aug 26, 2021
d659f04
Merge master into tests/multiple-resources
nginx-bot Aug 26, 2021
ca8f675
Merge master into tests/multiple-resources
nginx-bot Aug 26, 2021
e5b00c5
Merge master into tests/multiple-resources
nginx-bot Aug 27, 2021
84f9f25
Merge master into tests/multiple-resources
nginx-bot Aug 27, 2021
4400960
Merge master into tests/multiple-resources
nginx-bot Aug 30, 2021
5aa78ff
Merge master into tests/multiple-resources
nginx-bot Aug 31, 2021
e70fbfc
Merge master into tests/multiple-resources
nginx-bot Aug 31, 2021
0d81754
Merge master into tests/multiple-resources
nginx-bot Aug 31, 2021
be8322d
Merge master into tests/multiple-resources
nginx-bot Aug 31, 2021
cc319bb
Merge master into tests/multiple-resources
nginx-bot Sep 1, 2021
33a1b46
Address PR comments
vepatel Sep 1, 2021
15acde8
move waiting logic out of common lib
vepatel Sep 1, 2021
641eabb
Merge master into tests/multiple-resources
nginx-bot Sep 1, 2021
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 19 additions & 0 deletions tests/conftest.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,8 @@
DEFAULT_SERVICE,
DEFAULT_DEPLOYMENT_TYPE,
NUM_REPLICAS,
BATCH_START,
BATCH_RESOURCES,
)
from suite.resources_utils import get_first_pod_name

Expand Down Expand Up @@ -80,6 +82,18 @@ def pytest_addoption(parser) -> None:
default="no",
help="Show IC logs in stdout on test failure",
)
parser.addoption(
"--batch-start",
action="store",
default=BATCH_START,
help="Run tests for pods restarts with multiple resources deployed (Ingress/VS): True/False",
)
parser.addoption(
"--batch-resources",
action="store",
default=BATCH_RESOURCES,
help="Number of VS/Ingress resources to deploy",
)


# import fixtures into pytest global namespace
Expand Down Expand Up @@ -110,6 +124,11 @@ def pytest_collection_modifyitems(config, items) -> None:
for item in items:
if "appprotect" in item.keywords:
item.add_marker(appprotect)
if str(config.getoption("--batch-start")) != "True":
batch_start = pytest.mark.skip(reason="Skipping pod restart test with multiple resources")
for item in items:
if "batch_start" in item.keywords:
item.add_marker(batch_start)


@pytest.hookimpl(tryfirst=True, hookwrapper=True)
Expand Down
2 changes: 1 addition & 1 deletion tests/data/appprotect/appprotect-ingress.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -3,13 +3,13 @@ kind: Ingress
metadata:
name: appprotect-ingress
annotations:
kubernetes.io/ingress.class: "nginx"
appprotect.f5.com/app-protect-policy: "test-namespace/example-policy"
appprotect.f5.com/app-protect-enable: "True"
appprotect.f5.com/app-protect-security-log-enable: "True"
appprotect.f5.com/app-protect-security-log: "test-namespace/logconf"
appprotect.f5.com/app-protect-security-log-destination: "syslog:server=<IP>:<PORT>"
spec:
ingressClassName: nginx
tls:
- hosts:
- appprotect.example.com
Expand Down
2 changes: 1 addition & 1 deletion tests/data/smoke/standard/smoke-ingress.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,9 @@ apiVersion: networking.k8s.io/v1
kind: Ingress
metadata:
annotations:
kubernetes.io/ingress.class: "nginx"
name: smoke-ingress
spec:
ingressClassName: nginx
tls:
- hosts:
- smoke.example.com
Expand Down
3 changes: 3 additions & 0 deletions tests/settings.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,9 @@
ALLOWED_SERVICE_TYPES = ["nodeport", "loadbalancer"]
DEFAULT_DEPLOYMENT_TYPE = "deployment"
ALLOWED_DEPLOYMENT_TYPES = ["deployment", "daemon-set"]
BATCH_START = "False"
vepatel marked this conversation as resolved.
Show resolved Hide resolved
# Number of Ingress/VS resources to deploy based on BATCH_START value
BATCH_RESOURCES = 1
# Time in seconds to ensure reconfiguration changes in cluster
RECONFIGURATION_DELAY = 3
NGINX_API_VERSION = 4
20 changes: 7 additions & 13 deletions tests/suite/resources_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -197,7 +197,7 @@ def create_deployment_with_name(apps_v1_api: AppsV1Api, namespace, name) -> str:
return create_deployment(apps_v1_api, namespace, dep)


def scale_deployment(v1:CoreV1Api, apps_v1_api: AppsV1Api, name, namespace, value) -> int:
def scale_deployment(v1: CoreV1Api, apps_v1_api: AppsV1Api, name, namespace, value) -> int:
"""
Scale a deployment.

Expand All @@ -220,11 +220,9 @@ def scale_deployment(v1:CoreV1Api, apps_v1_api: AppsV1Api, name, namespace, valu
print(f"All pods came up in {int(later-now)} seconds")

elif value is 0:
replica_num = (apps_v1_api.read_namespaced_deployment_scale(name, namespace)).spec.replicas
while(replica_num is not None):
replica_num = (apps_v1_api.read_namespaced_deployment_scale(name, namespace)).spec.replicas
time.sleep(1)
print("Number of replicas is not 0, retrying...")
while get_pods_amount(v1, namespace) is not 0:
vepatel marked this conversation as resolved.
Show resolved Hide resolved
print(f"Number of replicas not 0, retrying...")
wait_before_test()

else:
pytest.fail("wrong argument")
Expand Down Expand Up @@ -262,13 +260,9 @@ def wait_until_all_pods_are_ready(v1: CoreV1Api, namespace) -> None:
:return:
"""
print("Start waiting for all pods in a namespace to be ContainersReady")
counter = 0
while not are_all_pods_in_ready_state(v1, namespace) and counter < 50:
print("There are pods that are not ContainerReady. Wait for 4 sec...")
time.sleep(4)
counter = counter + 1
if counter >= 50:
raise PodNotReadyException()
while not are_all_pods_in_ready_state(v1, namespace):
vepatel marked this conversation as resolved.
Show resolved Hide resolved
print("There are pods that are not ContainersReady. Wait for 1 sec...")
time.sleep(1)
print("All pods are ContainersReady")


Expand Down
3 changes: 0 additions & 3 deletions tests/suite/test_app_protect_integration.py
Original file line number Diff line number Diff line change
Expand Up @@ -418,9 +418,6 @@ def test_ap_pod_startup(
ns = ingress_controller_prerequisites.namespace

scale_deployment(kube_apis.v1, kube_apis.apps_v1_api, "nginx-ingress", ns, 0)
while get_pods_amount(kube_apis.v1, ns) is not 0:
print(f"Number of replicas not 0, retrying...")
wait_before_test()
num = scale_deployment(kube_apis.v1, kube_apis.apps_v1_api, "nginx-ingress", ns, 1)
delete_items_from_yaml(kube_apis, src_ing_yaml, test_namespace)
delete_items_from_yaml(kube_apis, src_syslog_yaml, test_namespace)
Expand Down
Loading