Skip to content

Commit d76ce8a

Browse files
authored
Merge pull request #34936 from dims/add-periodic-presubmit-for-running-unit-tests-in-k/k-with-updated-dependencies
Add periodic/presubmit for running unit tests in k/k with updated dependencies
2 parents 352a559 + 53abcef commit d76ce8a

File tree

2 files changed

+125
-5
lines changed

2 files changed

+125
-5
lines changed

config/jobs/kubernetes/sig-arch/kubernetes-code-organization.yaml

Lines changed: 88 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ presubmits:
2525
- wrapper.sh
2626
- bash
2727
- -c
28-
- ./../test-infra/experiment/dependencies/update-dependencies-and-run-kind-e2e.sh
28+
- ./../test-infra/experiment/dependencies/update-dependencies-and-run-tests.sh --test-mode kind
2929
env:
3030
- name: LABEL_FILTER
3131
value: "Feature: isEmpty && !Slow && !Disruptive && !Flaky"
@@ -48,6 +48,49 @@ presubmits:
4848
testgrid-alert-stale-results-hours: '24'
4949
fork-per-release: "true"
5050

51+
- name: pull-kubernetes-e2e-unit-dependencies
52+
cluster: k8s-infra-prow-build
53+
optional: true
54+
always_run: false
55+
decorate: true
56+
skip_branches:
57+
- release-\d+\.\d+ # per-release settings
58+
path_alias: k8s.io/kubernetes
59+
extra_refs:
60+
- org: kubernetes
61+
repo: test-infra
62+
base_ref: master
63+
path_alias: k8s.io/test-infra
64+
spec:
65+
# unit tests have no business requiring root or doing privileged operations
66+
securityContext:
67+
# NOTE: these are arbitrary non-root values. They don't exist in the
68+
# image and don't need to, the unit tests should only write to TMPDIR
69+
runAsUser: 2001
70+
runAsGroup: 2010
71+
containers:
72+
- image: gcr.io/k8s-staging-test-infra/kubekins-e2e:v20250527-1b2b10e804-master
73+
securityContext:
74+
allowPrivilegeEscalation: false
75+
command:
76+
- wrapper.sh
77+
- bash
78+
- -c
79+
- ./../test-infra/experiment/dependencies/update-dependencies-and-run-tests.sh --test-mode unit
80+
resources:
81+
limits:
82+
cpu: 7.2
83+
memory: "43Gi"
84+
requests:
85+
cpu: 7.2
86+
memory: "43Gi"
87+
annotations:
88+
testgrid-dashboards: sig-arch-code-organization
89+
testgrid-tab-name: pull-unit-master-dependencies
90+
testgrid-num-failures-to-alert: '10'
91+
testgrid-alert-stale-results-hours: '24'
92+
fork-per-release: "true"
93+
5194
periodics:
5295
- interval: 4h
5396
cluster: k8s-infra-prow-build
@@ -79,7 +122,7 @@ periodics:
79122
- wrapper.sh
80123
- bash
81124
- -c
82-
- ./../test-infra/experiment/dependencies/update-dependencies-and-run-kind-e2e.sh
125+
- ./../test-infra/experiment/dependencies/update-dependencies-and-run-tests.sh --test-mode kind
83126
env:
84127
- name: LABEL_FILTER
85128
value: "Feature: isEmpty && !Slow && !Disruptive && !Flaky"
@@ -95,3 +138,46 @@ periodics:
95138
requests:
96139
cpu: 7
97140
memory: 9000Mi
141+
142+
- interval: 4h
143+
cluster: k8s-infra-prow-build
144+
name: ci-kubernetes-unit-dependencies
145+
annotations:
146+
testgrid-dashboards: sig-arch-code-organization
147+
testgrid-tab-name: unit-master-dependencies
148+
description: Runs unit tests after updating dependencies to latest versions
149+
testgrid-alert-email: [email protected]
150+
testgrid-num-columns-recent: '6'
151+
decorate: true
152+
extra_refs:
153+
- org: kubernetes
154+
repo: kubernetes
155+
base_ref: master
156+
path_alias: k8s.io/kubernetes
157+
- org: kubernetes
158+
repo: test-infra
159+
base_ref: master
160+
path_alias: k8s.io/test-infra
161+
spec:
162+
# unit tests have no business requiring root or doing privileged operations
163+
securityContext:
164+
# NOTE: these are arbitrary non-root values. They don't exist in the
165+
# image and don't need to, the unit tests should only write to TMPDIR
166+
runAsUser: 2001
167+
runAsGroup: 2010
168+
containers:
169+
- image: gcr.io/k8s-staging-test-infra/kubekins-e2e:v20250527-1b2b10e804-master
170+
securityContext:
171+
allowPrivilegeEscalation: false
172+
command:
173+
- wrapper.sh
174+
- bash
175+
- -c
176+
- ./../test-infra/experiment/dependencies/update-dependencies-and-run-tests.sh --test-mode unit
177+
resources:
178+
limits:
179+
cpu: 7.2
180+
memory: "43Gi"
181+
requests:
182+
cpu: 7.2
183+
memory: "43Gi"

experiment/dependencies/update-dependencies-and-run-kind-e2e.sh renamed to experiment/dependencies/update-dependencies-and-run-tests.sh

Lines changed: 37 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,32 @@ set -o nounset
1919
set -o pipefail
2020
set -o xtrace
2121

22+
# Default test mode
23+
TEST_MODE="kind"
24+
25+
# Parse command line arguments
26+
while [[ $# -gt 0 ]]; do
27+
key="$1"
28+
case $key in
29+
--test-mode)
30+
TEST_MODE="$2"
31+
shift 2
32+
;;
33+
*)
34+
echo "Unknown option: $1"
35+
echo "Usage: $0 [--test-mode <kind|unit>]"
36+
exit 1
37+
;;
38+
esac
39+
done
40+
41+
# Validate test mode
42+
if [[ "${TEST_MODE}" != "kind" && "${TEST_MODE}" != "unit" ]]; then
43+
echo "Invalid test mode: ${TEST_MODE}. Must be either 'kind' or 'unit'."
44+
echo "Usage: $0 [--test-mode <kind|unit>]"
45+
exit 1
46+
fi
47+
2248
# install kind
2349
curl -sSL https://kind.sigs.k8s.io/dl/latest/linux-amd64.tgz | tar xvfz - -C "${PATH%%:*}/"
2450

@@ -32,7 +58,9 @@ go install github.com/sgaunet/mdtohtml@latest
3258
popd
3359

3460
# needed by gomod_staleness.py
35-
apt update && apt -y install jq
61+
if ! command -v jq &> /dev/null; then
62+
apt update && apt -y install jq
63+
fi
3664

3765
# grab the stats before we start
3866
depstat stats -m "k8s.io/kubernetes$(ls staging/src/k8s.io | awk '{printf ",k8s.io/" $0}')" -v > "${WORKDIR}/stats-before.txt"
@@ -60,5 +88,11 @@ hack/lint-dependencies.sh || true
6088
# ensure that all our code will compile
6189
hack/verify-typecheck.sh
6290

63-
# run kind based tests
64-
e2e-k8s.sh
91+
# run tests based on the selected mode
92+
if [[ "${TEST_MODE}" == "kind" ]]; then
93+
# run kind based e2e tests
94+
e2e-k8s.sh
95+
else
96+
# run unit tests
97+
make test
98+
fi

0 commit comments

Comments
 (0)