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

Updated integ-tests implementation to run all the OSD plugins. #3316

Merged
merged 1 commit into from
May 4, 2023

Conversation

Divyaasm
Copy link
Collaborator

Signed-by: [email protected]

Fix to issue #2144

Description

-Made changes to run OSD plugins altogether or individually using --component arg.
-OSD integtests when triggered from buildrepo are now executed via opensearch-dashboards-functional-test repo.
-Updated test-cases accordingly.

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-commenter
Copy link

codecov-commenter commented Mar 16, 2023

Codecov Report

Merging #3316 (305a8ab) into main (9720afd) will decrease coverage by 0.32%.
The diff coverage is 55.55%.

📣 This organization is not using Codecov’s GitHub App Integration. We recommend you install it so Codecov can continue to function properly for your repositories. Learn more

@@            Coverage Diff             @@
##             main    #3316      +/-   ##
==========================================
- Coverage   91.74%   91.42%   -0.32%     
==========================================
  Files         172      172              
  Lines        4991     5017      +26     
==========================================
+ Hits         4579     4587       +8     
- Misses        412      430      +18     
Impacted Files Coverage Δ
...workflow/integ_test/integ_test_suite_opensearch.py 65.85% <27.27%> (-26.15%) ⬇️
src/test_workflow/integ_test/integ_test_suite.py 94.00% <50.00%> (+8.28%) ⬆️
...teg_test/integ_test_suite_opensearch_dashboards.py 95.31% <89.28%> (-4.69%) ⬇️

@Divyaasm Divyaasm changed the title Updated integ-tests implementation to all the run OSD plugins. Updated integ-tests implementation to run all the OSD plugins. Mar 16, 2023
Copy link
Member

@gaiksaya gaiksaya left a comment

Choose a reason for hiding this comment

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

I believe the methods need to be separated into child classes due to -t option. It only applies to dashboards and not opensearch.

@@ -114,7 +116,8 @@ def custom_node_endpoint_encoder(node_endpoint: NodeEndpoint) -> dict:

def execute_integtest_sh(self, endpoint: str, port: int, security: bool, test_config: str) -> int:
cluster_endpoint_port = [ClusterEndpoint("cluster1", [NodeEndpoint(endpoint, port, 9300)], [])]
return self.multi_execute_integtest_sh(cluster_endpoint_port, security, test_config)
script = ScriptFinder.find_integ_test_script("functionalTestDashboards", "https://github.com/opensearch-project/opensearch-dashboards-functional-test.git")
Copy link
Member

Choose a reason for hiding this comment

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

This will break for opensearch plugins. functional test only applies to dashboards. Also the I don't see ref anywhere, this will by default clone main. You need to get the repo link and ref from input manifest, https://github.com/opensearch-project/opensearch-build/blob/main/manifests/2.6.0/opensearch-dashboards-2.6.0.yml#L13-L15

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

I see the function execute_integtest_sh in used only for OSD which calls multi_execute_integtest_sh, whereas OS directly uses multi_execute_integtest_sh.

Copy link
Member

Choose a reason for hiding this comment

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

Yeah we need to change that behavior. Can you fix that as well? Adding @peterzhuamazon @prudhvigodithi for more input

Copy link
Member

Choose a reason for hiding this comment

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

Use the git lib in build repo to checkout ftrepo, do not need to use a find script call like this, because if cwd already have ftrepo content, you can just call the find script for integtest.sh and it will find it in root.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Sure Peter, started working on this change. Trying to fetch the integtest.sh from ftrepo based on ref branch from input manifest.

if os.path.exists(script):
if len(cluster_endpoints) == 1:
single_data_node = cluster_endpoints[0].data_nodes[0]
cmd = f"bash {script} -b {single_data_node.endpoint} -p {single_data_node.port} -s {str(security).lower()} -v {self.bundle_manifest.build.version}"
cmd = f"bash {script} -b {single_data_node.endpoint} -p {single_data_node.port} -s {str(security).lower()} -t {self.component.name} -v {self.bundle_manifest.build.version}"
Copy link
Member

Choose a reason for hiding this comment

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

This is again not true for opensearch components,

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

I can make multi_execute_integtest_sh abstract and implement it separately for OS and OSD.

Copy link
Member

Choose a reason for hiding this comment

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

Just use a filter to remove -t if not needed.

