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

fix: Refactor E2E tests #1463

Conversation

mateusoliveira43
Copy link
Contributor

@mateusoliveira43 mateusoliveira43 commented Jul 15, 2024

Why the changes were made

  • update envtest version to use same kubernetes version as OCP 4.16
  • remove unnecessary flags from E2E tests
  • resolves Validate BSL/VSL in E2E tests #1288
    • This helped finding bugs around DPA not being properly checked (only check if it is reconciled, and not reconciled true), BSL/VSL being unavailable, BSL/VSL not being cleaned up
  • remove usage of deprecated k8s.io/utils/pointer library
  • transform subscription E2E test in an integration test
  • delete unused objects
  • remove duplication
  • organize objects
  • fix CI flake about restore succeeding, but app route not available

How to test the changes made

Check CI logs and run tests and E2E tests locally.

@openshift-ci openshift-ci bot requested review from mpryc and weshayutin July 15, 2024 17:23
@openshift-ci openshift-ci bot added the approved Indicates a PR has been approved by an approver from all required OWNERS files. label Jul 15, 2024
@mateusoliveira43

This comment was marked as outdated.

@mateusoliveira43

This comment was marked as outdated.

@kaovilai

This comment was marked as outdated.

@kaovilai

This comment was marked as outdated.

Copy link
Contributor

@mrnold mrnold left a comment

Choose a reason for hiding this comment

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

I checked out this branch and ran a successful batch of virtualization tests, no objections from me.

@mateusoliveira43

This comment was marked as outdated.

Makefile Show resolved Hide resolved
@shubham-pampattiwar
Copy link
Member

shubham-pampattiwar commented Jul 22, 2024

Tried running locally, failed for 2 tests, I will retry again:


Summarizing 2 Failures:
  [FAIL] Backup and restore tests Backup and restore applications [It] MySQL application CSI
  /home/shubham/oadp-operator/tests/e2e/backup_restore_suite_test.go:317
  [FAIL] Configuration testing for DPA Custom Resource DPA reconciled to true [It] DPA CR with VSL [aws, azure, gcp]
  /home/shubham/oadp-operator/tests/e2e/dpa_deployment_suite_test.go:147

Ran 24 of 28 Specs in 4910.517 seconds
FAIL! -- 22 Passed | 2 Failed | 0 Pending | 4 Skipped
--- FAIL: TestOADPE2E (4910.87s)
FAIL
You're using deprecated Ginkgo functionality:
=============================================
  --ginkgo.slow-spec-threshold is deprecated --slow-spec-threshold has been deprecated and will be removed in a future version of Ginkgo.  This feature has proved to be more noisy than useful.  You can use --poll-progress-after, instead, to get more actionable feedback about potentially slow specs and understand where they might be getting stuck.

To silence deprecations that can be silenced set the following environment variable:
  ACK_GINKGO_DEPRECATIONS=2.14.0


Ginkgo ran 1 suite in 1h22m25.924794069s

Test Suite Failed
make: *** [Makefile:502: test-e2e] Error 1
shubham@fedora ~/oadp-operator -  (mateus-e2e-refactor) $ 

@@ -24,17 +31,24 @@ func CreateBackupForNamespaces(ocClient client.Client, veleroNamespace, backupNa
SnapshotMoveData: &snapshotMoveData,
},
}
err := ocClient.Create(context.Background(), &backup)
return backup, err
return ocClient.Create(context.Background(), &backup)

Choose a reason for hiding this comment

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

Curious, Why did we do this refactor ?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I was thinking about #1240 to make these functions more simple (but did not change nothing on them, except for not returning a backup and not having backup as a parameter anymore)

@mateusoliveira43
Copy link
Contributor Author

@shubham-pampattiwar do you have the logs of error of each failed test?

@shubham-pampattiwar
Copy link
Member

shubham-pampattiwar commented Jul 22, 2024

I have results only on the one that timed out:

Configuration testing for DPA Custom Resource                                                                                           
/home/shubham/oadp-operator/tests/e2e/dpa_deployment_suite_test.go:130                                                                  
  DPA reconciled to true                                                                                                                
  /home/shubham/oadp-operator/tests/e2e/dpa_deployment_suite_test.go:141                                                                
    DPA CR with VSL [aws, azure, gcp]                                                                                                   
    /home/shubham/oadp-operator/tests/e2e/dpa_deployment_suite_test.go:316                                                              
  > Enter [It] DPA CR with VSL - /home/shubham/oadp-operator/tests/e2e/dpa_deployment_suite_test.go:316 @ 07/19/24 13:36:58.026         
