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

Set unsupported images via shell in our e2e tests #1541

Open
wants to merge 8 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 16 additions & 0 deletions docs/developer/testing/TESTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -94,6 +94,22 @@ You can also execute make test-e2e with a $GINKGO_ARGS variable set. Example:
make test-e2e GINKGO_ARGS="--ginkgo.focus='MySQL application DATAMOVER'"
```

### Run tests with custom images

You can run tests with custom images by setting the following environment variables:
```bash
export VELERO_IMAGE=<velero_image>
export AWS_PLUGIN_IMAGE=<aws_plugin_image>
export OPENSHIFT_PLUGIN_IMAGE=<openshift_plugin_image>
export AZURE_PLUGIN_IMAGE=<azure_plugin_image>
export GCP_PLUGIN_IMAGE=<gcp_plugin_image>
export CSI_PLUGIN_IMAGE=<csi_plugin_image>
export RESTORE_IMAGE=<restore_image>
weshayutin marked this conversation as resolved.
Show resolved Hide resolved
export KUBEVIRT_PLUGIN_IMAGE=<kubevirt_plugin_image>
export NON_ADMIN_IMAGE=<non_admin_image>
```
For further details, see [tests/e2e/scripts/](../../../tests/e2e/scripts/)

## Clean up

To clean environment after running E2E tests, run
Expand Down
11 changes: 1 addition & 10 deletions tests/e2e/dpa_deployment_suite_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,6 @@ type TestDPASpec struct {
NoS3ForcePathStyle bool
NoRegion bool
DoNotBackupImages bool
UnsupportedOverrides map[oadpv1alpha1.UnsupportedImageKey]string
}

func createTestDPASpec(testSpec TestDPASpec) *oadpv1alpha1.DataProtectionApplicationSpec {
Expand Down Expand Up @@ -66,7 +65,7 @@ func createTestDPASpec(testSpec TestDPASpec) *oadpv1alpha1.DataProtectionApplica
},
},
SnapshotLocations: testSpec.SnapshotLocations,
UnsupportedOverrides: testSpec.UnsupportedOverrides,
UnsupportedOverrides: dpaCR.UnsupportedOverrides,
}
if testSpec.EnableNodeAgent {
dpaSpec.Configuration.NodeAgent = &oadpv1alpha1.NodeAgentConfig{
Expand Down Expand Up @@ -359,14 +358,6 @@ var _ = ginkgo.Describe("Configuration testing for DPA Custom Resource", func()
DoNotBackupImages: true,
}),
}),
ginkgo.Entry("DPA CR with unsupportedOverrides", ginkgo.Label("aws", "ibmcloud"), InstallCase{
DpaSpec: createTestDPASpec(TestDPASpec{
BSLSecretName: bslSecretName,
UnsupportedOverrides: map[oadpv1alpha1.UnsupportedImageKey]string{
"awsPluginImageFqin": "quay.io/konveyor/velero-plugin-for-aws:oadp-1.4",
},
}),
}),
)

ginkgo.DescribeTable("DPA reconciled to false",
Expand Down
1 change: 1 addition & 0 deletions tests/e2e/e2e_suite_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -169,6 +169,7 @@ func TestOADPE2E(t *testing.T) {
BSLBucketPrefix: veleroPrefix,
VeleroDefaultPlugins: dpa.DeepCopy().Spec.Configuration.Velero.DefaultPlugins,
SnapshotLocations: dpa.DeepCopy().Spec.SnapshotLocations,
UnsupportedOverrides: dpa.DeepCopy().Spec.UnsupportedOverrides,
}

ginkgo.RunSpecs(t, "OADP E2E using velero prefix: "+veleroPrefix)
Expand Down
14 changes: 8 additions & 6 deletions tests/e2e/lib/dpa_helpers.go
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@ type DpaCustomResource struct {
BSLBucketPrefix string
VeleroDefaultPlugins []oadpv1alpha1.DefaultPlugin
SnapshotLocations []oadpv1alpha1.SnapshotLocation
UnsupportedOverrides map[oadpv1alpha1.UnsupportedImageKey]string
}

func LoadDpaSettingsFromJson(settings string) (*oadpv1alpha1.DataProtectionApplication, error) {
Expand Down Expand Up @@ -92,6 +93,7 @@ func (v *DpaCustomResource) Build(backupRestoreType BackupRestoreType) *oadpv1al
},
},
},
UnsupportedOverrides: v.UnsupportedOverrides,
}
switch backupRestoreType {
case RESTIC, KOPIA:
Expand All @@ -111,10 +113,7 @@ func (v *DpaCustomResource) Build(backupRestoreType BackupRestoreType) *oadpv1al
dpaSpec.Configuration.Velero.FeatureFlags = append(dpaSpec.Configuration.Velero.FeatureFlags, velero.CSIFeatureFlag)
dpaSpec.SnapshotLocations = nil
}
// Uncomment to override plugin images to use
dpaSpec.UnsupportedOverrides = map[oadpv1alpha1.UnsupportedImageKey]string{
// oadpv1alpha1.VeleroImageKey: "quay.io/konveyor/velero:oadp-1.1",
}

return &dpaSpec
}

Expand Down Expand Up @@ -144,7 +143,6 @@ func (v *DpaCustomResource) CreateOrUpdate(c client.Client, spec *oadpv1alpha1.D
// for debugging
// prettyPrint, _ := json.MarshalIndent(spec, "", " ")
// log.Printf("DPA with spec\n%s\n", prettyPrint)
weshayutin marked this conversation as resolved.
Show resolved Hide resolved

dpa, err := v.Get()
if err != nil {
if apierrors.IsNotFound(err) {
Expand All @@ -155,13 +153,16 @@ func (v *DpaCustomResource) CreateOrUpdate(c client.Client, spec *oadpv1alpha1.D
},
Spec: *spec.DeepCopy(),
}
return v.Create(dpa)
Copy link
Contributor

Choose a reason for hiding this comment

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

All changes from this line on, I think are unnecessary

the workflow is: UnsupportedOverrides will be in json, tests/e2e/e2e_suite_test.go will load the values, line 96 of this file will add values to DPAs created by test run

changes being done on this line on are duplication of was already done in line 96

Copy link
Contributor Author

Choose a reason for hiding this comment

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

You are incorrect. There is duplication in how the tests create the dpa. My addition requires the above. I was also confused about that. DPA creation is handled in two different ways.
Follow the dpa creation from the two points:

  • make test-e2e GINKGO_ARGS="--ginkgo.focus='MySQL application DATAMOVER'"
  • make test-e2e GINKGO_ARGS="--ginkgo.focus='DPA reconciled to true'"

Should we perhaps fix that yes, but it's certainly NOT in scope for this change :) 1 scope per PR.

Copy link
Contributor

Choose a reason for hiding this comment

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

Understood what you want to do, but I do not think this is the correct approach

Since tests here https://github.com/openshift/oadp-operator/blob/d5adc852931f1e23a24c7f0be7f86a27d107ce2d/tests/e2e/dpa_deployment_suite_test.go do not use DpaCustomResource.Build function, you were not seeing UnsupportedOverrides there

But this change breaks this test

ginkgo.Entry("DPA CR with unsupportedOverrides", ginkgo.Label("aws", "ibmcloud"), InstallCase{
DpaSpec: createTestDPASpec(TestDPASpec{
BSLSecretName: bslSecretName,
UnsupportedOverrides: map[oadpv1alpha1.UnsupportedImageKey]string{
"awsPluginImageFqin": "quay.io/konveyor/velero-plugin-for-aws:oadp-1.4",
},
}),
}),

If I export AWS_PLUGIN_IMAGE, or not, the value defined in json will overwrite value defined in test

Copy link
Contributor

Choose a reason for hiding this comment

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

The way I would go with this:

Copy link
Contributor Author

Choose a reason for hiding this comment

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

ok.. thank you for the in depth review! I think I have made the changes you requested, I'm going to push an update and take some time to double check the changes and test.

Copy link
Contributor

Choose a reason for hiding this comment

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

with the current changes, I think you can safely undo changes in lines 156-158 and line 165

the same changes are being applied to line 68 of tests/e2e/dpa_deployment_suite_test.go

dpaPatch := dpa.DeepCopy()
dpaPatch.Spec.UnsupportedOverrides = v.UnsupportedOverrides
return v.Create(dpaPatch)
}
return err
}
dpaPatch := dpa.DeepCopy()
spec.DeepCopyInto(&dpaPatch.Spec)
dpaPatch.ObjectMeta.ManagedFields = nil
dpaPatch.Spec.UnsupportedOverrides = v.UnsupportedOverrides
err = v.Client.Patch(context.Background(), dpaPatch, client.MergeFrom(dpa), &client.PatchOptions{})
if err != nil {
log.Printf("error patching DPA: %s", err)
Expand All @@ -170,6 +171,7 @@ func (v *DpaCustomResource) CreateOrUpdate(c client.Client, spec *oadpv1alpha1.D
}
return err
}

return nil
}

Expand Down
10 changes: 10 additions & 0 deletions tests/e2e/scripts/aws_settings.sh
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,16 @@
cat > $TMP_DIR/oadpcreds <<EOF
{
"spec": {
"unsupportedOverrides": {
"veleroImageFqin": "$VELERO_IMAGE",
"awsPluginImageFqin": "$AWS_PLUGIN_IMAGE",
"openshiftPluginImageFqin": "$OPENSHIFT_PLUGIN_IMAGE",
"azurePluginImageFqin": "$AZURE_PLUGIN_IMAGE",
"gcpPluginImageFqin": "$GCP_PLUGIN_IMAGE",
"resticRestoreImageFqin": "$RESTORE_IMAGE",
"kubevirtPluginImageFqin": "$KUBEVIRT_PLUGIN_IMAGE",
"nonAdminControllerImageFqin": "$NON_ADMIN_IMAGE"
},
"configuration":{
"velero":{
"defaultPlugins": [
Expand Down
10 changes: 10 additions & 0 deletions tests/e2e/scripts/azure_settings.sh
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,16 @@ EOF
cat > $TMP_DIR/oadpcreds <<EOF
{
"spec": {
"unsupportedOverrides": {
"veleroImageFqin": "$VELERO_IMAGE",
"awsPluginImageFqin": "$AWS_PLUGIN_IMAGE",
"openshiftPluginImageFqin": "$OPENSHIFT_PLUGIN_IMAGE",
"azurePluginImageFqin": "$AZURE_PLUGIN_IMAGE",
"gcpPluginImageFqin": "$GCP_PLUGIN_IMAGE",
"resticRestoreImageFqin": "$RESTORE_IMAGE",
"kubevirtPluginImageFqin": "$KUBEVIRT_PLUGIN_IMAGE",
"nonAdminControllerImageFqin": "$NON_ADMIN_IMAGE"
},
"configuration":{
"velero":{
"defaultPlugins": [
Expand Down
10 changes: 10 additions & 0 deletions tests/e2e/scripts/gcp_settings.sh
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,16 @@
cat > $TMP_DIR/oadpcreds <<EOF
{
"spec": {
"unsupportedOverrides": {
"veleroImageFqin": "$VELERO_IMAGE",
"awsPluginImageFqin": "$AWS_PLUGIN_IMAGE",
"openshiftPluginImageFqin": "$OPENSHIFT_PLUGIN_IMAGE",
"azurePluginImageFqin": "$AZURE_PLUGIN_IMAGE",
"gcpPluginImageFqin": "$GCP_PLUGIN_IMAGE",
"resticRestoreImageFqin": "$RESTORE_IMAGE",
"kubevirtPluginImageFqin": "$KUBEVIRT_PLUGIN_IMAGE",
"nonAdminControllerImageFqin": "$NON_ADMIN_IMAGE"
},
"configuration":{
"velero":{
"defaultPlugins": [
Expand Down
10 changes: 10 additions & 0 deletions tests/e2e/scripts/ibmcloud_settings.sh
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,16 @@
cat > $TMP_DIR/oadpcreds <<EOF
{
"spec": {
"unsupportedOverrides": {
"veleroImageFqin": "$VELERO_IMAGE",
"awsPluginImageFqin": "$AWS_PLUGIN_IMAGE",
"openshiftPluginImageFqin": "$OPENSHIFT_PLUGIN_IMAGE",
"azurePluginImageFqin": "$AZURE_PLUGIN_IMAGE",
"gcpPluginImageFqin": "$GCP_PLUGIN_IMAGE",
"resticRestoreImageFqin": "$RESTORE_IMAGE",
"kubevirtPluginImageFqin": "$KUBEVIRT_PLUGIN_IMAGE",
"nonAdminControllerImageFqin": "$NON_ADMIN_IMAGE"
},
"configuration":{
"velero":{
"defaultPlugins": [
Expand Down
10 changes: 10 additions & 0 deletions tests/e2e/scripts/openstack_settings.sh
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,16 @@
cat > $TMP_DIR/oadpcreds <<EOF
{
"spec": {
"unsupportedOverrides": {
"veleroImageFqin": "$VELERO_IMAGE",
"awsPluginImageFqin": "$AWS_PLUGIN_IMAGE",
"openshiftPluginImageFqin": "$OPENSHIFT_PLUGIN_IMAGE",
"azurePluginImageFqin": "$AZURE_PLUGIN_IMAGE",
"gcpPluginImageFqin": "$GCP_PLUGIN_IMAGE",
"resticRestoreImageFqin": "$RESTORE_IMAGE",
"kubevirtPluginImageFqin": "$KUBEVIRT_PLUGIN_IMAGE",
"nonAdminControllerImageFqin": "$NON_ADMIN_IMAGE"
},
"configuration":{
"velero":{
"defaultPlugins": [
Expand Down