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

Setup Initial Jenkins Git Structure #744

Merged
merged 38 commits into from
Jun 21, 2024

Conversation

lewijacn
Copy link
Collaborator

@lewijacn lewijacn commented Jun 19, 2024

Description

This change introduces a shared library structure for our Jenkins pipelines. As can be seen, this allows creating a pipeline template that our actual pipeline files can utilize and configure as needed.

Along with this, this change includes some common functions that will be needed for testing and have been added to the console library, with a future change expected to move our python testing files to be able to use this console library as well.

Issues Resolved

Partially resolves: https://opensearch.atlassian.net/browse/MIGRATIONS-1753

Testing

Local/Cloud testing

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: Tanner Lewis <[email protected]>
Signed-off-by: Tanner Lewis <[email protected]>
Signed-off-by: Tanner Lewis <[email protected]>
Signed-off-by: Tanner Lewis <[email protected]>
Signed-off-by: Tanner Lewis <[email protected]>
Signed-off-by: Tanner Lewis <[email protected]>
Signed-off-by: Tanner Lewis <[email protected]>
Signed-off-by: Tanner Lewis <[email protected]>
Signed-off-by: Tanner Lewis <[email protected]>
Signed-off-by: Tanner Lewis <[email protected]>
Signed-off-by: Tanner Lewis <[email protected]>
Signed-off-by: Tanner Lewis <[email protected]>
Signed-off-by: Tanner Lewis <[email protected]>
Signed-off-by: Tanner Lewis <[email protected]>
Signed-off-by: Tanner Lewis <[email protected]>
Signed-off-by: Tanner Lewis <[email protected]>
Signed-off-by: Tanner Lewis <[email protected]>
Signed-off-by: Tanner Lewis <[email protected]>
Signed-off-by: Tanner Lewis <[email protected]>
Signed-off-by: Tanner Lewis <[email protected]>
Signed-off-by: Tanner Lewis <[email protected]>
Copy link

codecov bot commented Jun 19, 2024

Codecov Report

Attention: Patch coverage is 54.28571% with 32 lines in your changes missing coverage. Please review.

Project coverage is 68.21%. Comparing base (787fd26) to head (fd9ba8d).
Report is 4 commits behind head on main.

Files Patch % Lines
...le/lib/console_link/console_link/logic/clusters.py 40.62% 19 Missing ⚠️
...le/lib/console_link/console_link/models/cluster.py 21.42% 11 Missing ⚠️
...rationConsole/lib/console_link/console_link/cli.py 91.66% 2 Missing ⚠️
Additional details and impacted files
@@              Coverage Diff              @@
##               main     #744       +/-   ##
=============================================
- Coverage     89.37%   68.21%   -21.17%     
- Complexity        0     1578     +1578     
=============================================
  Files            46      270      +224     
  Lines          2702    11139     +8437     
  Branches          0      736      +736     
=============================================
+ Hits           2415     7598     +5183     
- Misses          287     3138     +2851     
- Partials          0      403      +403     
Flag Coverage Δ
gradle-test 61.50% <ø> (?)
python-test 88.47% <54.28%> (-0.90%) ⬇️

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@lewijacn lewijacn marked this pull request as ready for review June 20, 2024 15:22
Comment on lines 26 to 28
access_result['connection_message'] = "Successfully connected!"
access_result['cluster_version'] = response_json['version']['number']
access_result['connection_established'] = True
Copy link
Collaborator

Choose a reason for hiding this comment

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

might be nice to make this access_result something like a named tuple or a very simple class so we can make a type guarantee on the return and the caller knows exactly what to assume they can get

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Good idea have made a simple class around this



# As a default we exclude system indices and searchguard indices
def clear_indices(cluster: Cluster):
Copy link
Collaborator

Choose a reason for hiding this comment

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

Is this used anywhere? It's definitely very helpful for our testing, but I think we should put it behind a verification step where the user explicitly acknowledges that they're going to delete all the data in their cluster.

(helper for that https://click.palletsprojects.com/en/8.1.x/prompts/#confirmation-prompts)

Copy link
Collaborator

Choose a reason for hiding this comment

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

potentially even do something like only create a CLI command for it (or at least only enable it) if there's an env variable like DEBUG_MODE or I_WANT_TO_DO_DANGEROUS_THINGS_TO_MY_CLUSTER set

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Went ahead and added this as a CLI option, with a confirmation step added to it, thanks for the link

raise NotImplementedError(f"Auth type {self.auth_type} is not currently support for executing "
f"benchmark workloads")
logger.info(f"Running opensearch-benchmark with '{workload}' workload")
subprocess.run(f"opensearch-benchmark execute-test --distribution-version=1.0.0 "
Copy link
Collaborator

Choose a reason for hiding this comment

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

Do the benchmark outputs print to stdout or are they captured here? Kind of nice to show the user that something's happening, so I think I'm moderately in favor of not-capturing, but don't feel super strongly.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Right now they are printing to stdout which I kinda like as well. I'm open to change that though if we decide we don't like it

Signed-off-by: Tanner Lewis <[email protected]>
Signed-off-by: Tanner Lewis <[email protected]>
# Conflicts:
#	TrafficCapture/dockerSolution/src/main/docker/migrationConsole/lib/console_link/console_link/models/cluster.py
Signed-off-by: Tanner Lewis <[email protected]>
Signed-off-by: Tanner Lewis <[email protected]>
Signed-off-by: Tanner Lewis <[email protected]>
Signed-off-by: Tanner Lewis <[email protected]>
click.echo("Performing clear indices operation...")
click.echo(logic_clusters.clear_indices(cluster_focus))
else:
if click.confirm('Clearing indices can result in data loss, are you sure you want to continue?'):
Copy link
Collaborator

Choose a reason for hiding this comment

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

can we phrase this slightly more strongly: "Clearing indices WILL result in the loss of all data on the {source/target} cluster. Are you sure you want to continue?"

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Updated to this wording

"""[Caution] Clear indices on a source or target cluster"""
cluster_focus = ctx.env.source_cluster if cluster.lower() == 'source' else ctx.env.target_cluster
if acknowledge_risk:
click.echo("Performing clear indices operation...")
Copy link
Collaborator

Choose a reason for hiding this comment

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

minor, but I'd also reiterate in these messages which cluster is being cleared.

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 like it, added

assert result.exit_code == 0


def test_cli_cluster_clear_indices(runner, env, mocker):
Copy link
Collaborator

Choose a reason for hiding this comment

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

can you do a version of this test without --acknowledge-risk to make sure that it doesn't call clear?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Added 👍

Comment on lines +67 to +69
//deployStep: {
// echo 'Custom Test Step'
//}
Copy link
Collaborator

Choose a reason for hiding this comment

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

intentional?

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 was trying to use it as a reference that steps could be replaced if needed

@lewijacn lewijacn merged commit 8ecb500 into opensearch-project:main Jun 21, 2024
10 of 12 checks passed
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.

2 participants