2024/07/19 13:36:58 DPA status is Reconciled: False, reason Error: region for AWS VSL is not configured, please ensure a region is confi
gured                                                                                                                                   
2024/07/19 13:37:03 DPA status is Reconciled: False, reason Error: region for AWS VSL is not configured, please ensure a region is confi
gured                                                                                                                                   
2024/07/19 13:37:08 DPA status is Reconciled: False, reason Error: region for AWS VSL is not configured, please ensure a region is confi
gured                                                                                                                                   
2024/07/19 13:37:13 DPA status is Reconciled: False, reason Error: region for AWS VSL is not configured, please ensure a region is confi
gured                                                                                                                                   
2024/07/19 13:37:18 DPA status is Reconciled: False, reason Error: region for AWS VSL is not configured, please ensure a region is confi
gured                                                                                                                                   
2024/07/19 13:37:23 DPA status is Reconciled: False, reason Error: region for AWS VSL is not configured, please ensure a region is confi
gured                                                                                                                                   
2024/07/19 13:37:28 DPA status is Reconciled: False, reason Error: region for AWS VSL is not configured, please ensure a region is confi
gured                                                                                                                                   
2024/07/19 13:37:33 DPA status is Reconciled: False, reason Error: region for AWS VSL is not configured, please ensure a region is confi
gured                                                                                                                                   
2024/07/19 13:37:38 DPA status is Reconciled: False, reason Error: region for AWS VSL is not configured, please ensure a region is confi
gured                                                                                                                                   
2024/07/19 13:37:43 DPA status is Reconciled: False, reason Error: region for AWS VSL is not configured, please ensure a region is conf$
gured
2024/07/19 13:37:49 DPA status is Reconciled: False, reason Error: region for AWS VSL is not configured, please ensure a region is confi
gured
2024/07/19 13:37:54 DPA status is Reconciled: False, reason Error: region for AWS VSL is not configured, please ensure a region is confi
gured
2024/07/19 13:37:59 DPA status is Reconciled: False, reason Error: region for AWS VSL is not configured, please ensure a region is confi
gured
2024/07/19 13:38:04 DPA status is Reconciled: False, reason Error: region for AWS VSL is not configured, please ensure a region is confi
gured
2024/07/19 13:38:09 DPA status is Reconciled: False, reason Error: region for AWS VSL is not configured, please ensure a region is confi
gured
2024/07/19 13:38:14 DPA status is Reconciled: False, reason Error: region for AWS VSL is not configured, please ensure a region is confi
gured
2024/07/19 13:38:19 DPA status is Reconciled: False, reason Error: region for AWS VSL is not configured, please ensure a region is confi
gured
2024/07/19 13:38:24 DPA status is Reconciled: False, reason Error: region for AWS VSL is not configured, please ensure a region is confi
gured
2024/07/19 13:38:29 DPA status is Reconciled: False, reason Error: region for AWS VSL is not configured, please ensure a region is confi
gured
2024/07/19 13:38:34 DPA status is Reconciled: False, reason Error: region for AWS VSL is not configured, please ensure a region is confi
gured
2024/07/19 13:38:39 DPA status is Reconciled: False, reason Error: region for AWS VSL is not configured, please ensure a region is confi
gured
2024/07/19 13:38:44 DPA status is Reconciled: False, reason Error: region for AWS VSL is not configured, please ensure a region is confi
gured
2024/07/19 13:38:49 DPA status is Reconciled: False, reason Error: region for AWS VSL is not configured, please ensure a region is confi
gured
2024/07/19 13:38:55 DPA status is Reconciled: False, reason Error: region for AWS VSL is not configured, please ensure a region is confi
gured
  [FAILED] Timed out after 120.002s.
  Expected
      <bool>: false
  to be true
  In [It] at: /home/shubham/oadp-operator/tests/e2e/dpa_deployment_suite_test.go:147 @ 07/19/24 13:38:58.179
  < Exit [It] DPA CR with VSL - /home/shubham/oadp-operator/tests/e2e/dpa_deployment_suite_test.go:316 @ 07/19/24 13:38:58.179 (2m0.153s
)

@mateusoliveira43
Copy link
Contributor Author

@shubham-pampattiwar this is because $VSL_REGION env var was not set. We already have docs on that https://github.com/openshift/oadp-operator/blob/master/docs/developer/testing/TESTING.md?plain=1#L39

Signed-off-by: Mateus Oliveira <msouzaol@redhat.com>
Signed-off-by: Mateus Oliveira <msouzaol@redhat.com>
Signed-off-by: Mateus Oliveira <msouzaol@redhat.com>
Signed-off-by: Mateus Oliveira <msouzaol@redhat.com>
Signed-off-by: Mateus Oliveira <msouzaol@redhat.com>
Signed-off-by: Mateus Oliveira <msouzaol@redhat.com>
Signed-off-by: Mateus Oliveira <msouzaol@redhat.com>
Signed-off-by: Mateus Oliveira <msouzaol@redhat.com>
Signed-off-by: Mateus Oliveira <msouzaol@redhat.com>
tests/e2e/lib/flakes.go Outdated Show resolved Hide resolved
Signed-off-by: Mateus Oliveira <msouzaol@redhat.com>
If running E2E tests against operator created from `make deploy-olm`, remember its image expires, which may cause **Subscription Config Suite Test** to fail.
If running E2E tests against operator created from `make deploy-olm`, remember its image expires, which may cause tests to fail.

When running Virtual Machine backup/restore tests on IBM Cloud, it is better to manually install OpenShift Virtualization operator, instead of automatically installing it through `make test-e2e`. Because this may cause the error of Virtual Machines never starting to run. Example test log:
Copy link
Member

Choose a reason for hiding this comment

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

Is it fixable? Let's open an issue?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

the virt test checks if virt operator is installed https://github.com/openshift/oadp-operator/blob/master/tests/e2e/virt_backup_restore_suite_test.go#L142

if yes, continues; otherwise, installs and configure it for you

Copy link
Contributor

Choose a reason for hiding this comment

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

It could also patch the StorageProfile automatically, but for now I guess manual setup is the only way to make it work. I can work on this in another pull request.

Signed-off-by: Mateus Oliveira <msouzaol@redhat.com>
Copy link
Member

@kaovilai kaovilai left a comment

Choose a reason for hiding this comment

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

lgtm

for followup


// Subscription Config environment variables are passed to controller-manager Pod
// https://github.com/operator-framework/operator-lifecycle-manager/blob/d8500d88932b17aa9b1853f0f26086f6ee6b35f9/doc/design/subscription-config.md
os.Setenv(scenario.envVar.Name, scenario.envVar.Value)
Copy link
Member

Choose a reason for hiding this comment

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

Would be cool if this could undo the setenv

    originalValue, _ := os.LookupEnv("MY_VAR") // Store original value (if exists)
    defer func() {
        if originalValue != "" {
            os.Setenv("MY_VAR", originalValue) // Restore original value
        } else {
            os.Unsetenv("MY_VAR")             // Remove if newly created
        }
    }()

    os.Setenv("MY_VAR", "new_value")

Copy link
Member

Choose a reason for hiding this comment

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

This was not as necessary in subscription suite test e2e because env is set in operator controller pod.

Now this is a unit test, setting env here could maybe change current terminal env and break things like git which reads from env proxy settings.

Copy link
Contributor Author

Choose a reason for hiding this comment

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


// Subscription Config environment variables are passed to controller-manager Pod
// https://github.com/operator-framework/operator-lifecycle-manager/blob/d8500d88932b17aa9b1853f0f26086f6ee6b35f9/doc/design/subscription-config.md
os.Setenv(scenario.envVar.Name, scenario.envVar.Value)
Copy link
Member

Choose a reason for hiding this comment

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

    originalValue, _ := os.LookupEnv("MY_VAR") // Store original value (if exists)
    defer func() {
        if originalValue != "" {
            os.Setenv("MY_VAR", originalValue) // Restore original value
        } else {
            os.Unsetenv("MY_VAR")             // Remove if newly created
        }
    }()

    os.Setenv("MY_VAR", "new_value")

kaovilai
kaovilai previously approved these changes Jul 25, 2024
Signed-off-by: Mateus Oliveira <msouzaol@redhat.com>
Copy link

openshift-ci bot commented Jul 25, 2024

@mateusoliveira43: all tests passed!

Full PR test history. Your PR dashboard.

Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes-sigs/prow repository. I understand the commands that are listed here.

@sseago
Copy link
Contributor

sseago commented Jul 25, 2024

/lgtm

@openshift-ci openshift-ci bot added the lgtm Indicates that a PR is ready to be merged. label Jul 25, 2024
Copy link

openshift-ci bot commented Jul 25, 2024

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: mateusoliveira43, mrnold, shubham-pampattiwar, sseago

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 [mateusoliveira43,mrnold,shubham-pampattiwar,sseago]

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

@openshift-merge-bot openshift-merge-bot bot merged commit b01c0ac into openshift:master Jul 25, 2024
15 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
approved Indicates a PR has been approved by an approver from all required OWNERS files. lgtm Indicates that a PR is ready to be merged.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Validate BSL/VSL in E2E tests
6 participants