-
Notifications
You must be signed in to change notification settings - Fork 917
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] Remove unit test case in zip.test.js #540
Conversation
✅ DCO Check Passed 86aa36b |
✅ DCO Check Passed 3112862 |
Maybe we should be questioning the actual expectations of the test. If we merely want to ensure that one file is executable and another isn't for everyone, we don't need to match exact file permissions. For example, should we also accept write and execute permissions with I think we should make the name of the test less vague and refactor so that it's not environment specific. |
After investigation and discussion, I suggest to remove this specific test case. getMode function is system env dependent. Remove path.resolve won't work:
The above test has same result. The meaning of this test case is to test whether extractArchive function extract files with same permission when they archive:
It should not dependent on system env. Under this test suite, the getMode function can not test this and there is no other easy way to test mode in this test case. I will remove the test case for now and will open an issue. |
✅ DCO Check Passed dd1bf77 |
Follow up issue: #561 |
Can you update the title and description since the test is now being removed? |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
When squashing please make sure the commit message references that we just removed this test, otherwise if it gets merged with the titled it will be confusing when looking at the history.
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. After unzip executable has mode 777 and not-executable has mode 644. These two numbers are fixed. They are not dependent on diff system or folder mode where you unzip the files. However, the following two results: path.resolve(tempPath,'executable') path.resolve(tempPath,’not-executable') are dependent on tempPath mode because it will use the lower mode. For example (use mode# directly below): 1)If tempPath is 775 then: path.resolve(775, 777) —> 775 path.resolve(775, 644) —> 644 2)If tempPath is 755 then: path.resolve(755, 777) —> 755 path.resolve(755, 644) —> 644 Therefore, this unit test case result is dependent on the mode of tempPath which is affected by your system or system settings. After investigation and discussion, this PR remove this specific test case. The meaning of this test case is to test whether extractArchive function extract files with same permission when they archive. However, getMode function in this test suite is system env dependent which doesn’t serve the purpose of this test case. Since it is a broken test, we will remove this one and open an issue to investigate alternative ways to check file mode. Issues resolved: opensearch-project#4 Signed-off-by: Anan Zhuang <[email protected]>
✅ DCO Check Passed 304372d |
Done. Thanks for reminding me. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM, thanks for updating the details!
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. After unzip executable has mode 777 and not-executable has mode 644. These two numbers are fixed. They are not dependent on diff system or folder mode where you unzip the files. However, the following two results: path.resolve(tempPath,'executable') path.resolve(tempPath,’not-executable') are dependent on tempPath mode because it will use the lower mode. For example (use mode# directly below): 1)If tempPath is 775 then: path.resolve(775, 777) —> 775 path.resolve(775, 644) —> 644 2)If tempPath is 755 then: path.resolve(755, 777) —> 755 path.resolve(755, 644) —> 644 Therefore, this unit test case result is dependent on the mode of tempPath which is affected by your system or system settings. After investigation and discussion, this PR remove this specific test case. The meaning of this test case is to test whether extractArchive function extract files with same permission when they archive. However, getMode function in this test suite is system env dependent which doesn’t serve the purpose of this test case. Since it is a broken test, we will remove this one and open an issue to investigate alternative ways to check file mode. Issues resolved: #4 Signed-off-by: Anan Zhuang <[email protected]>
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. After unzip executable has mode 777 and not-executable has mode 644. These two numbers are fixed. They are not dependent on diff system or folder mode where you unzip the files. However, the following two results: path.resolve(tempPath,'executable') path.resolve(tempPath,’not-executable') are dependent on tempPath mode because it will use the lower mode. For example (use mode# directly below): 1)If tempPath is 775 then: path.resolve(775, 777) —> 775 path.resolve(775, 644) —> 644 2)If tempPath is 755 then: path.resolve(755, 777) —> 755 path.resolve(755, 644) —> 644 Therefore, this unit test case result is dependent on the mode of tempPath which is affected by your system or system settings. After investigation and discussion, this PR remove this specific test case. The meaning of this test case is to test whether extractArchive function extract files with same permission when they archive. However, getMode function in this test suite is system env dependent which doesn’t serve the purpose of this test case. Since it is a broken test, we will remove this one and open an issue to investigate alternative ways to check file mode. Issues resolved: #4 Signed-off-by: Anan Zhuang <[email protected]>
Description
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.
After unzip executable has mode 777 and not-executable has mode 644. These two numbers are fixed. They are not dependent on diff system or folder mode where you unzip the files. However, the following two results:
are dependent on tempPath mode because it will use the lower mode. For example (use mode# directly below):
1)If tempPath is 775 then:
2)If tempPath is 755 then:
To verify by yourself, you could change
getMode
function and for example pass it a 755:getMode = (path) => (fs.statSync(path).mode & parseInt('755’, 8)).toString(8);
Then in the test case, console log the mode of tempPath and test result:
Therefore, this unit test case result is dependent on the mode of tempPath which is affected by your system or system settings.
This PR investigats the issue and remove todo. We have two options: 1) Our Jenkins test env has 755 for tempPath (see below image). So we could enable this test case without any changes. Customer might fail this test locally and can manually skip this test.
Option2: Force the tempPath mode to be 755 by changing:
However, this assumes customer's env will generate a tempPath either 755 or 775, which does not guaranteed that this test case won't fail again locally.
Option3: Remove this test case and open a new issue to investigate alternative ways to write this test case
This PR uses option 3. The meaning of this test case is to test whether extractArchive function extract files with same
permission when they archive. However, getMode function in this test suite is system env dependent which doesn’t serve the purpose of this test case.
Signed-off-by: Anan Zhuang [email protected]
Issues Resolved
#4
Test results
unit test for zip.test.js
Overall test result:
Check List