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 integ tests for windows platform #3811

Merged
merged 3 commits into from
Jul 26, 2023
Merged

Conversation

zelinh
Copy link
Member

@zelinh zelinh commented Jul 25, 2023

Description

Fixing the current error of unable to remove temp files when terminating the process and also adding UTF-8 encoding when executing the process for results record purpose.

According to the module document for NamedTemporaryFile, the temp file is open when we creating it and it may be supported to re-open it again by its name on Unix but not especially on windows platform.

Also during my testing, the file was still open by python process even after we closed it by the file name.
item is popenfile(path='C:\\Users\\ADMINI~1\\AppData\\Local\\Temp\\2\\tmp2mlahvrq', fd=-1) and proc is psutil.Process(pid=6168, name='python.exe', status='running', started='23:49:13'). Adding the for loop to check if it's closed before we remove it from the system will avoid PermissionError: [WinError 32] The process cannot access the file because it is being used by another process: 'C:\\Users\\ADMINI~1\\AppData\\Local\\Temp\\2\\tmpix2x74us' which caused the issue before.

When the process completed, our current test-recorder is not able to record the stdout.txt for the dashboards on windows because it uses cp1252 for encoding by default and we would get UnicodeDecodeError: 'charmap' codec can't decode byte 0x90 in position 1357: character maps to <undefined>. I am adding utf-8 encoding to the subprocess execution to resolve this.

Sample running tests:
Running on dashboards: ./test.sh integ-test ./manifests/2.8.0/opensearch-dashboards-2.8.0-test.yml -p opensearch=https://ci.opensearch.org/ci/dbc/distribution-build-opensearch/2.8.0/7935/windows/x64/zip opensearch-dashboards=https://ci.opensearch.org/ci/dbc/distribution-build-opensearch-dashboards/2.8.0/6182/windows/x64/zip --test-run-id 1234 --component alertingDashboards

2023-07-24 23:22:58 INFO     | alertingDashboards   | with-security        | PASS  |
2023-07-24 23:22:58 INFO     | alertingDashboards   | without-security     | PASS  |

Running for OpenSearch: ./test.sh integ-test ./manifests/2.8.0/opensearch-2.8.0-test.yml -p opensearch=https://ci.opensearch.org/ci/dbc/distribution-build-opensearch/2.8.0/7935/windows/x64/zip --component alerting --test-run-id 123

2023-07-25 00:17:21 INFO     | alerting             | with-security        | PASS  |
2023-07-25 00:17:21 INFO     | alerting             | without-security     | PASS  |

I have also run integ tests on our linux docker and the back compatibility of the changes is passing.
[opensearch@a49844d86db9 opensearch-build]$ ./test.sh integ-test ./manifests/2.8.0/opensearch-dashboards-2.8.0-test.yml -p opensearch=https://ci.opensearch.org/ci/dbc/distribution-build-opensearch/2.8.0/7935/linux/x64/tar opensearch-dashboards=https://ci.opensearch.org/ci/dbc/distribution-build-opensearch-dashboards/2.8.0/6182/linux/x64/tar --test-run-id 1236 --component mlCommonsDashboards

2023-07-25 00:26:58 INFO     | mlCommonsDashboards  | with-security        | PASS  |
2023-07-25 00:26:58 INFO     | mlCommonsDashboards  | without-security     | PASS  |

Issues Resolved

#3196

By submitting this pull request, I confirm that my contribution is made under the terms of the Apache 2.0 license.
For more information on following Developer Certificate of Origin and signing off your commits, please check here.

@codecov
Copy link

codecov bot commented Jul 25, 2023

Codecov Report

Merging #3811 (235a4b5) into main (6087e36) will increase coverage by 0.06%.
Report is 12 commits behind head on main.
The diff coverage is 92.85%.

@@            Coverage Diff             @@
##             main    #3811      +/-   ##
==========================================
+ Coverage   91.54%   91.61%   +0.06%     
==========================================
  Files         182      182              
  Lines        5420     5438      +18     
==========================================
+ Hits         4962     4982      +20     
+ Misses        458      456       -2     
Files Changed Coverage Δ
src/system/process.py 92.94% <91.66%> (-1.09%) ⬇️
src/system/execute.py 100.00% <100.00%> (ø)
src/test_workflow/test_recorder/test_recorder.py 89.24% <100.00%> (+4.30%) ⬆️

src/system/process.py Show resolved Hide resolved
Comment on lines 70 to 71
except Exception:
pass
Copy link
Member

Choose a reason for hiding this comment

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

In case of exception, do we want to retry/ print / rethrow the exception? Not sure what we are trying to do in this entire try except block.

Copy link
Member Author

Choose a reason for hiding this comment

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

Yeah make sense. Let me add some more for exception handle.

Comment on lines 80 to 86
for proc in psutil.process_iter():
try:
for item in proc.open_files():
if self.stderr.name == item.path:
logging.warning(f"stderr {item} is being used by process with this detail {proc}")
except Exception:
pass
Copy link
Member

Choose a reason for hiding this comment

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

Same as above.

Copy link
Member

@peterzhuamazon peterzhuamazon left a comment

Choose a reason for hiding this comment

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

Hi @zelinh adding some comments here.
Thanks.

src/system/process.py Show resolved Hide resolved
src/system/process.py Outdated Show resolved Hide resolved
src/system/process.py Outdated Show resolved Hide resolved
src/system/execute.py Show resolved Hide resolved
@zelinh zelinh merged commit 53c9ced into opensearch-project:main Jul 26, 2023
@zelinh zelinh deleted the win-integ branch July 26, 2023 18:53
prudhvigodithi pushed a commit to prudhvigodithi/opensearch-build that referenced this pull request Jul 31, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants