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

[flaky test] Move DetectName to method in alizer package #6093

Conversation

feloy
Copy link
Contributor

@feloy feloy commented Sep 5, 2022

What type of PR is this:

/kind bug

What does this PR do / why we need it:

Move the DetectName function to a method in the pkg/alizer method, to be able to mock it from pkg/init/backend package

Which issue(s) this PR fixes:

Fixes #6092

PR acceptance criteria:

  • Unit test

  • Integration test

  • Documentation

How to test changes / Special notes to the reviewer:

@openshift-ci openshift-ci bot added the kind/bug Categorizes issue or PR as related to a bug. label Sep 5, 2022
@netlify
Copy link

netlify bot commented Sep 5, 2022

Deploy Preview for odo-docusaurus-preview canceled.

Name Link
🔨 Latest commit f2cd220
🔍 Latest deploy log https://app.netlify.com/sites/odo-docusaurus-preview/deploys/6315cf025cc42c000963213e

@odo-robot
Copy link

odo-robot bot commented Sep 5, 2022

Unit Tests on commit 06bbff9 finished successfully.
View logs: TXT HTML

@odo-robot
Copy link

odo-robot bot commented Sep 5, 2022

Validate Tests on commit 06bbff9 finished successfully.
View logs: TXT HTML

@odo-robot
Copy link

odo-robot bot commented Sep 5, 2022

Kubernetes Tests on commit 06bbff9 finished successfully.
View logs: TXT HTML

@odo-robot
Copy link

odo-robot bot commented Sep 5, 2022

OpenShift Tests on commit 06bbff9 finished with errors.
View logs: TXT HTML

@feloy feloy changed the title Move DetectName to method in alizer package [flaky test] Move DetectName to method in alizer package Sep 5, 2022
@valaparthvi
Copy link
Contributor

Did you figure out why this test passes when run individually but fails in a batch?

@feloy
Copy link
Contributor Author

feloy commented Sep 6, 2022

Did you figure out why this test passes when run individually but fails in a batch?

Not exactly, but the unit test were working on the real filesystem and calling the alizer library, because the DetectName were not mocked. This is what we want to avoid for unit tests

Copy link
Member

@rm3l rm3l left a comment

Choose a reason for hiding this comment

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

Thanks for fixing this issue 👍🏿

@openshift-ci openshift-ci bot added the lgtm Indicates that a PR is ready to be merged. Required by Prow. label Sep 6, 2022
@@ -57,7 +57,8 @@ func GatherName(contextDir string, devfileObj *parser.DevfileObj) (string, error
// Use Alizer if Devfile has no (optional) metadata.name field.
// We need to pass in the Devfile base directory (not the path to the devfile.yaml).
// Name returned by alizer.DetectName is expected to be already sanitized.
return alizer.DetectName(filepath.Dir(devfileObj.Ctx.GetAbsPath()))
alizerClient := alizer.Alizer{} // TODO(feloy) fix with DI
Copy link
Contributor

Choose a reason for hiding this comment

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

I am not sure how this will be fixed with DI given that GatherName is called from context pkg. A simpler solution that I can think of, is to let DetectName be a function, and let DetectName method call the function, that way it can still be mocked without having to fix this with DI.

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 prefer not to, or future developers will be tempted to call the function, even if the method could be called

@valaparthvi
Copy link
Contributor

/approve

@openshift-ci openshift-ci bot added the approved Indicates a PR has been approved by an approver from all required OWNERS files. Required by Prow. label Sep 6, 2022
@feloy
Copy link
Contributor Author

feloy commented Sep 6, 2022

Re-run with new names

@feloy feloy closed this Sep 6, 2022
@feloy feloy reopened this Sep 6, 2022
@sonarqubecloud
Copy link

sonarqubecloud bot commented Sep 6, 2022

Kudos, SonarCloud Quality Gate passed!    Quality Gate passed

Bug A 0 Bugs
Vulnerability A 0 Vulnerabilities
Security Hotspot A 0 Security Hotspots
Code Smell A 1 Code Smell

No Coverage information No Coverage information
0.0% 0.0% Duplication

@valaparthvi
Copy link
Contributor

/approve

@openshift-ci
Copy link

openshift-ci bot commented Sep 6, 2022

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: valaparthvi

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:

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

@feloy
Copy link
Contributor Author

feloy commented Sep 6, 2022

/override OpenShift-Integration-tests/OpenShift-Integration-tests
Passed with old name, failure on e2e tests, due to missing resources (timeout 180s)?

@openshift-ci
Copy link

openshift-ci bot commented Sep 6, 2022

@feloy: Overrode contexts on behalf of feloy: OpenShift-Integration-tests/OpenShift-Integration-tests

In response to this:

/override OpenShift-Integration-tests/OpenShift-Integration-tests
Passed with old name, failure on e2e tests, due to missing resources (timeout 180s)?

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/test-infra repository.

@feloy
Copy link
Contributor Author

feloy commented Sep 6, 2022

/override ci/prow/v4.10-integration-e2e
Tests pass on IBM Cloud

@openshift-ci
Copy link

openshift-ci bot commented Sep 6, 2022

@feloy: Overrode contexts on behalf of feloy: ci/prow/v4.10-integration-e2e

In response to this:

/override ci/prow/v4.10-integration-e2e
Tests pass on IBM Cloud

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/test-infra repository.

@openshift-merge-robot openshift-merge-robot merged commit 3add393 into redhat-developer:main Sep 6, 2022
cdrage pushed a commit to cdrage/odo that referenced this pull request Sep 7, 2022
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. Required by Prow. kind/bug Categorizes issue or PR as related to a bug. lgtm Indicates that a PR is ready to be merged. Required by Prow.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Flaky unit test
4 participants