-
Notifications
You must be signed in to change notification settings - Fork 2.7k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
5 changed files
with
1,834 additions
and
0 deletions.
There are no files selected for viewing
Empty file.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,293 @@ | ||
# Copyright 2023 The Kubernetes Authors. | ||
# | ||
# Licensed under the Apache License, Version 2.0 (the "License"); | ||
# you may not use this file except in compliance with the License. | ||
# You may obtain a copy of the License at | ||
# | ||
# http://www.apache.org/licenses/LICENSE-2.0 | ||
# | ||
# Unless required by applicable law or agreed to in writing, software | ||
# distributed under the License is distributed on an "AS IS" BASIS, | ||
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
# See the License for the specific language governing permissions and | ||
# limitations under the License. | ||
|
||
import math | ||
import json | ||
import yaml | ||
import re | ||
import jinja2 # pylint: disable=import-error | ||
|
||
|
||
from helpers import ( # pylint: disable=import-error, no-name-in-module | ||
build_cron, | ||
) | ||
|
||
# These are job tab names of unsupported grid combinations | ||
skip_jobs = [] | ||
|
||
image = "gcr.io/k8s-staging-test-infra/kubekins-e2e:v20230616-e730b60769-master" | ||
|
||
loader = jinja2.FileSystemLoader(searchpath="./templates") | ||
|
||
############## | ||
# Build Test # | ||
############## | ||
|
||
|
||
# Returns a string representing the periodic prow job and the number of job invocations per week | ||
def build_test( | ||
cloud="aws", | ||
distro="u2204", | ||
cri="containerd", | ||
name_override=None, | ||
feature_flags=(), | ||
extra_dashboards=None, | ||
test_parallelism=25, | ||
test_timeout_minutes=60, | ||
skip_regex="", | ||
arch="", | ||
test_type="node-e2e", | ||
scenario_name=None, | ||
focus_regex=None, | ||
runs_per_day=0, | ||
scenario=None, | ||
env=None, | ||
): | ||
# pylint: disable=too-many-statements,too-many-branches,too-many-arguments | ||
validation_wait = "20m" if distro in ("flatcar", "flatcararm64") else None | ||
|
||
suffix = "" | ||
if cri: | ||
suffix += cri | ||
if cloud: | ||
suffix += "-" + cloud | ||
if distro: | ||
suffix += "-" + distro | ||
|
||
tab = name_override or (f"{scenario_name}-{suffix}") | ||
job_name = f"ci-kubernetes-{tab}" | ||
|
||
if tab in skip_jobs: | ||
return None | ||
|
||
cron, runs_per_week = build_cron(tab, runs_per_day) | ||
|
||
# Scenario-specific parameters | ||
if env is None: | ||
env = {} | ||
|
||
tmpl_file = "periodic.yaml.jinja" | ||
if skip_regex is not None: | ||
env["SKIP"] = skip_regex | ||
if focus_regex is not None: | ||
env["FOCUS"] = focus_regex | ||
|
||
# arm64 config | ||
if arch == "arm64": | ||
env["USE_DOCKERIZED_BUILD"] = "true" | ||
env["TARGET_BUILD_ARCH"] = "linux/arm64" | ||
|
||
tmpl = jinja2.Environment(loader=loader).get_template(tmpl_file) | ||
job = tmpl.render( | ||
job_name=job_name, | ||
cloud=cloud, | ||
cron=cron, | ||
test_parallelism=str(test_parallelism), | ||
job_timeout=str(test_timeout_minutes + 30) + "m", | ||
test_timeout=str(test_timeout_minutes) + "m", | ||
skip_regex=skip_regex, | ||
kops_feature_flags=",".join(feature_flags), | ||
terraform_version="", # DEL | ||
focus_regex=focus_regex, | ||
validation_wait=validation_wait, | ||
image=image, | ||
scenario=scenario, | ||
env=env, | ||
) | ||
|
||
spec = { | ||
"cloud": cloud, | ||
"distro": distro, | ||
"cri": cri, | ||
"scenario": scenario_name, | ||
} | ||
jsonspec = json.dumps(spec, sort_keys=True) | ||
|
||
dashboards = [ | ||
f"sig-node-{cri}", | ||
f"sig-node-{distro.removesuffix('-arm64')}", | ||
] | ||
if cloud == "aws": | ||
dashboards.extend(["sig-node-aws"]) | ||
if cloud == "gce": | ||
dashboards.extend(["sig-node-gce"]) | ||
|
||
if extra_dashboards: | ||
dashboards.extend(extra_dashboards) | ||
|
||
days_of_results = 90 | ||
if runs_per_week * days_of_results > 2000: | ||
# testgrid has a limit on number of test runs to show for a job | ||
days_of_results = math.floor(2000 / runs_per_week) | ||
annotations = { | ||
"testgrid-dashboards": ", ".join(sorted(dashboards)), | ||
"testgrid-days-of-results": str(days_of_results), | ||
"testgrid-tab-name": tab, | ||
} | ||
for k, v in spec.items(): | ||
annotations[f"node.k8s.io/{k}"] = v or "" | ||
|
||
extra = yaml.dump( | ||
{"annotations": annotations}, width=9999, default_flow_style=False | ||
) | ||
|
||
output = f"\n# {jsonspec}\n{job.strip()}\n" | ||
for line in extra.splitlines(): | ||
output += f" {line}\n" | ||
return output, runs_per_week | ||
|
||
#################### | ||
# Grid Definitions # | ||
#################### | ||
clouds = [ | ||
"aws", | ||
"gce", | ||
] | ||
|
||
cri_options = [ | ||
"containerd", | ||
# 'cri-o', | ||
] | ||
|
||
gce_distro_options = [ | ||
"cos", | ||
# "ubuntu2204-gke", | ||
# "ubuntu2204-gke-arm64", | ||
] | ||
|
||
aws_distro_options = [ | ||
"amazonlinux2", | ||
"al2023", | ||
"al2023-arm64", | ||
"ubuntu2204", | ||
"ubuntu2204-arm64", | ||
] | ||
|
||
image_config_file = { | ||
"amazonlinux2": "amazonlinux2.yaml", # config is stored in config folder of k-sigs/aws-provider-test-infra repo | ||
"amazonlinux2-arm64": "amazonlinux2-arm64.yaml", # config is stored in config folder of k-sigs/aws-provider-test-infra repo | ||
"ubuntu2204": "ubuntu2204.yaml", # config is stored in config folder of k-sigs/aws-provider-test-infra repo | ||
"ubuntu2204-arm64": "ubuntu2204-arm64.yaml", # config is stored in config folder of k-sigs/aws-provider-test-infra repo | ||
"al2023": "al2023.yaml", # config is stored in config folder of k-sigs/aws-provider-test-infra repo | ||
"al2023-arm64": "al2023-arm64.yaml", # config is stored in config folder of k-sigs/aws-provider-test-infra repo | ||
"cos": "../test-infra/jobs/e2e_node/containerd/image-config.yaml", | ||
"ubuntu2204-gke": "../test-infra/jobs/e2e_node/containerd/image-config-ubuntu2204.yaml", | ||
"ubuntu2204-gke-arm64": "../test-infra/jobs/e2e_node/containerd/image-config-ubuntu2204-gke-arm64.yaml", | ||
} | ||
|
||
default_test_args = '--container-runtime-process-name=/usr/bin/containerd --container-runtime-pid-file= --kubelet-flags="--runtime-cgroups=/system.slice/containerd.service" --extra-log="{\"name\": \"containerd.log\", \"journalctl\": [\"-u\", \"containerd*\"]}"' | ||
|
||
test_scenarios = [ | ||
{ | ||
"name": "node-e2e", | ||
"skip_regex": r"\[Slow\]|\[Serial\]|\[Flaky\]", | ||
"focus_regex": r"\[Conformance\]|\[NodeConformance\]", | ||
"cloud": "all", | ||
"test_args": default_test_args, | ||
"release_blocking": ["cos-gce"] | ||
}, | ||
{ | ||
"name": "node-e2e-serial", | ||
"skip_regex": r"\[Flaky\]|\[Benchmark\]|\[NodeSpecialFeature:.+\]|\[NodeSpecialFeature\]|\[NodeAlphaFeature:.+\]|\[NodeAlphaFeature\]|\[NodeFeature:Eviction\]", | ||
"focus_regex": r"\[Serial\]", | ||
"cloud": "all", | ||
"test_args": default_test_args, | ||
}, | ||
{ | ||
"name": "node-e2e-features", | ||
"skip_regex": r"\[Flaky\]|\[Serial\]", | ||
"focus_regex": r"\[NodeFeature:.+\]|\[NodeFeature\]", | ||
"cloud": "all", | ||
"test_args": default_test_args, | ||
}, | ||
] | ||
|
||
# cri_versions = [ | ||
# "containerd/main", | ||
# "containerd/1.7", | ||
# "containerd/1.6", | ||
# ] | ||
|
||
############################ | ||
# kops-periodics-grid.yaml # | ||
############################ | ||
def generate_grid(): | ||
results = [] | ||
# pylint: disable=too-many-nested-blocks | ||
for cri in cri_options: | ||
for test_scenario in test_scenarios: | ||
for cloud in clouds: | ||
if cloud != test_scenario["cloud"] and test_scenario["cloud"] != "all": | ||
continue | ||
for distro in eval(f"{cloud}_distro_options"): | ||
distro_short = distro.replace('ubuntu', 'u').replace('debian', 'deb').replace('amazonlinux', 'amzn') # pylint: disable=line-too-long | ||
arch = "" | ||
if 'arm64' in distro: | ||
arch = "arm64" | ||
extra_dashboards = ["sig-node-grid"] | ||
if "release_blocking" in test_scenario: | ||
for v in test_scenario["release_blocking"]: | ||
if re.match(fr"{distro}-{cloud}", v): | ||
extra_dashboards.extend(['sig-release-master-blocking', 'sig-node-release-blocking']) | ||
results.append( | ||
build_test( | ||
cloud=cloud, | ||
distro=distro_short, | ||
runs_per_day=3, | ||
extra_dashboards=extra_dashboards, | ||
scenario_name=test_scenario["name"], | ||
cri=cri, | ||
arch=arch, | ||
skip_regex=test_scenario["skip_regex"], | ||
focus_regex=test_scenario["focus_regex"], | ||
env={ | ||
"TEST_ARGS": test_scenario["test_args"], | ||
"IMAGE_CONFIG_FILE": image_config_file[distro] | ||
} | ||
) | ||
) | ||
|
||
return filter(None, results) | ||
|
||
######################## | ||
# YAML File Generation # | ||
######################## | ||
periodics_files = { | ||
"sig-node-grid.yaml": generate_grid, | ||
} | ||
|
||
|
||
def main(): | ||
for filename, generate_func in periodics_files.items(): | ||
print(f"Generating {filename}") | ||
output = [] | ||
runs_per_week = 0 | ||
job_count = 0 | ||
for res in generate_func(): | ||
output.append(res[0]) | ||
runs_per_week += res[1] | ||
job_count += 1 | ||
output.insert( | ||
0, "# Test jobs generated by build_jobs.py (do not manually edit)\n" | ||
) | ||
output.insert( | ||
1, f"# {job_count} jobs, total of {runs_per_week} runs per week\n" | ||
) | ||
output.insert(2, "periodics:\n") | ||
with open(filename, "w") as fd: | ||
fd.write("".join(output)) | ||
|
||
|
||
if __name__ == "__main__": | ||
main() |
Oops, something went wrong.