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

[BUG] get_keystore test using absolute path #773

Closed
abbyhu2000 opened this issue Sep 9, 2021 · 3 comments · Fixed by #3854
Closed

[BUG] get_keystore test using absolute path #773

abbyhu2000 opened this issue Sep 9, 2021 · 3 comments · Fixed by #3854
Assignees
Labels
bug Something isn't working ci good first issue Good for newcomers hacktoberfest Global event that encourages people to contribute to open-source. help wanted Community development is encouraged technical debt If not paid, jeapardizes long-term success and maintainability of the repository.

Comments

@abbyhu2000
Copy link
Member

Describe the bug
Get_keystone checks if the path contains the word 'config'. However, if we have a branch with a name including the word 'config', the get_keystone test will fail on Jenkins because it is taking the branch name to create a new folder and validate against the absolute path. We should not test against an absolute path because we should only care about what is within the opensearch dashboard application but not the path outside of opensearch dashboards.

To Reproduce
Steps to reproduce the behavior:

  1. Create a branch and name it with the word 'config'
  2. Go to Jenkins
  3. Build
  4. See error log under unit test: get_keystore test failed

Screenshots
Screen Shot 2021-09-08 at 6 26 11 PM

@abbyhu2000 abbyhu2000 added bug Something isn't working untriaged labels Sep 9, 2021
@kavilla kavilla added good first issue Good for newcomers help wanted Community development is encouraged and removed untriaged labels Sep 10, 2021
@tmarkley tmarkley added the ci label Sep 23, 2021
@tmarkley tmarkley added the technical debt If not paid, jeapardizes long-term success and maintainability of the repository. label May 25, 2022
@joshuarrrr joshuarrrr added the hacktoberfest Global event that encourages people to contribute to open-source. label Oct 4, 2022
@Aigerim-ai
Copy link
Contributor

Hi can I take this issue?

@Aigerim-ai
Copy link
Contributor

Hi @abbyhu2000, How can I "go to Jenkins"? Do I need specific repository to run?

@abbyhu2000
Copy link
Member Author

Hi @Aigerim-ai, Jenkins is used to be the main automation tool for our CICD. It might be difficult for you to access our Jenkin pipeline. However, you can still finish this task without using Jenkin.

The problematic unit tests are below in src/cli_keystore/get_keystore.test.js. If you read the function getKeystore() in src/cli_keystore/get_keystore.js, the rules are pretty simple. If there is a existing data keystore, we return data keystore path; if not, we return the config keystore path. However, the unit tests here are just using toContain('config') and toContain('data') to verify if the function is returning the correct path. It assumes that if the path contains the word 'config', then the function correctly returns the config keystore file path; and vise versa.

Instead of assuming this, could you rewrite the following two unit tests so they are actually checking the function getKeystore() returns the correct file path of either data keystore or config keystore?

  it('uses the config directory if there is no pre-existing keystore', () => {
    sandbox.stub(fs, 'existsSync').returns(false);
    expect(getKeystore()).toContain('config');
    console.log(getKeystore())
    expect(getKeystore()).not.toContain('data');
  });

  it('uses the data directory if there is a pre-existing keystore in the data directory', () => {
    sandbox.stub(fs, 'existsSync').returns(true);
    expect(getKeystore()).toContain('data');
    console.log(getKeystore())
    expect(getKeystore()).not.toContain('config');
  });

Aigerim-ai added a commit to Aigerim-ai/OpenSearch-Dashboards-temporary that referenced this issue Apr 16, 2023
Aigerim-ai added a commit to Aigerim-ai/OpenSearch-Dashboards-temporary that referenced this issue Apr 17, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working ci good first issue Good for newcomers hacktoberfest Global event that encourages people to contribute to open-source. help wanted Community development is encouraged technical debt If not paid, jeapardizes long-term success and maintainability of the repository.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

5 participants