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

New test framework #1967

Merged
merged 47 commits into from
Sep 20, 2022

Conversation

nibix
Copy link
Collaborator

@nibix nibix commented Jul 26, 2022

Signed-Off-By: Nils Bandener [email protected]

Description

This is the first iteration of a new framework for integration tests. The main focus is on conciseness and self-contained test. The framework offers:

  • A programmatic way of defining the cluster setup
  • A programmatic way of defining users and roles
  • A programmatic way of defining indices
  • A REST client with methods tailored for testing

This is now all part of the test class, so you do not need to jump around in various configuration files to get an overview on the test setup. There are of course still a lot of features missing, like setting up test data. I propose to add these features in increments.

The new framework and tests live in a new source folder called "newTest" so they do not interfere with the already existing tests

Check List

  • New functionality includes testing
  • New functionality has been documented
  • Commits are signed per the DCO using --signoff

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.

@nibix nibix requested a review from a team July 26, 2022 15:29
@nibix nibix force-pushed the integration-test-framework branch from 59f136c to 484d72d Compare July 26, 2022 16:23
Copy link
Member

@peternied peternied left a comment

Choose a reason for hiding this comment

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

Some comments after an initial pass, I'll circle back with a complete review

build.gradle Outdated Show resolved Hide resolved
build.gradle Outdated Show resolved Hide resolved
src/newTest/java/org/opensearch/node/PluginAwareNode.java Outdated Show resolved Hide resolved
build.gradle Outdated Show resolved Hide resolved
@peternied
Copy link
Member

Thanks for the contribution, this is a great step forward in how tests are authored in this codebase. I left a lot of feedback, lets work down that list and as we resolve some of those conversations we can checkpoint where this change is at.

@peternied peternied self-assigned this Jul 28, 2022
@davidlago
Copy link

@jochenkressin @lukasz-soszynski-eliatra please amend your commits adding DCO to them, the check is failing. Thanks!

@kt-eliatra kt-eliatra force-pushed the integration-test-framework branch 6 times, most recently from ca1793e to 3995774 Compare August 11, 2022 13:38
@peternied
Copy link
Member

I've reviewed the outstanding comments and resolved a bunch, thanks!

@lukasz-soszynski-eliatra lukasz-soszynski-eliatra force-pushed the integration-test-framework branch 2 times, most recently from 987fdb0 to 88394ec Compare August 17, 2022 09:50
@lukasz-soszynski-eliatra
Copy link
Contributor

@davidlago @peternied
IIRC you mentioned in one of our calls that the CI build has to be run manually. Could you run CI build for me, please?

@peternied
Copy link
Member

@lukasz-soszynski-eliatra the build has run and it looked like it failed https:/opensearch-project/security/runs/7877581013?check_suite_focus=true I believe it will continue to trigger automatically on your fork as well as on this pull request as I have approved it. Let us know if you are seeing any 'waiting for approval' gates.

@lukasz-soszynski-eliatra
Copy link
Contributor

I rebased branch eliatra:integration-test-framework into newest opensearch-project:main yesterday. Could you run build one again in order to check if I solve the last problem, please?

Copy link
Member

@peternied peternied left a comment

Choose a reason for hiding this comment

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

I've resolved a bunch of the previous comments that don't need any updates, great progress. The list of changes is going down, but the inclusive name of cluster manager is still a bigger lingering presence in the code.

build.gradle Show resolved Hide resolved
build.gradle Outdated Show resolved Hide resolved
build.gradle Outdated Show resolved Hide resolved
build.gradle Show resolved Hide resolved
build.gradle Show resolved Hide resolved
@codecov-commenter
Copy link

codecov-commenter commented Aug 19, 2022

Codecov Report

Merging #1967 (67b5446) into main (7f992eb) will decrease coverage by 0.02%.
The diff coverage is 33.33%.

❗ Current head 67b5446 differs from pull request most recent head 6e5e885. Consider uploading reports for the commit 6e5e885 to get more accurate results

@@             Coverage Diff              @@
##               main    #1967      +/-   ##
============================================
- Coverage     60.99%   60.96%   -0.03%     
+ Complexity     3226     3225       -1     
============================================
  Files           256      256              
  Lines         18075    18072       -3     
  Branches       3225     3224       -1     
============================================
- Hits          11024    11017       -7     
- Misses         5472     5476       +4     
  Partials       1579     1579              
Impacted Files Coverage Δ
.../org/opensearch/security/support/PemKeyReader.java 73.38% <20.00%> (-3.38%) ⬇️
...ch/security/securityconf/DynamicConfigFactory.java 56.05% <100.00%> (ø)

Help us with your feedback. Take ten seconds to tell us how you rate us. Have a feature suggestion? Share it here.

@nibix nibix force-pushed the integration-test-framework branch 2 times, most recently from 412f050 to f7e0738 Compare August 25, 2022 10:04
Copy link
Member

@peternied peternied left a comment

Choose a reason for hiding this comment

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

I've created some pull requests for specific updates, which you can take or leave, but there seems to be some kind of warnings that are shown when the tests run that seem like they might indicate there is a problem

@peternied
Copy link
Member

Retriggered the CI - I think we are super close!

kt-eliatra and others added 12 commits September 13, 2022 13:28
Signed-off-by: Kacper Trochimiak <[email protected]>
Signed-Off-By: Nils Bandener <[email protected]>
Removes the following messages from the output:
2022-08-25 12:51:21 SUITE-SecurityRolesTests-seed#[BB25A03A663EB2F7] WARN  Salt:48 - If you plan to use field masking pls configure compliance salt e1ukloTsQlOgPquJ to be a random string of 16 chars length identical on all nodes
2022-08-25 12:51:21 SUITE-SecurityRolesTests-seed#[BB25A03A663EB2F7] ERROR SinkProvider:64 - Default endpoint could not be created, auditlog will not work properly.
2022-08-25 12:51:21 SUITE-SecurityRolesTests-seed#[BB25A03A663EB2F7] WARN  AuditMessageRouter:61 - No default storage available, audit log may not work properly. Please check configuration.

Signed-off-by: Peter Nied <[email protected]>
Signed-Off-By: Nils Bandener <[email protected]>
Signed-Off-By: Nils Bandener <[email protected]>
…y class NodeAndClusterIdConverter during tests execution

Signed-off-by: Lukasz Soszynski <[email protected]>
Copy link
Member

@peternied peternied left a comment

Choose a reason for hiding this comment

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

Last item before we merge is the copyright headers in the test cases files - could you do a quick pass over any files that can remove this since they are net new for this project?

Please do not modify these in any files that have been copied from other codebases.

Signed-Off-By: Nils Bandener <[email protected]>
peternied
peternied previously approved these changes Sep 13, 2022
@peternied
Copy link
Member

@opensearch-project/security Could we have another reviewer take a look?

integrationTestImplementation 'junit:junit:4.13.2'
integrationTestImplementation "org.opensearch.plugin:reindex-client:${opensearch_version}"
integrationTestImplementation "org.opensearch.plugin:percolator-client:${opensearch_version}"
integrationTestImplementation 'commons-io:commons-io:2.11.0'
Copy link
Member

Choose a reason for hiding this comment

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

I'm curious, why do dependencies need to be repeated for integrationTestImplementation if we already have an entry for testImplementation?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

As the goal of the project is the replacement of large parts of the old legacy tests, we want to keep the test definitions as separate as possible.

Copy link
Member

@DarshitChanpura DarshitChanpura left a comment

Choose a reason for hiding this comment

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

Ty so much for this PR!

* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
Copy link
Member

Choose a reason for hiding this comment

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

Does this file come from floragunn repo or is it a new file ? If it is a new file we should remove the floragunn license section

Copy link
Member

Choose a reason for hiding this comment

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

This should also apply to any other files in this PR

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

This is based on code from floragunn

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

This is based on floragunn code.

Copy link
Member

Choose a reason for hiding this comment

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

okay

Copy link
Member

@DarshitChanpura DarshitChanpura Sep 19, 2022

Choose a reason for hiding this comment

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

@lukasz-soszynski-eliatra @nibix Can you please provide the link to the source repo where this is based off of? This would be super helpful to add it to merge-commit

protected final static TestSecurityConfig.User NEGATED_REGEX = new TestSecurityConfig.User("negated_regex_user")
.roles(new Role("negated_regex_role").indexPermissions("read").on("/^[a-z].*/")
.clusterPermissions("cluster_composite_ops"));

Copy link
Member

Choose a reason for hiding this comment

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

Ty for adding this! Can you please add a line or two comment over here explaining the idea behind these tests? I feel it would be helpful to understand as it took me a while

Copy link
Member

Choose a reason for hiding this comment

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

This could be addressed in a separate PR as it isn't a blocking change

Copy link
Member

@DarshitChanpura DarshitChanpura left a comment

Choose a reason for hiding this comment

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

Thank you! Can you please respond to couple of comments above and we will get this merged

@peternied peternied merged commit f591af6 into opensearch-project:main Sep 20, 2022
@peternied
Copy link
Member

This is a giant PR and it has two approvals so I am merging. I know there are some outstanding comments - we can handle outstanding comments asynchronously.

@DarshitChanpura if there are any you are feeling passionate about please create issues for follow up or pull requests to resolve.

vinayak15 pushed a commit to vinayak15/security that referenced this pull request Sep 29, 2022
This is the first iteration of a new framework for integration tests. The main focus is on conciseness and self-contained test. The framework offers:

A programmatic way of defining the cluster setup
A programmatic way of defining users and roles
A programmatic way of defining indices
A REST client with methods tailored for testing

This is now all part of the test class, so you do not need to jump around in various configuration files to get an overview on the test setup. There are of course still a lot of features missing, like setting up test data. I propose to add these features in increments.

Signed-off-by: Nils Bandener <[email protected]>
Signed-off-by: Jochen Kressin <[email protected]>
Signed-off-by: Lukasz Soszynski <[email protected]>
Signed-off-by: Kacper Trochimiak <[email protected]>
Signed-off-by: Nils Bandener <[email protected]>
Signed-off-by: Peter Nied <[email protected]>
Co-authored-by: Jochen Kressin <[email protected]>
Co-authored-by: Lukasz Soszynski <[email protected]>
Co-authored-by: Kacper Trochimiak <[email protected]>
Co-authored-by: Peter Nied <[email protected]>
stephen-crawford pushed a commit to stephen-crawford/security that referenced this pull request Nov 10, 2022
This is the first iteration of a new framework for integration tests. The main focus is on conciseness and self-contained test. The framework offers:

A programmatic way of defining the cluster setup
A programmatic way of defining users and roles
A programmatic way of defining indices
A REST client with methods tailored for testing

This is now all part of the test class, so you do not need to jump around in various configuration files to get an overview on the test setup. There are of course still a lot of features missing, like setting up test data. I propose to add these features in increments.

Signed-off-by: Nils Bandener <[email protected]>
Signed-off-by: Jochen Kressin <[email protected]>
Signed-off-by: Lukasz Soszynski <[email protected]>
Signed-off-by: Kacper Trochimiak <[email protected]>
Signed-off-by: Nils Bandener <[email protected]>
Signed-off-by: Peter Nied <[email protected]>
Co-authored-by: Jochen Kressin <[email protected]>
Co-authored-by: Lukasz Soszynski <[email protected]>
Co-authored-by: Kacper Trochimiak <[email protected]>
Co-authored-by: Peter Nied <[email protected]>
Signed-off-by: Stephen Crawford <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

9 participants