Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

checkup: Introduce vmi under test configmap #219

Merged
merged 2 commits into from
Jan 25, 2024

Conversation

RamLavi
Copy link
Collaborator

@RamLavi RamLavi commented Jan 25, 2024

This PR introduces a new configmap to the checkup, that will be consumed by the VMI-under-test VMI.
In future PRs this configmap will be used to insert scripts to the guest.

@RamLavi
Copy link
Collaborator Author

RamLavi commented Jan 25, 2024

passes on CNV 4.15 cluster:

make test/e2e
podman run --rm \
           --volume /home/ralavi/go/src/github.com/kiagnose/kubevirt-dpdk-checkup:/home/ralavi/go/src/github.com/kiagnose/kubevirt-dpdk-checkup:Z \
           --volume /home/ralavi/.kube/sno01-cnvqe2-rdu2:/root/.kube:Z,ro \
           --workdir /home/ralavi/go/src/github.com/kiagnose/kubevirt-dpdk-checkup \
           -e KUBECONFIG=/root/.kube/kubeconfig \
           -e TEST_CHECKUP_IMAGE=quay.io/ramlavi/kubevirt-dpdk-checkup:latest \
           -e TEST_NAMESPACE=dpdk-checkup-ns-1 \
           -e NETWORK_ATTACHMENT_DEFINITION_NAME=dpdk-sriovnetwork-ns-1 \
           -e TRAFFIC_GEN_CONTAINER_DISK_IMAGE=quay.io/kiagnose/kubevirt-dpdk-checkup-traffic-gen:main \
           -e VM_UNDER_TEST_CONTAINER_DISK_IMAGE=quay.io/kiagnose/kubevirt-dpdk-checkup-vm:main \
           docker.io/library/golang:1.20.12 go test ./tests/... -test.v -test.timeout=1h -ginkgo.v -ginkgo.timeout=1h
=== RUN   TestKubevirtDpdkCheckup
Running Suite: KubevirtDpdkCheckup Suite - /home/ralavi/go/src/github.com/kiagnose/kubevirt-dpdk-checkup/tests
==============================================================================================================
Random Seed: 1706176945

Will run 1 of 1 specs
------------------------------
[BeforeSuite] 
/home/ralavi/go/src/github.com/kiagnose/kubevirt-dpdk-checkup/tests/test_suite_test.go:56
[BeforeSuite] PASSED [0.002 seconds]
------------------------------
Execute the checkup Job should complete successfully
/home/ralavi/go/src/github.com/kiagnose/kubevirt-dpdk-checkup/tests/checkup_test.go:83
• [308.245 seconds]
------------------------------

Ran 1 of 1 Specs in 308.248 seconds
SUCCESS! -- 1 Passed | 0 Failed | 0 Pending | 0 Skipped
--- PASS: TestKubevirtDpdkCheckup (308.25s)
PASS
ok  	github.com/kiagnose/kubevirt-dpdk-checkup/tests	308.269s

Copy link
Member

@orelmisan orelmisan left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you for the PR @RamLavi.
Please see the inline comments.

Comment on lines +370 to +359
func vmiUnderTestConfigMapName(suffix string) string {
return vmiUnderTestConfigMapNamePrefix + "-" + suffix
}
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This function is a duplicate of trafficGenConfigMapName(), please consider adjusting the signature of trafficGenConfigMapName and using a single function for both uses.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Let's do it in a later PR

@@ -200,7 +200,7 @@ func TestTeardownShouldFailWhen(t *testing.T) {
})
}

func TestTrafficGenCMTeardownFailure(t *testing.T) {
func TestCMTeardownFailure(t *testing.T) {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

WDYT about?

Suggested change
func TestCMTeardownFailure(t *testing.T) {
func TestVMConfigMapTeardownFailure(t *testing.T) {

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

DONE

Comment on lines +71 to +72
vmi.WithConfigMapVolume(configVolumeName, configMapName),
vmi.WithConfigMapDisk(configVolumeName, configDiskSerial),
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This part could potentially be moved to baseOptions() so it could be shared by the two VMIs.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I thought about it, but ended up not liking the fact that part of the configmap is loaded on the base function, and part here. It makes it less understood. WDYT?

@@ -156,3 +164,12 @@ func trafficGenBootCommands(configDiskSerial string) []string {
fmt.Sprintf("cp %s/*.py %s", configMountDirectory, trex.StreamsPyPath),
}
}

func vmiUnderTestBootCommands(configDiskSerial string) []string {
const configMountDirectory = "/mnt/app-config"
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please consider increasing the scope of the existing configMountDirectory const, and share it between the functions.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

we don't need it anywhere else. Everything is copied from this dir to where it will actually be executed.

func newVMIUnderTest(name string, checkupConfig config.Config) *kvcorev1.VirtualMachineInstance {
func newVMIUnderTest(name string, checkupConfig config.Config, configMapName string) *kvcorev1.VirtualMachineInstance {
const (
configDiskSerial = "DEADBEEF"
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please consider increasing the scope of the original configDiskSerial const, and share it between the VMIs.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't see a reason to do that, It would imply that it is connected somehow..
Both VMIs have configmaps, both happen to have the same serial..

Comment on lines 216 to 227
func (c *Checkup) createVMIUnderTestCM(ctx context.Context) error {
log.Printf("Creating ConfigMap %q...", ObjectFullName(c.namespace, c.vmiUnderTestConfigMap.Name))

_, err := c.client.CreateConfigMap(ctx, c.namespace, c.vmiUnderTestConfigMap)
return err
}

func (c *Checkup) deleteVMIUnderTestCM(ctx context.Context) error {
log.Printf("Deleting ConfigMap %q...", ObjectFullName(c.namespace, c.vmiUnderTestConfigMap.Name))

return c.client.DeleteConfigMap(ctx, c.namespace, c.vmiUnderTestConfigMap.Name)
}
Copy link
Member

@orelmisan orelmisan Jan 25, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please consider adjusting the signatures of createTrafficGenCM and deleteTrafficGenCM so they could be shared between the two configMaps.

In a similar way to how createVMI and deleteVMI work.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

DONE

This commit adds a new configmap that will be consumed by the
vmi-under-test in future commits.
The create and delete configmap functions are generalized to accept both
configmaps.
The unit test is also generalized in order to include any configmap
deleted/created.

Signed-off-by: Ram Lavi <[email protected]>
Currently the configmap is mounted but has no data.

Signed-off-by: Ram Lavi <[email protected]>
@RamLavi RamLavi force-pushed the introduce_vmi_under_test_configmap branch from de93b0d to d63b317 Compare January 25, 2024 11:21
@RamLavi
Copy link
Collaborator Author

RamLavi commented Jan 25, 2024

make test/e2e
podman run --rm \
           --volume /home/ralavi/go/src/github.com/kiagnose/kubevirt-dpdk-checkup:/home/ralavi/go/src/github.com/kiagnose/kubevirt-dpdk-checkup:Z \
           --volume /home/ralavi/.kube/sno01-cnvqe2-rdu2:/root/.kube:Z,ro \
           --workdir /home/ralavi/go/src/github.com/kiagnose/kubevirt-dpdk-checkup \
           -e KUBECONFIG=/root/.kube/kubeconfig \
           -e TEST_CHECKUP_IMAGE=quay.io/ramlavi/kubevirt-dpdk-checkup:latest \
           -e TEST_NAMESPACE=dpdk-checkup-ns-1 \
           -e NETWORK_ATTACHMENT_DEFINITION_NAME=dpdk-sriovnetwork-ns-1 \
           -e TRAFFIC_GEN_CONTAINER_DISK_IMAGE=quay.io/kiagnose/kubevirt-dpdk-checkup-traffic-gen:main \
           -e VM_UNDER_TEST_CONTAINER_DISK_IMAGE=quay.io/kiagnose/kubevirt-dpdk-checkup-vm:main \
           docker.io/library/golang:1.20.12 go test ./tests/... -test.v -test.timeout=1h -ginkgo.v -ginkgo.timeout=1h
=== RUN   TestKubevirtDpdkCheckup
Running Suite: KubevirtDpdkCheckup Suite - /home/ralavi/go/src/github.com/kiagnose/kubevirt-dpdk-checkup/tests
==============================================================================================================
Random Seed: 1706181861

Will run 1 of 1 specs
------------------------------
[BeforeSuite] 
/home/ralavi/go/src/github.com/kiagnose/kubevirt-dpdk-checkup/tests/test_suite_test.go:56
[BeforeSuite] PASSED [0.003 seconds]
------------------------------
Execute the checkup Job should complete successfully
/home/ralavi/go/src/github.com/kiagnose/kubevirt-dpdk-checkup/tests/checkup_test.go:83
• [361.935 seconds]
------------------------------

Ran 1 of 1 Specs in 361.938 seconds
SUCCESS! -- 1 Passed | 0 Failed | 0 Pending | 0 Skipped
--- PASS: TestKubevirtDpdkCheckup (361.94s)
PASS
ok  	github.com/kiagnose/kubevirt-dpdk-checkup/tests	361.971s

@orelmisan orelmisan merged commit ed5c2cb into kiagnose:main Jan 25, 2024
4 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants