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

test(CNV-43603): add disk-uploader functional tests #549

Draft
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

codingben
Copy link
Member

What this PR does / why we need it:

Deploy a new Cirros VM to export from,
and run disk-uploader as Task to execute
extraction process and upload it to the
Quay container registry.

Release note:

None

@kubevirt-bot kubevirt-bot added release-note-none Denotes a PR that doesn't merit a release note. dco-signoff: yes Indicates the PR's author has DCO signed all their commits. labels Nov 12, 2024
@kubevirt-bot
Copy link
Contributor

[APPROVALNOTIFIER] This PR is NOT APPROVED

This pull-request has been approved by:
Once this PR has been reviewed and has the lgtm label, please assign 0xfelix for approval. For more information see the Kubernetes Code Review Process.

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

Needs approval from an approver in each of these files:

Approvers can indicate their approval by writing /approve in a comment
Approvers can cancel approval by writing /approve cancel in a comment

Copy link

openshift-ci bot commented Nov 12, 2024

[APPROVALNOTIFIER] This PR is NOT APPROVED

This pull-request has been approved by: codingben
Once this PR has been reviewed and has the lgtm label, please assign 0xfelix for approval. For more information see the Kubernetes Code Review Process.

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

Needs approval from an approver in each of these files:

Approvers can indicate their approval by writing /approve in a comment
Approvers can cancel approval by writing /approve cancel in a comment

@codingben codingben marked this pull request as draft November 12, 2024 14:39
@kubevirt-bot kubevirt-bot added the do-not-merge/work-in-progress Indicates that a PR should not merge because it is a work in progress. label Nov 12, 2024
@codingben
Copy link
Member Author

/cc @ksimon1 @akrejcir

@codingben
Copy link
Member Author

@ksimon1 @0xFelix Can you please take a look?

ExportSourceKind: "vm",
ExportSourceName: vmName,
VolumeName: dvName,
ImageDestination: "quay.io/boukhano/e2e-example-vm", // TODO: Use quay.io/kubevirt/e2e-example-vm
Copy link
Member

Choose a reason for hiding this comment

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

Is there a registry local to the test cluster, that can be used?

Copy link
Member Author

Choose a reason for hiding this comment

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

I had a discussion with @ksimon1 about it to keep using an external registry that allows you also to test it on Kubernetes cluster. As you know, only OpenShift has built-in container registry.

test/disk_uploader_test.go Outdated Show resolved Hide resolved
test/disk_uploader_test.go Outdated Show resolved Hide resolved
Comment on lines 71 to 72
"accessKeyId": []byte(""), // TODO: Get value from OCP CI
"secretKey": []byte(""), // TODO: Get value from OCP CI
Copy link
Member

Choose a reason for hiding this comment

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

Please don't add any credentials to this repo! Can we do this differently with a local registry?

Copy link
Member

Choose a reason for hiding this comment

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

There will be no credentials in the repo, since the OCP ci has a secret vault, which can be used for populating the secrets in test

Copy link
Member Author

Choose a reason for hiding this comment

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

There will be no secrets in this repository. Both accessKeyId and secretKey values will be set from the environment variables (aka Secrets in the OCP CI).

Copy link
Member Author

Choose a reason for hiding this comment

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

@ksimon1 How do you think we'll store the registry credenetials when running in developer mode, locally in the developer machine? (not in a CI)

CreateTaskRun().
ExpectSuccess().
ExpectLogs(config.GetAllExpectedLogs()...).
ExpectResults(nil)
Copy link
Member

Choose a reason for hiding this comment

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

Query the repository after to verify disk was uploaded?

Copy link
Member Author

Choose a reason for hiding this comment

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

Yep good idea, need to check it.

Copy link
Member

Choose a reason for hiding this comment

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

Are you going to add a check?

Copy link
Member Author

Choose a reason for hiding this comment

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

Yes. We may want to delete the repository after completing running the tests. If we won't delete it, and re-run the functional tests, it may be false check.

@codingben
Copy link
Member Author

codingben commented Nov 13, 2024

@0xFelix @ksimon1 This revision adds the usage of libvmi and libdv.

CI or developer locally expected to set REGISTRY_IMAGE_DESTINATION, REGISTRY_ACCESS_KEY_ID and REGISTRY_SECRET_KEY environment variables.

@codingben
Copy link
Member Author

codingben commented Nov 13, 2024

@ksimon1 @0xFelix Currently there is a single test case: Extracts disk from VM and upload to container registry. Do you think we should also test scenarios of extracting it from VMSnapshot or PVC, or it's enough to have only VM? I don't want to end up re-testing and over-testing Export API.

func createAndWaitForVM(client kubevirtcliv1.KubevirtClient, namespace, name string, timeout time.Duration) {
dataVolume := libdv.NewDataVolume(
libdv.WithRegistryURLSource("docker://quay.io/kubevirt/cirros-container-disk-demo"),
libdv.WithForceBindAnnotation(),
Copy link
Member

Choose a reason for hiding this comment

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

Should not be required, if the VM was started at least once.

Copy link
Member Author

Choose a reason for hiding this comment

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

VM can't be exported if started and it's running. It should be stopped.

Copy link
Member Author

@codingben codingben Nov 14, 2024

Choose a reason for hiding this comment

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

VM is created as stopped by default.

test/disk_uploader_test.go Outdated Show resolved Hide resolved
Deploy a new Cirros VM to export from,
and run disk-uploader as Task to execute
extraction process and upload it to the
Quay container registry.

Signed-off-by: Ben Oukhanov <[email protected]>
@codingben
Copy link
Member Author

@ksimon1 @0xFelix This revision will make e2e tests work, as tested locally it works now and image was pushed to the Quay container registry [1].

Can you please review?

[1] https://quay.io/repository/boukhano/e2e-tests-example-vm

@@ -40,7 +40,7 @@ kubectl apply -f "https://github.com/kubevirt/kubevirt/releases/download/${KUBEV

kubectl apply -f "https://github.com/kubevirt/kubevirt/releases/download/${KUBEVIRT_VERSION}/kubevirt-cr.yaml"

kubectl patch kubevirt kubevirt -n kubevirt --type merge -p '{"spec":{"configuration":{"developerConfiguration":{"featureGates": ["DataVolumes"]}}}}'
kubectl patch kubevirt kubevirt -n kubevirt --type merge -p '{"spec":{"configuration":{"developerConfiguration":{"featureGates": ["DataVolumes", "VMExport"]}}}}'
Copy link
Member

Choose a reason for hiding this comment

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

DataVolumes FG can be dropped I guess.

Copy link
Member Author

Choose a reason for hiding this comment

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

Yep just want to get confirmation from @ksimon1 about it, so this PR won't do any other changes except adding new tests.

@@ -3,3 +3,6 @@
export DEV_MODE="${DEV_MODE:-false}"
export STORAGE_CLASS="${STORAGE_CLASS:-}"
export NUM_NODES=${NUM_NODES:-2}
export REGISTRY_IMAGE_DESTINATION="quay.io/kubevirt/e2e-tests-example-vm"
Copy link
Member

Choose a reason for hiding this comment

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

Is there absolutely no way to use an ephemeral registry? Why do we have to store test artifacts on a live registry? (quay.io)

Copy link
Member Author

Choose a reason for hiding this comment

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

I replied here earlier. The issue is that there is no built-in registry in Kubernetes cluster (only on OpenShift).

So we have 3 options:

1). Deploy a new pod that will use registry image to push there
2). Use OCP's built-in container registry
3). Use an external container registry

@0xFelix @ksimon1 What do you prefer?

Comment on lines +38 to +48
imageDestination := os.Getenv("REGISTRY_IMAGE_DESTINATION")
Expect(imageDestination).ToNot(BeEmpty())

registryCredentials, err := createRegistryCredentials(f.CoreV1Client, f.DeployNamespace)
Expect(err).ToNot(HaveOccurred())

cirrosVm, err := createCirrosVM(f.KubevirtClient, f.DeployNamespace)
Expect(err).ToNot(HaveOccurred())

_, err = vm.WaitForVM(f.KubevirtClient, f.DeployNamespace, cirrosVm.Name, "", constants.Timeouts.WaitForVMStart.Duration, false)
Expect(err).ToNot(HaveOccurred())
Copy link
Member

Choose a reason for hiding this comment

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

Move this to BeforeEach?

CreateTaskRun().
ExpectSuccess().
ExpectLogs(config.GetAllExpectedLogs()...).
ExpectResults(nil)
Copy link
Member

Choose a reason for hiding this comment

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

Are you going to add a check?


func createCirrosVM(client kubevirtcliv1.KubevirtClient, namespace string) (*v1.VirtualMachine, error) {
dataVolume := libdv.NewDataVolume(
libdv.WithRegistryURLSource("docker://quay.io/kubevirt/cirros-container-disk-demo"),
Copy link
Member

Choose a reason for hiding this comment

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

Please do not use libdv. It lives under tests/libdv which might be subject to change. Only libvmi can be considered stable.

Copy link
Member Author

Choose a reason for hiding this comment

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

@0xFelix Don't you think that this is an issue that such important libs for external projects tests living under kubevirt/kubevirt, especially under tests/libdv?

@codingben
Copy link
Member Author

@ksimon1 @0xFelix Currently there is a single test case: Extracts disk from VM and upload to container registry. Do you think we should also test scenarios of extracting it from VMSnapshot or PVC, or it's enough to have only VM? I don't want to end up re-testing and over-testing Export API.

@ksimon1 @0xFelix What is your opinion about it?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
dco-signoff: yes Indicates the PR's author has DCO signed all their commits. do-not-merge/work-in-progress Indicates that a PR should not merge because it is a work in progress. release-note-none Denotes a PR that doesn't merit a release note. size/XXL
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants