Skip to content

Commit 5f9b695

Browse files
authored
test(k8s): update k8s integrtion test (#9725)
1 parent 3169ebf commit 5f9b695

File tree

3 files changed

+14
-262
lines changed

3 files changed

+14
-262
lines changed

integration/k8s_test.go

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,8 @@ func TestK8s(t *testing.T) {
4242
"summary",
4343
"--checks-bundle-repository",
4444
"mirror.gcr.io/aquasec/trivy-checks:1.11.2@sha256:f3ea8227f838a985f0c884909e9d226362f5fc5ab6021310a179fbb24c5b57fd",
45-
"-q",
45+
"--include-namespaces", "default",
46+
"--debug",
4647
"--timeout",
4748
"5m0s",
4849
"--format",
Lines changed: 1 addition & 260 deletions
Original file line numberDiff line numberDiff line change
@@ -1,290 +1,31 @@
11
{
22
"vulnerabilities": [
33
"CVE-2019-1551",
4-
"CVE-2019-1551",
5-
"CVE-2019-1563",
64
"CVE-2019-1563",
75
"CVE-2019-18276",
8-
"CVE-2019-18276",
9-
"CVE-2019-5094",
10-
"CVE-2019-5094",
11-
"CVE-2019-5094",
12-
"CVE-2019-5094",
136
"CVE-2019-5094",
147
"CVE-2019-5094",
158
"CVE-2019-5094",
169
"CVE-2019-5094"
1710
],
1811
"misconfigurations": [
19-
"AVD-KSV-01010",
20-
"KCV0001",
21-
"KCV0006",
22-
"KCV0010",
23-
"KCV0018",
24-
"KCV0019",
25-
"KCV0020",
26-
"KCV0021",
27-
"KCV0022",
28-
"KCV0030",
29-
"KCV0033",
30-
"KCV0038",
31-
"KCV0059",
32-
"KCV0069",
33-
"KCV0075",
34-
"KCV0077",
35-
"KSV001",
36-
"KSV001",
37-
"KSV001",
38-
"KSV001",
39-
"KSV001",
40-
"KSV001",
41-
"KSV001",
42-
"KSV001",
4312
"KSV001",
44-
"KSV0012",
4513
"KSV003",
46-
"KSV003",
47-
"KSV003",
48-
"KSV003",
49-
"KSV003",
50-
"KSV003",
51-
"KSV003",
52-
"KSV003",
53-
"KSV003",
54-
"KSV004",
55-
"KSV004",
56-
"KSV004",
57-
"KSV004",
58-
"KSV004",
59-
"KSV004",
60-
"KSV004",
6114
"KSV004",
62-
"KSV004",
63-
"KSV009",
64-
"KSV009",
65-
"KSV009",
66-
"KSV009",
67-
"KSV009",
68-
"KSV009",
69-
"KSV011",
70-
"KSV011",
71-
"KSV011",
72-
"KSV011",
73-
"KSV011",
74-
"KSV011",
75-
"KSV011",
7615
"KSV011",
77-
"KSV011",
78-
"KSV012",
79-
"KSV012",
80-
"KSV012",
81-
"KSV012",
82-
"KSV012",
83-
"KSV012",
8416
"KSV012",
85-
"KSV012",
86-
"KSV012",
87-
"KSV012",
88-
"KSV0125",
89-
"KSV0125",
90-
"KSV0125",
91-
"KSV0125",
92-
"KSV0125",
93-
"KSV0125",
94-
"KSV0125",
95-
"KSV0125",
96-
"KSV014",
97-
"KSV014",
98-
"KSV014",
99-
"KSV014",
10017
"KSV014",
101-
"KSV014",
102-
"KSV014",
103-
"KSV014",
104-
"KSV014",
105-
"KSV015",
106-
"KSV015",
107-
"KSV015",
10818
"KSV015",
10919
"KSV016",
110-
"KSV016",
111-
"KSV016",
112-
"KSV016",
113-
"KSV016",
114-
"KSV016",
115-
"KSV016",
116-
"KSV017",
117-
"KSV018",
118-
"KSV018",
11920
"KSV018",
120-
"KSV018",
121-
"KSV018",
122-
"KSV018",
123-
"KSV018",
124-
"KSV018",
125-
"KSV020",
126-
"KSV020",
12721
"KSV020",
128-
"KSV020",
129-
"KSV020",
130-
"KSV020",
131-
"KSV020",
132-
"KSV020",
133-
"KSV020",
134-
"KSV020",
135-
"KSV021",
136-
"KSV021",
137-
"KSV021",
138-
"KSV021",
139-
"KSV021",
140-
"KSV021",
141-
"KSV021",
142-
"KSV021",
14322
"KSV021",
144-
"KSV021",
145-
"KSV022",
146-
"KSV022",
147-
"KSV023",
148-
"KSV023",
149-
"KSV023",
150-
"KSV023",
151-
"KSV023",
152-
"KSV023",
153-
"KSV030",
154-
"KSV030",
155-
"KSV030",
15623
"KSV030",
157-
"KSV030",
158-
"KSV030",
159-
"KSV036",
160-
"KSV041",
161-
"KSV041",
162-
"KSV041",
163-
"KSV041",
164-
"KSV041",
165-
"KSV041",
166-
"KSV041",
167-
"KSV041",
168-
"KSV041",
169-
"KSV041",
170-
"KSV041",
171-
"KSV041",
172-
"KSV041",
173-
"KSV044",
174-
"KSV045",
175-
"KSV046",
176-
"KSV046",
177-
"KSV046",
178-
"KSV046",
179-
"KSV046",
180-
"KSV046",
181-
"KSV046",
182-
"KSV048",
183-
"KSV048",
184-
"KSV048",
185-
"KSV048",
186-
"KSV048",
187-
"KSV048",
188-
"KSV048",
189-
"KSV048",
190-
"KSV048",
191-
"KSV048",
192-
"KSV048",
193-
"KSV048",
194-
"KSV048",
195-
"KSV048",
196-
"KSV048",
197-
"KSV048",
198-
"KSV048",
199-
"KSV048",
200-
"KSV048",
201-
"KSV048",
202-
"KSV048",
203-
"KSV048",
204-
"KSV048",
205-
"KSV048",
206-
"KSV048",
207-
"KSV048",
208-
"KSV048",
209-
"KSV048",
210-
"KSV048",
211-
"KSV048",
212-
"KSV048",
213-
"KSV048",
214-
"KSV048",
215-
"KSV048",
216-
"KSV048",
217-
"KSV048",
218-
"KSV049",
219-
"KSV049",
220-
"KSV049",
221-
"KSV049",
222-
"KSV049",
223-
"KSV049",
224-
"KSV049",
225-
"KSV049",
226-
"KSV050",
227-
"KSV050",
228-
"KSV053",
229-
"KSV053",
230-
"KSV053",
231-
"KSV056",
232-
"KSV056",
233-
"KSV056",
234-
"KSV056",
235-
"KSV056",
236-
"KSV056",
237-
"KSV056",
238-
"KSV056",
239-
"KSV056",
240-
"KSV056",
241-
"KSV056",
242-
"KSV056",
243-
"KSV056",
244-
"KSV056",
245-
"KSV056",
246-
"KSV056",
247-
"KSV056",
248-
"KSV056",
249-
"KSV056",
250-
"KSV104",
251-
"KSV104",
25224
"KSV104",
253-
"KSV104",
254-
"KSV104",
255-
"KSV104",
256-
"KSV106",
257-
"KSV106",
258-
"KSV106",
259-
"KSV106",
260-
"KSV106",
261-
"KSV106",
262-
"KSV106",
263-
"KSV106",
26425
"KSV106",
26526
"KSV110",
266-
"KSV111",
267-
"KSV112",
268-
"KSV112",
269-
"KSV113",
270-
"KSV113",
27127
"KSV117",
272-
"KSV117",
273-
"KSV117",
274-
"KSV118",
275-
"KSV118",
276-
"KSV118",
277-
"KSV118",
278-
"KSV118",
279-
"KSV118",
280-
"KSV118",
281-
"KSV118",
28228
"KSV118",
283-
"KSV119",
284-
"KSV122",
285-
"no-user-pods-in-system-namespace",
286-
"no-user-pods-in-system-namespace",
287-
"no-user-pods-in-system-namespace",
288-
"no-user-pods-in-system-namespace"
29+
"KSV118"
28930
]
29031
}

magefiles/magefile.go

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -252,10 +252,20 @@ func (t Test) K8s() error {
252252
return fmt.Errorf("can't create environment for limited user: %w", err)
253253
}
254254

255+
// wait for all pods are running correctly
256+
err = sh.RunWithV(ENV, "kubectl", "wait", "--for=condition=Ready", "pod", "--all", "--all-namespaces", "--timeout=300s")
257+
if err != nil {
258+
return fmt.Errorf("can't wait for the pods: %w", err)
259+
}
260+
255261
// print all resources for info
256262
err = sh.RunWithV(ENV, "kubectl", "get", "all", "-A")
257263
if err != nil {
258-
return err
264+
return fmt.Errorf("can't get workloads: %w", err)
265+
}
266+
err = sh.RunWithV(ENV, "kubectl", "get", "cm", "-A")
267+
if err != nil {
268+
return fmt.Errorf("can't get configmaps: %w", err)
259269
}
260270

261271
return sh.RunWithV(ENV, "go", "test", "-v", "-tags=k8s_integration", "./integration/...")

0 commit comments

Comments
 (0)