Copy link
Member

Choose a reason for hiding this comment

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

Another problem is what if user does not enter any component, then it should default run everything in the yml. Therefore, you method might not work as it will include ftrepo as a component to run.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Hey @peterzhuamazon , the plan is to implement the multi_execute_integtest_sh in the child classes for OS and OSD. If that's the case I think the implementaion works well for OS too, let me know if I just need to add a filter to remove -t instead of having different implementations OS and OSD.

Currently I can see the tests are running sequentially for all OSD and OS plugins in yml if we do not provide --component names.

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 @Divyaasm,
Some comments here.
Thanks.

if os.path.exists(script):
if len(cluster_endpoints) == 1:
single_data_node = cluster_endpoints[0].data_nodes[0]
cmd = f"bash {script} -b {single_data_node.endpoint} -p {single_data_node.port} -s {str(security).lower()} -v {self.bundle_manifest.build.version}"
cmd = f"bash {script} -b {single_data_node.endpoint} -p {single_data_node.port} -s {str(security).lower()} -t {self.component.name} -v {self.bundle_manifest.build.version}"
Copy link
Member

Choose a reason for hiding this comment

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

Just use a filter to remove -t if not needed.

@@ -114,7 +116,8 @@ def custom_node_endpoint_encoder(node_endpoint: NodeEndpoint) -> dict:

def execute_integtest_sh(self, endpoint: str, port: int, security: bool, test_config: str) -> int:
cluster_endpoint_port = [ClusterEndpoint("cluster1", [NodeEndpoint(endpoint, port, 9300)], [])]
return self.multi_execute_integtest_sh(cluster_endpoint_port, security, test_config)
script = ScriptFinder.find_integ_test_script("functionalTestDashboards", "https://github.com/opensearch-project/opensearch-dashboards-functional-test.git")
Copy link
Member

Choose a reason for hiding this comment

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

Use the git lib in build repo to checkout ftrepo, do not need to use a find script call like this, because if cwd already have ftrepo content, you can just call the find script for integtest.sh and it will find it in root.

@@ -87,7 +88,8 @@ def __setup_cluster_and_execute_test_config(self, config: str) -> int:
) as (endpoints):
os.chdir(self.work_dir)
self.pretty_print_message("Running integration tests for " + self.component.name + " " + config)
return self.multi_execute_integtest_sh(endpoints, security, config)
script = ScriptFinder.find_integ_test_script(self.component.name, self.repo.working_directory)
Copy link
Member

Choose a reason for hiding this comment

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

Why do we need to call the scriptfinder here?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

To make sure I separate the ftrepo clone for dashboards, Will change it back in the child class implementations.

if os.path.exists(script):
if len(cluster_endpoints) == 1:
single_data_node = cluster_endpoints[0].data_nodes[0]
cmd = f"bash {script} -b {single_data_node.endpoint} -p {single_data_node.port} -s {str(security).lower()} -v {self.bundle_manifest.build.version}"
cmd = f"bash {script} -b {single_data_node.endpoint} -p {single_data_node.port} -s {str(security).lower()} -t {self.component.name} -v {self.bundle_manifest.build.version}"
Copy link
Member

Choose a reason for hiding this comment

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

Another problem is what if user does not enter any component, then it should default run everything in the yml. Therefore, you method might not work as it will include ftrepo as a component to run.

@peterzhuamazon
Copy link
Member

peterzhuamazon commented Mar 17, 2023

Have offline discussion with @Divyaasm on this and there are several issues:

  1. The ftrepo is not checked out at all as the initial implementation assuming only components within the manifest get checked out, so removing it from the manifest would cause it not to be checked out and actually trying to use the default gradle integtest to run cypress OSD test.
  2. @Divyaasm will do a filter none check before sending the component to -t. So that we can make sure the component has value before using -t, else remove.
    https://github.com/dblock/opensearch-build/blob/8babdde32e2262b9e2de3e3672daa198bef74c4f/src/build_workflow/builder_from_source.py#L48
  3. Refine how the script finder is called once ftrepo is checked out.
