Skip to content

Commit 23ce4a8

Browse files
committed
ci: lint e2e tests
Signed-off-by: Miguel Duarte Barroso <[email protected]>
1 parent 786ca28 commit 23ce4a8

File tree

3 files changed

+20
-17
lines changed

3 files changed

+20
-17
lines changed

.github/workflows/check.yaml

+1-1
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ jobs:
3232
uses: golangci/golangci-lint-action@v3
3333
with:
3434
version: v1.47.3
35-
args: --timeout 3m --verbose cmd/... pkg/...
35+
args: --timeout 3m --verbose cmd/... pkg/... e2e/...
3636

3737
- name: Test
3838
run: make test

e2e/client/types.go

+14-13
Original file line numberDiff line numberDiff line change
@@ -76,8 +76,8 @@ func (c *E2EClient) DeleteNamespace(name string) error {
7676
return nil
7777
}
7878

79-
func (c *E2EClient) ProvisionPod(podName string, namespace string, label, annotations map[string]string) (*corev1.Pod, error) {
80-
pod := PodObject(podName, namespace, label, annotations)
79+
func (c *E2EClient) ProvisionPod(podName string, namespace string, label, podAnnotations map[string]string) (*corev1.Pod, error) {
80+
pod := PodObject(podName, namespace, label, podAnnotations)
8181
pod, err := c.k8sClient.CoreV1().Pods(pod.Namespace).Create(context.Background(), pod, metav1.CreateOptions{})
8282
if err != nil {
8383
return nil, err
@@ -144,8 +144,9 @@ func (c *E2EClient) WaitForPodBySelector(namespace, selector string, timeout tim
144144
return nil
145145
}
146146

147-
for _, pod := range podList.Items {
148-
if err := c.WaitForPodReady(namespace, pod.Name, timeout); err != nil {
147+
pods := podList.Items
148+
for i := range pods {
149+
if err := c.WaitForPodReady(namespace, pods[i].Name, timeout); err != nil {
149150
return err
150151
}
151152
}
@@ -196,9 +197,9 @@ func isPodGone(cs kubernetes.Interface, podName, namespace string) wait.Conditio
196197
}
197198
}
198199

199-
func PodObject(podName string, namespace string, label, annotations map[string]string) *corev1.Pod {
200+
func PodObject(podName string, namespace string, label, podAnnotations map[string]string) *corev1.Pod {
200201
return &corev1.Pod{
201-
ObjectMeta: podMeta(podName, namespace, label, annotations),
202+
ObjectMeta: podMeta(podName, namespace, label, podAnnotations),
202203
Spec: podSpec("samplepod"),
203204
}
204205
}
@@ -220,31 +221,31 @@ func containerCmd() []string {
220221
return []string{"/bin/ash", "-c", "trap : TERM INT; sleep infinity & wait"}
221222
}
222223

223-
func podMeta(podName string, namespace string, label map[string]string, annotations map[string]string) metav1.ObjectMeta {
224+
func podMeta(podName string, namespace string, label map[string]string, podAnnotations map[string]string) metav1.ObjectMeta {
224225
return metav1.ObjectMeta{
225226
Name: podName,
226227
Namespace: namespace,
227228
Labels: label,
228-
Annotations: annotations,
229+
Annotations: podAnnotations,
229230
}
230231
}
231232

232233
func dynamicNetworksAnnotation(pod *corev1.Pod, newIfaceConfigs ...*nettypes.NetworkSelectionElement) string {
233-
currentNetworkSelectionElements, err := extractPodNetworkSelectionElements(pod)
234+
networkSelectionElements, err := extractPodNetworkSelectionElements(pod)
234235
if err != nil {
235236
return ""
236237
}
237238

238-
updatedNetworkSelectionElements := append(
239-
currentNetworkSelectionElements,
239+
networkSelectionElements = append(
240+
networkSelectionElements,
240241
newIfaceConfigs...,
241242
)
242-
newSelectionElements, err := json.Marshal(updatedNetworkSelectionElements)
243+
updatedNetworkSelectionElements, err := json.Marshal(networkSelectionElements)
243244
if err != nil {
244245
return ""
245246
}
246247

247-
return string(newSelectionElements)
248+
return string(updatedNetworkSelectionElements)
248249
}
249250

250251
func removeFromDynamicNetworksAnnotation(pod *corev1.Pod, networkName string, netNamespace string, ifaceName string) string {

e2e/status/helpers.go

+5-3
Original file line numberDiff line numberDiff line change
@@ -18,10 +18,12 @@ func FilterPodsNetworkStatus(clients *client.E2EClient, namespace, podName strin
1818
if err != nil {
1919
return nil
2020
}
21+
22+
podsCurrentNetworks := PodDynamicNetworks(&pods.Items[0])
2123
var podNetworkStatus []nettypes.NetworkStatus
22-
for _, netStatus := range PodDynamicNetworks(&pods.Items[0]) {
23-
if p(netStatus) {
24-
podNetworkStatus = append(podNetworkStatus, netStatus)
24+
for i := range podsCurrentNetworks {
25+
if p(podsCurrentNetworks[i]) {
26+
podNetworkStatus = append(podNetworkStatus, podsCurrentNetworks[i])
2527
}
2628
}
2729
return podNetworkStatus

0 commit comments

Comments
 (0)