Skip to content

Commit 05789c2

Browse files
committed
Split Python policies tests
1 parent 9636e7b commit 05789c2

12 files changed

+136
-15
lines changed

.github/data/matrix-smoke-oss.json

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -36,17 +36,24 @@
3636
"platforms": "linux/arm64, linux/amd64"
3737
},
3838
{
39-
"label": "policies 1/2",
39+
"label": "policies 1/3",
4040
"image": "alpine",
4141
"type": "oss",
4242
"marker": "'policies and not policies_rl and not policies_ac and not policies_jwt and not policies_mtls and not policies_cache'",
4343
"platforms": "linux/arm64, linux/amd64"
4444
},
4545
{
46-
"label": "policies 2/2",
46+
"label": "policies 2/3",
4747
"image": "alpine",
4848
"type": "oss",
49-
"marker": "'policies_rl or policies_ac or policies_jwt or policies_mtls or policies_cache or otel'",
49+
"marker": "'policies_rl or policies_ac or policies_jwt'",
50+
"platforms": "linux/arm64, linux/amd64"
51+
},
52+
{
53+
"label": "policies 3/3",
54+
"image": "alpine",
55+
"type": "oss",
56+
"marker": "'policies_mtls or policies_cache or otel'",
5057
"platforms": "linux/arm64, linux/amd64"
5158
},
5259
{

.github/data/matrix-smoke-plus.json

Lines changed: 40 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,26 +1,33 @@
11
{
22
"images": [
33
{
4-
"label": "VS 1/3",
4+
"label": "VS 1/4",
55
"image": "debian-plus",
66
"type": "plus",
7-
"marker": "'vs and not vs_ipv6 and not vs_rewrite and not vs_responses and not vs_grpc and not vs_redirects and not vs_externalname and not vs_externaldns and not vs_certmanager and not vs_api and not vs_backup and not vs_use_cluster_ip and not vs_canary and not vs_upstream and not vs_config_map'",
7+
"marker": "'vs and not vs_ipv6 and not vs_rewrite and not vs_responses and not vs_grpc and not vs_redirects and not vs_externalname and not vs_externaldns and not vs_certmanager and not vs_api and not vs_backup and not vs_use_cluster_ip and not vs_canary and not vs_upstream and not vs_config_map and not vs_listeners'",
88
"platforms": "linux/arm64, linux/amd64"
99
},
1010
{
11-
"label": "VS 2/3",
11+
"label": "VS 2/4",
1212
"image": "debian-plus",
1313
"type": "plus",
1414
"marker": "'vs_grpc or vs_redirects or vs_externalname or vs_externaldns or vs_api or vs_backup or vs_use_cluster_ip or vs_canary or vs_upstream or vs_config_map'",
1515
"platforms": "linux/arm64, linux/amd64"
1616
},
1717
{
18-
"label": "VS 3/3",
18+
"label": "VS 3/4",
1919
"image": "debian-plus",
2020
"type": "plus",
2121
"marker": "'vs_responses or vs_ipv6 or vs_rewrite or vs_certmanager'",
2222
"platforms": "linux/arm64, linux/amd64"
2323
},
24+
{
25+
"label": "VS 4/4",
26+
"image": "debian-plus",
27+
"type": "plus",
28+
"marker": "'vs_listeners'",
29+
"platforms": "linux/arm64, linux/amd64"
30+
},
2431
{
2532
"label": "TS",
2633
"image": "debian-plus",
@@ -29,14 +36,21 @@
2936
"platforms": "linux/arm64, linux/amd64"
3037
},
3138
{
32-
"label": "ingresses 1/2",
39+
"label": "ingresses 1/3",
40+
"image": "alpine-plus",
41+
"type": "plus",
42+
"marker": "'ingresses and not annotations and not basic_auth and not hsts and not watch_namespace and not wildcard_tls and not ingresses_smoke and not ingresses_jwt'",
43+
"platforms": "linux/arm64, linux/amd64"
44+
},
45+
{
46+
"label": "ingresses 2/3",
3347
"image": "alpine-plus",
3448
"type": "plus",
35-
"marker": "'ingresses and not annotations and not basic_auth and not hsts and not watch_namespace and not wildcard_tls'",
49+
"marker": "'ingresses_smoke or ingresses_jwt'",
3650
"platforms": "linux/arm64, linux/amd64"
3751
},
3852
{
39-
"label": "ingresses 2/2",
53+
"label": "ingresses 3/3",
4054
"image": "alpine-plus-fips",
4155
"type": "plus",
4256
"marker": "'annotations or basic_auth or hsts or watch_namespace or wildcard_tls'",
@@ -64,24 +78,38 @@
6478
"platforms": "linux/arm64, linux/amd64"
6579
},
6680
{
67-
"label": "policies 1/3",
81+
"label": "policies 1/5",
6882
"image": "ubi-9-plus",
6983
"type": "plus",
7084
"marker": "'policies and not policies_ac and not policies_jwt and not policies_mtls and not policies_rl and not policies_cache'",
7185
"platforms": "linux/arm64, linux/amd64"
7286
},
7387
{
74-
"label": "policies 2/3",
88+
"label": "policies 2/5",
89+
"image": "ubi-9-plus",
90+
"type": "plus",
91+
"marker": "'policies_ac or policies_mtls or policies_cache'",
92+
"platforms": "linux/arm64, linux/amd64"
93+
},
94+
{
95+
"label": "policies 3/5",
96+
"image": "ubi-9-plus",
97+
"type": "plus",
98+
"marker": "'policies_jwt or otel'",
99+
"platforms": "linux/arm64, linux/amd64"
100+
},
101+
{
102+
"label": "policies 4/5",
75103
"image": "ubi-9-plus",
76104
"type": "plus",
77-
"marker": "'policies_ac or policies_jwt or policies_mtls or otel'",
105+
"marker": "'policies_rl_vs'",
78106
"platforms": "linux/arm64, linux/amd64"
79107
},
80108
{
81-
"label": "policies 3/3",
109+
"label": "policies 5/5",
82110
"image": "ubi-9-plus",
83111
"type": "plus",
84-
"marker": "'policies_rl or policies_cache'",
112+
"marker": "'policies_rl_vsr'",
85113
"platforms": "linux/arm64, linux/amd64"
86114
},
87115
{

pyproject.toml

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -45,11 +45,15 @@ markers = [
4545
"dos_learning",
4646
"hsts",
4747
"ingresses",
48+
"ingresses_jwt",
49+
"ingresses_smoke",
4850
"multi_ns",
4951
"oidc",
5052
"otel",
5153
"policies",
5254
"policies_rl",
55+
"policies_rl_vs",
56+
"policies_rl_vsr",
5357
"policies_jwt",
5458
"policies_ac",
5559
"policies_mtls",
@@ -75,6 +79,7 @@ markers = [
7579
"vs_certmanager",
7680
"vs_config_map",
7781
"vs_grpc",
82+
"vs_listeners",
7883
"vs_upstream",
7984
"vs_use_cluster_ip",
8085
"vsr",

tests/scripts/longest_test_job.py

Lines changed: 71 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,71 @@
1+
#!/usr/bin/env python3
2+
3+
import argparse
4+
5+
from github import Auth, Github
6+
7+
# parse args
8+
parser = argparse.ArgumentParser()
9+
parser.add_argument("-t", "--token", required=True, help="GitHub access token")
10+
parser.add_argument("-o", "--owner", required=False, default="nginx", help="GitHub repository owner")
11+
parser.add_argument("-r", "--repo", help="GitHub repository name", required=False, default="kubernetes-ingress")
12+
parser.add_argument("-w", "--workflow", help="GitHub Actions workflow name", required=False, default="CI")
13+
parser.add_argument("-b", "--branch", help="GitHub repository branch", required=False, default="main")
14+
parser.add_argument(
15+
"-d", "--duration", help="Minimum duration of jobs in seconds", required=False, default=900, type=int
16+
)
17+
args = parser.parse_args()
18+
TOKEN = args.token
19+
OWNER = args.owner
20+
REPO = args.repo
21+
BRANCH = args.branch
22+
DURATION = args.duration
23+
WORKFLOW = args.workflow
24+
25+
26+
def get_github_repo(owner, repo, token):
27+
# Authenticate to GitHub
28+
auth = Auth.Token(token)
29+
g = Github(auth=auth)
30+
31+
# Get the repository
32+
repository = g.get_repo(f"{owner}/{repo}")
33+
g.close() # Close the connection
34+
return repository
35+
36+
37+
def get_workflow_runs(repo, workflow_name, branch=None):
38+
workflows = repo.get_workflows()
39+
for workflow in workflows:
40+
if workflow.name == workflow_name:
41+
return workflow.get_runs(branch=branch, status="completed")
42+
return None
43+
44+
45+
def get_run_branch_jobs(runs):
46+
results = {}
47+
for run in runs:
48+
results[run.id] = run.jobs()
49+
return results
50+
51+
52+
def convert_seconds(seconds):
53+
min, sec = divmod(seconds, 60)
54+
hour, min = divmod(min, 60)
55+
return "%d:%02d:%02d" % (hour, min, sec)
56+
57+
58+
r = get_github_repo(OWNER, REPO, TOKEN)
59+
60+
# Get the latest workflow runs
61+
runs = get_workflow_runs(r, WORKFLOW, branch=BRANCH)
62+
if not runs:
63+
print("No workflow runs found.")
64+
exit(1)
65+
wj = get_run_branch_jobs(runs)
66+
for run_id in sorted(wj.keys()):
67+
print(f"Workflow Run ID: {run_id}")
68+
for job in wj[run_id]:
69+
job_duration = (job.completed_at - job.started_at).total_seconds()
70+
if job.status == "completed" and job.conclusion == "success" and job_duration > DURATION:
71+
print(f" Job: {job.name}, Duration: {convert_seconds(job_duration)}, URL: {job.html_url}")

tests/suite/test_jwt_auth_mergeable.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -195,6 +195,7 @@ def get_token_from_file(token_type) -> str:
195195

196196

197197
@pytest.mark.ingresses
198+
@pytest.mark.ingresses_jwt
198199
@pytest.mark.skip_for_nginx_oss
199200
class TestJWTAuthMergeableMinions:
200201
def test_jwt_auth_response_codes_and_location(self, kube_apis, jwt_auth_setup, test_namespace):

tests/suite/test_jwt_policies_jwksuri.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -171,6 +171,7 @@ def fin():
171171

172172
@pytest.mark.skip_for_nginx_oss
173173
@pytest.mark.policies
174+
@pytest.mark.policies_jwt
174175
@pytest.mark.parametrize(
175176
"crd_ingress_controller, virtual_server_setup",
176177
[

tests/suite/test_jwt_secrets.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -93,6 +93,7 @@ def fin():
9393

9494

9595
@pytest.mark.ingresses
96+
@pytest.mark.ingresses_jwt
9697
@pytest.mark.skip_for_nginx_oss
9798
class TestJWTSecrets:
9899
def test_response_code_200_and_server_name(self, jwt_secrets_setup, jwt_secret):

tests/suite/test_policy_ingress_class.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@
1818

1919

2020
@pytest.mark.policies
21+
@pytest.mark.policies_rl
2122
@pytest.mark.parametrize(
2223
"crd_ingress_controller, virtual_server_setup",
2324
[

tests/suite/test_rl_policies.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -100,6 +100,7 @@
100100

101101
@pytest.mark.policies
102102
@pytest.mark.policies_rl
103+
@pytest.mark.policies_rl_vs
103104
@pytest.mark.parametrize(
104105
"crd_ingress_controller, virtual_server_setup",
105106
[
@@ -636,6 +637,7 @@ def test_rl_policy_jwt_claim_sub(
636637

637638
@pytest.mark.policies
638639
@pytest.mark.policies_rl
640+
@pytest.mark.policies_rl_vs
639641
@pytest.mark.parametrize(
640642
"crd_ingress_controller, virtual_server_setup",
641643
[

tests/suite/test_rl_policies_vsr.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -119,6 +119,7 @@
119119

120120
@pytest.mark.policies
121121
@pytest.mark.policies_rl
122+
@pytest.mark.policies_rl_vsr
122123
@pytest.mark.parametrize(
123124
"crd_ingress_controller, v_s_route_setup",
124125
[
@@ -683,6 +684,7 @@ def test_rl_policy_jwt_claim_sub_vsr(
683684

684685
@pytest.mark.policies
685686
@pytest.mark.policies_rl
687+
@pytest.mark.policies_rl_vsr
686688
@pytest.mark.parametrize(
687689
"crd_ingress_controller, v_s_route_setup",
688690
[

0 commit comments

Comments
 (0)