Service is available
2023-03-17 18:43:05 INFO     ===============================================
2023-03-17 18:43:05 INFO     Running integration tests for customImportMapDashboards
2023-03-17 18:43:05 INFO     ===============================================
2023-03-17 18:43:05 INFO     Executing "bash /local/home/divyaasm/divyaasm/opensearch-build/scripts/default/integtest.sh -b localhost -p 5601 -s true -t customImportMapDashboards -v 2.6.0" in /tmp/tmpv4kasw4_/customImportMapDashboards
2023-03-17 18:43:05 INFO     Recording component test results for customImportMapDashboards at /local/home/divyaasm/divyaasm/opensearch-build/test-results/2e5262448e9e454cb9790bc9892f6415/integ-test/customImportMapDashboards/with-security/test-results
2023-03-17 18:43:05 INFO     Sending SIGKILL to PID 27123
2023-03-17 18:43:05 INFO     Process killed with exit code None
2023-03-17 18:43:05 INFO     Cleanup /tmp/tmpv4kasw4_/local-test-cluster/* content after the test
2023-03-17 18:43:06 INFO     Sending SIGKILL to PID 27241
2023-03-17 18:43:06 INFO     Process killed with exit code None
2023-03-17 18:43:06 INFO     Cleanup /tmp/tmpv4kasw4_/local-test-cluster/* content after the test
2023-03-17 18:43:06 INFO     Recording local cluster logs for customImportMapDashboards with test configuration as with-security at /local/home/divyaasm/divyaasm/opensearch-build/test-results/2e5262448e9e454cb9790bc9892f6415/integ-test/customImportMapDashboards/with-security/local-cluster-logs
2023-03-17 18:43:06 INFO     Recording local cluster logs for customImportMapDashboards with test configuration as with-security at /local/home/divyaasm/divyaasm/opensearch-build/test-results/2e5262448e9e454cb9790bc9892f6415/integ-test/customImportMapDashboards/with-security/local-cluster-logs
2023-03-17 18:43:06 INFO     opensearch distribution: tar
2023-03-17 18:43:06 INFO     opensearch-dashboards distribution: tar
2023-03-17 18:43:06 INFO     Downloading bundle artifact
2023-03-17 18:43:06 INFO     Downloading https://ci.opensearch.org/ci/dbc/distribution-build-opensearch-dashboards/2.6.0/5520/linux/x64/tar/dist/opensearch-dashboards/opensearch-dashboards-2.6.0-linux-x64.tar.gz into /tmp/tmpv4kasw4_/local-test-cluster/opensearch-dashboards-2.6.0-linux-x64.tar.gz ...
2023-03-17 18:43:07 INFO     Downloaded bundle to /tmp/tmpv4kasw4_/local-test-cluster/opensearch-dashboards-2.6.0-linux-x64.tar.gz
2023-03-17 18:43:07 INFO     Installing /tmp/tmpv4kasw4_/local-test-cluster/opensearch-dashboards-2.6.0-linux-x64.tar.gz in /tmp/tmpv4kasw4_/local-test-cluster/opensearch-dashboards-2.6.0
Removing securityDashboards...
Plugin removal complete
2023-03-17 18:43:30 INFO   

Thanks.

Copy link
Member

@gaiksaya gaiksaya left a comment

Choose a reason for hiding this comment

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

Looks good, Some minor improvements.

@@ -81,6 +94,38 @@ def __setup_cluster_and_execute_test_config(self, config: str) -> int:
os.chdir(self.work_dir)
return self.execute_integtest_sh(endpoint, port, security, config)

def multi_execute_integtest_sh(self, cluster_endpoints: list, security: bool, test_config: str) -> int:
script = ScriptFinder.find_integ_test_script(self.component.name, self.repo.working_directory)
Copy link
Member

Choose a reason for hiding this comment

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

Add tests for this asserting that self.repo is always functionalTestDashboards for opensearch dashboards

Comment on lines 59 to 60
build_manifest_opensearch_dashboards.components["functionalTestDashboards"].repository,
build_manifest_opensearch_dashboards.components["functionalTestDashboards"].commit_id,
Copy link
Member

Choose a reason for hiding this comment

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

nit: Use single quotes

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Sure Sayali

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 @Divyaasm ,

Some good improvements, just some nits.

Thanks.

@peterzhuamazon
Copy link
Member

Thanks @Divyaasm this is a great addition to OSD test so that it can run parallel like OS test.

return {"endpoint": node_endpoint.endpoint, "port": node_endpoint.port, "transport": node_endpoint.transport}
if os.path.exists(script):
single_node = cluster_endpoints[0].data_nodes[0]
cmd = f"bash {script} -b {single_node.endpoint} -p {single_node.port} -s {str(security).lower()} -t {self.component.name} -v {self.bundle_manifest.build.version}"
Copy link
Collaborator Author

@Divyaasm Divyaasm Apr 20, 2023

Choose a reason for hiding this comment

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

Hi @tianleh , seems there is an issue in running integtests when -t is passed from python code base @line 107.
This command which is executed inside the cloned ftrepo is running integtests for all the components instead of the specified component.

Copy link
Member

Choose a reason for hiding this comment

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

Checked with @peterzhuamazon . Please raise the PR to FTRep once ready.

@rishabh6788
Copy link
Collaborator

How about we introduce a new parameter, say sub-component that is only acknowledged when the calling class is IntegTestSuiteOpenSearchDashboards.
This way we don't have to have multiple implementations of custom_node_endpoint_encoder method here.

All we need to do would be add a condition to test which sub-class is calling this method and if it comes from IntegTestSuiteOpenSearchDashboards and if a subcomponent has been passed in the argument then add that to the command. We wouldn't have to change anything in the manifests as well.
Since I was debugging the issue with OSD integ test running for all components even after passing the specific component, to test I tried this slightly different approach to achieve this. Here is a draft PR just for the demo purpose.
I am okay with going ahead with the current implementation as well.
Thoughts? @peterzhuamazon @Divyaasm @gaiksaya @dblock

@gaiksaya
Copy link
Member

Thoughts? @peterzhuamazon @Divyaasm @gaiksaya @dblock

The idea is good but the sub-component is actually the component of dashboards product. That's why in order to avoid confusion we went with refactoring the current set up. It is also true that they are sub-components of functional-test repo which is quite confusing but that is just from test perspective. For build workflow, we have similar thing where we build specific components. Wanted to keep the same for test as well.

@rishabh6788
Copy link
Collaborator

The logic is such that if sub-component is passed when running OS integ-test it will be ignored, it will only be acknowledged when the test suite is executed from OSD class.

@gaiksaya
Copy link
Member

The logic is such that if sub-component is passed when running OS integ-test it will be ignored, it will only be acknowledged when the test suite is executed from OSD class.

Yeah got that but again will be confusing for component as well as other teams between components and sub-components for OS and OSD. I am happy to revisit this logic in future. The reason we turnedmulti_execute_integtest_sh into abstract method was because eventually the way integration tests are run for OS and OSD may vary in future as these two are different products. This is the start of diverging path.

Copy link
Collaborator

@rishabh6788 rishabh6788 left a comment

Choose a reason for hiding this comment

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

LGTM!

return {"endpoint": node_endpoint.endpoint, "port": node_endpoint.port, "transport": node_endpoint.transport}
if os.path.exists(script):
single_node = cluster_endpoints[0].data_nodes[0]
cmd = f"bash {script} -b {single_node.endpoint} -p {single_node.port} -s {str(security).lower()} -t {self.component.name} -v {self.bundle_manifest.build.version} -o default"
Copy link
Member

Choose a reason for hiding this comment

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

if self.component.name is empty will the tests still run for all components by default?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

The list of components is fetched here based on input argument --component if that's not passed it runs for all the components in the test manifest. self.component.name has the plugin name and has it's value from the manifest and is not empty in any case.

We alter the plugin names passed to self.component.name based on --component argument to the workflow but run them individually each time with -t component.name as per test manifest.

Copy link
Member

Choose a reason for hiding this comment

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

Thanks! This makes it clear.

Copy link
Member

@gaiksaya gaiksaya left a comment

Choose a reason for hiding this comment

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

I believe opensearch-project/opensearch-dashboards-functional-test#644 needs to go in first before this PR can be merged?

@Divyaasm
Copy link
Collaborator Author

I believe opensearch-project/opensearch-dashboards-functional-test#644 needs to go in first before this PR can be merged?

Yes, and Peter seem to have PR related to integ-test OSD in line

Signed-off-by: Divya Madala <[email protected]>

Changes updated

Signed-off-by: Divya Madala <[email protected]>

add -o parameter

Signed-off-by: Divya Madala <[email protected]>

Updated test cases

Signed-off-by: Divya Madala <[email protected]>
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.

6 participants