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] Unit test case 'verify consistency of modes of files' fails due to file mode #561

Closed
ananzh opened this issue Jun 26, 2021 · 0 comments

Comments

@ananzh
Copy link
Member

ananzh commented Jun 26, 2021

Describe the issue

With existing fixture, test verify consistency of modes of files inside zip.test.js fails. This is due to diff file mode in different system when doing same command or operation. For example, in our ubuntu, when create a file using mkdir cmd, the file mode is 775. But local machine, the file mode is 755.

The two test expectations can be either 775 or 755 depending on file mode of tempPath.

getMode(path.resolve(tempPath,'executable'))
getMode(path.resolve(tempPath,’not-executable'))

The purpose of this test case is to check extractArchive function extract files with same permission when they archive:

expect(getMode('/executable')).toEqual('777');
expect(getMode('/not-executable')).toEqual('644'); 

The test should not dependent on system env. We want to investigate whether there is a better way to test the above case.

More discussions: #540

To Reproduce

  1. restore test case:
    describe('checkFilePermission', () => {
      // TODO:: Verify why zip is not validating correct permission.
      it.skip('verify consistency of modes of files', async () => {
        const archivePath = path.resolve(repliesPath, 'test_plugin.zip');

        await extractArchive(archivePath, tempPath, 'opensearch-dashboards/test-plugin/bin');

        expect(glob.sync('**/*', { cwd: tempPath })).toMatchInlineSnapshot(`
          Array [
            "executable",
            "not-executable",
          ]
        `);

        expect(getMode(path.resolve(tempPath, 'executable'))).toEqual('755');
        expect(getMode(path.resolve(tempPath, 'not-executable'))).toEqual('644');
      });
    });
  1. Run:yarn test:jest {path to zip.test.js}

Expected behavior

Investigate whether this test can be rewrite.

OpenSearch Version
OpenSearch 1.0.0

Dashboards Version
Dashboards 1.0.0

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant