kubevirt / containerized-data-importer

Data Import Service for kubernetes, designed with kubevirt in mind.
Apache License 2.0
395 stars 249 forks source link

Prevent a panic in test clean-up #3322

Closed EduardGomezEscandell closed 1 month ago

EduardGomezEscandell commented 1 month ago

What this PR does / why we need it: Avoid panic in tests.

During test setup, pointer framework.ClientsInstance.K8sClient is assigned. During the test AfterSuite phase, an Eventually loop accesses this pointer.

If the test fails before this assignment, the after-suite will panic.

Pointer assignment: https://github.com/kubevirt/containerized-data-importer/blob/b6392df9bf943f00c70ae71d37106cc12a576f19/tests/tests_suite_test.go#L123 Panic in AfterSuite, when calling GetTestNamespaceList: https://github.com/kubevirt/containerized-data-importer/blob/b6392df9bf943f00c70ae71d37106cc12a576f19/tests/tests_suite_test.go#L162 Which defereferences the client pointer in client.CoreV1(): https://github.com/kubevirt/containerized-data-importer/blob/b6392df9bf943f00c70ae71d37106cc12a576f19/tests/utils/common.go#L136

Special notes for your reviewer: I believe this is similar to this PR: https://github.com/kubevirt/containerized-data-importer/pull/3294

Release note:

NONE
coveralls commented 1 month ago

Coverage Status

coverage: 59.03% (-0.03%) from 59.056% when pulling a6a86fa9ae184b7f659b2c951a86bbde3638bf60 on EduardGomezEscandell:fix-panic-test-failure into b6392df9bf943f00c70ae71d37106cc12a576f19 on kubevirt:main.

EduardGomezEscandell commented 1 month ago

/cc @alromeros

alromeros commented 1 month ago

Great! /lgtm

awels commented 1 month ago

/approve

kubevirt-bot commented 1 month ago

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: awels

The full list of commands accepted by this bot can be found here.

The pull request process is described here

Needs approval from an approver in each of these files: - ~~[OWNERS](https://github.com/kubevirt/containerized-data-importer/blob/main/OWNERS)~~ [awels] Approvers can indicate their approval by writing `/approve` in a comment Approvers can cancel approval by writing `/approve cancel` in a comment