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

Migrations-1015 - Add buildscript for replayer #118

Merged
merged 9 commits into from
Mar 29, 2023

Conversation

okhasawn
Copy link
Contributor

@okhasawn okhasawn commented Mar 9, 2023

Description

This adds a gradle build script file to make it possible to repeatedly build the Traffic Replayer, compiling all java files, run unit tests, checkstyle and spotbugs on the code, all with one command.

You can either run gradle build within the traffic replayer directory, or to do this with a gradle wrapper, then you must run gradle wrapper then run ./gradlew build

Issues Resolved

Migrations-1015

Check List

  • New functionality includes testing
    • All tests pass, including unit test, integration test and doctest
  • 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.

Signed-off-by: Omar Khasawneh <okhasawn@amazon.com>
@codecov-commenter
Copy link

codecov-commenter commented Mar 9, 2023

Codecov Report

Merging #118 (ff51474) into main (f792138) will increase coverage by 91.51%.
The diff coverage is n/a.

📣 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     #118       +/-   ##
=========================================
+ Coverage      0   91.51%   +91.51%     
=========================================
  Files         0       25       +25     
  Lines         0     1155     +1155     
  Branches      0      122      +122     
=========================================
+ Hits          0     1057     +1057     
- Misses        0       83       +83     
- Partials      0       15       +15     

see 25 files with indirect coverage changes

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

@gregschohn
Copy link
Collaborator

Can you look up what the conventions are for other opensearch gradle projects. What are some of the target names, are there any other specific tools that are commonly used (like checkstyle)? You can create more tasks to add them, but it's good to maintain consistency for future developers.

@okhasawn
Copy link
Contributor Author

okhasawn commented Mar 9, 2023

Can you look up what the conventions are for other opensearch gradle projects. What are some of the target names, are there any other specific tools that are commonly used (like checkstyle)? You can create more tasks to add them, but it's good to maintain consistency for future developers.

opensearch-project/opensearch-java repo actually has checkstyle as a github action, while the opensearch-project/opensearch stopped using checkstyle and started using spotless

Signed-off-by: Omar Khasawneh <okhasawn@amazon.com>
Signed-off-by: Omar Khasawneh <okhasawn@amazon.com>
Signed-off-by: Omar Khasawneh <okhasawn@amazon.com>
@okhasawn okhasawn marked this pull request as ready for review March 13, 2023 16:47
@okhasawn okhasawn requested a review from a team as a code owner March 13, 2023 16:47
@okhasawn okhasawn requested a review from gregschohn March 13, 2023 16:47
@okhasawn okhasawn changed the title Migrations-1015 - DRAFT - Add buildscript for replayer Migrations-1015 - Add buildscript for replayer Mar 13, 2023
…ommit fixes that

Signed-off-by: Omar Khasawneh <okhasawn@amazon.com>
Copy link
Collaborator

@gregschohn gregschohn left a comment

Choose a reason for hiding this comment

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

I'm not familiar w/ a lot of the specific details that need to go into the build.gradle file, but I've left some comments. I'd like to make sure that this works well with IDE integration and the command line. Please add some notes to the PR with your findings.

Comment on lines 45 to 47
implementation group: 'com.beust', name: 'jcommander', version: '1.82'
implementation group: 'org.apache.logging.log4j', name: 'log4j-api', version: '2.20.0'
annotationProcessor 'org.projectlombok:lombok:1.18.10'
Copy link
Collaborator

Choose a reason for hiding this comment

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

Thank you for noticing & adding these!

sourceSets {
main {
java {
srcDirs = ['src/org/opensearch/migrations/replay','src/org/opensearch/migrations/replay/netty']
Copy link
Collaborator

Choose a reason for hiding this comment

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

I would expect the source set to just be 'src' since org... are all part of the same source hierarchy. This might create an issue when importing this into an IDE. If you just make this 'src', does the project still build? Does it load well into IntelliJ (I don't know how vscode works, but if you know, that's a good datapoint to try too)?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Thanks for letting me know and pointing this out. It does still build and load well into IntelliJ, I'll update this and "tst" too!

java {
compileClasspath += main.output + test.output
runtimeClasspath += main.output + test.output
resources.srcDir file('tst/org/opensearch/migrations/replay')
Copy link
Collaborator

Choose a reason for hiding this comment

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

Same as above - should this just be 'tst'?

Comment on lines 60 to 61
compileClasspath += main.output + test.output
runtimeClasspath += main.output + test.output
Copy link
Collaborator

Choose a reason for hiding this comment

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

do you know what compileClasspath/runtimeClasspath are set to beforehand (asking because of the '+=")?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

compileClasspath defaults to the compile configuration and runtimeClasspath defaults to the sourceSet's output + runtime configuration

Signed-off-by: Omar Khasawneh <okhasawn@amazon.com>
implementation group: 'org.apache.logging.log4j', name: 'log4j-api', version: '2.20.0'
implementation group: 'org.apache.logging.log4j', name: 'log4j-core', version: '2.20.0'
testImplementation 'org.junit.jupiter:junit-jupiter:5.9.2'
annotationProcessor 'org.projectlombok:lombok:1.18.10'
Copy link
Collaborator

Choose a reason for hiding this comment

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

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I'll bump that along with a few more things that the mend security check pointed out. https://github.com/opensearch-project/opensearch-migrations/pull/118/checks?check_run_id=12176201328

@lewijacn
Copy link
Collaborator

Couple things then I'm fine to approve:

I don't want to mess with the gradle configuration too much while this is still a sub directory of this repo as its hard to tell what is an actual problem or what is Intelij having trouble reconciling. But we should definitely make sure this works well when we move it out and is properly picked up by Intelij.

I was able to build successfully after fixing a spot bugs issue in line 282 of TrafficReplayer.java. Not sure if you've looked into this but if @gregschohn does not have concern would add it in
Bug: Found a call to a method which will perform a byte to String (or String to byte) conversion, and will assume that the default platform encoding is suitable. This will cause the application behaviour to vary between platforms. Use an alternative API and specify a charset name or Charset object explicitly
Original:
try (InputStreamReader r = new InputStreamReader(fis)) {
Change:
try (InputStreamReader r = new InputStreamReader(fis, StandardCharsets.UTF_8)) {

Signed-off-by: Omar Khasawneh <okhasawn@amazon.com>
Copy link
Collaborator

@lewijacn lewijacn left a comment

Choose a reason for hiding this comment

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

LGTM

Copy link
Collaborator

@gregschohn gregschohn left a comment

Choose a reason for hiding this comment

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

You can also delete the IntelliJ project file (TrafficReplayer.iml)
I'm sure that I will soon regret not looking at the checkstyle.xml file carefully :)

@okhasawn
Copy link
Contributor Author

okhasawn commented Mar 29, 2023

You can also delete the IntelliJ project file (TrafficReplayer.iml) I'm sure that I will soon regret not looking at the checkstyle.xml file carefully :)

@gregschohn I'll remove that file in one of the other PR's that I have open.
The checkstyle.xml file is just the default google java style guideline.

@okhasawn okhasawn merged commit b6fbcc2 into opensearch-project:main Mar 29, 2023
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.

4 participants