From 7e6f30e4efa08d1c5333efb94192ae8bcba21334 Mon Sep 17 00:00:00 2001 From: Tanner Lewis Date: Mon, 17 Jun 2024 12:43:19 -0400 Subject: [PATCH 01/34] Add in default jenkinsFile Signed-off-by: Tanner Lewis --- .../migration-pipelines/e2eSetup.jenkinsFile | 128 ++++++++++++++++++ 1 file changed, 128 insertions(+) create mode 100644 jenkins/migration-pipelines/e2eSetup.jenkinsFile diff --git a/jenkins/migration-pipelines/e2eSetup.jenkinsFile b/jenkins/migration-pipelines/e2eSetup.jenkinsFile new file mode 100644 index 000000000..25cbab35f --- /dev/null +++ b/jenkins/migration-pipelines/e2eSetup.jenkinsFile @@ -0,0 +1,128 @@ +// Note: +// 1. We are using an existing common VPC for now until we move to a proper Jenkins accounts and can create a setup without +// public subnets as well as request an extension to allow more than 5 VPCs per region +// 2. There is a still a manual step needed on the EC2 source load balancer to replace its security group rule which allows all traffic (0.0.0.0/0) to +// allow traffic for the relevant service security group. This needs a better story around accepting user security groups in our Migration CDK. +def source_cdk_context = """ +{ + "source-single-node-ec2": { + "suffix": "ec2-source-", + "networkStackSuffix": "ec2-source-", + "vpcId": "vpc-07d3e089b8e9139e4", + "distVersion": "7.10.2", + "cidr": "12.0.0.0/16", + "distributionUrl": "https://artifacts.elastic.co/downloads/elasticsearch/elasticsearch-oss-7.10.2-linux-x86_64.tar.gz", + "captureProxyEnabled": true, + "securityDisabled": true, + "minDistribution": false, + "cpuArch": "x64", + "isInternal": true, + "singleNodeCluster": true, + "networkAvailabilityZones": 2, + "dataNodeCount": 1, + "managerNodeCount": 0, + "serverAccessType": "ipv4", + "restrictServerAccessTo": "0.0.0.0/0" + } +} +""" +def migration_cdk_context = """ +{ + "migration-default": { + "stage": "", + "vpcId": "vpc-07d3e089b8e9139e4", + "engineVersion": "OS_2.11", + "domainName": "os-cluster-", + "dataNodeCount": 2, + "openAccessPolicyEnabled": true, + "domainRemovalPolicy": "DESTROY", + "artifactBucketRemovalPolicy": "DESTROY", + "trafficReplayerExtraArgs": "--speedup-factor 10.0", + "fetchMigrationEnabled": true, + "reindexFromSnapshotServiceEnabled": true, + "sourceClusterEndpoint": "", + "dpPipelineTemplatePath": "../../../test/dp_pipeline_aws_integ.yaml", + "migrationConsoleEnableOSI": true, + "migrationAPIEnabled": true + } +} +""" +def source_context_file_name = 'sourceJenkinsContext.json' +def migration_context_file_name = 'migrationJenkinsContext.json' +pipeline { + environment { + // GIT_URL = 'https://github.com/mikaylathompson/opensearch-migrations.git' + // GIT_BRANCH = 'add-metric-verification-to-tests' + GIT_URL = 'https://github.com/opensearch-project/opensearch-migrations.git' + GIT_BRANCH = 'main' + STAGE = 'aws-integ' + } + + parameters { + string(name: 'BRANCH_NAME', defaultValue: 'main', description: 'The branch to build') + choice(name: 'DEPLOY_STAGE', description: 'Deployment environment') + } + + agent { label 'Jenkins-Default-Agent-X64-C5xlarge-Single-Host' } + + stages { + stage('Checkout') { + steps { + git branch: "${env.GIT_BRANCH}", url: "${env.GIT_URL}" + } + } + + stage('Test Caller Identity') { + steps { + sh 'aws sts get-caller-identity' + } + } + + stage('Setup E2E CDK Context') { + steps { + writeFile (file: "test/$source_context_file_name", text: source_cdk_context) + sh "echo 'Using source context file options: ' && cat test/$source_context_file_name" + writeFile (file: "test/$migration_context_file_name", text: migration_cdk_context) + sh "echo 'Using migration context file options: ' && cat test/$migration_context_file_name" + } + } + + stage('Build') { + steps { + timeout(time: 1, unit: 'HOURS') { + sh 'sudo ./gradlew clean build' + } + } + } + + stage('Deploy') { + steps { + dir('test') { + sh 'sudo usermod -aG docker $USER' + sh 'sudo newgrp docker' + sh "sudo ./awsE2ESolutionSetup.sh --source-context-file './$source_context_file_name' --migration-context-file './$migration_context_file_name' --source-context-id source-single-node-ec2 --migration-context-id migration-default --stage ${env.STAGE} --migrations-git-url ${env.GIT_URL} --migrations-git-branch ${env.GIT_BRANCH}" + } + } + } + + stage('Integ Tests') { + steps { + dir('test') { + script { + def time = new Date().getTime() + def uniqueId = "integ_min_${time}_${currentBuild.number}" + sh "sudo ./awsRunIntegTests.sh --stage ${env.STAGE} --migrations-git-url ${env.GIT_URL} --migrations-git-branch ${env.GIT_BRANCH} --unique-id ${uniqueId}" + } + } + + } + } + } + post { + always { + dir('test') { + sh "sudo ./awsE2ESolutionSetup.sh --stage ${env.STAGE} --run-post-actions" + } + } + } +} From 14ad3a954f864732d1ce1e45af85a9235739f12f Mon Sep 17 00:00:00 2001 From: Tanner Lewis Date: Mon, 17 Jun 2024 14:18:08 -0400 Subject: [PATCH 02/34] Test 2 Signed-off-by: Tanner Lewis --- .../defaultStructure.groovy | 125 +++++++++++++++++ .../migration-pipelines/e2eSetup.jenkinsFile | 130 +----------------- 2 files changed, 127 insertions(+), 128 deletions(-) create mode 100644 jenkins/migration-pipelines/defaultStructure.groovy diff --git a/jenkins/migration-pipelines/defaultStructure.groovy b/jenkins/migration-pipelines/defaultStructure.groovy new file mode 100644 index 000000000..93e0d855b --- /dev/null +++ b/jenkins/migration-pipelines/defaultStructure.groovy @@ -0,0 +1,125 @@ +def source_cdk_context = """ +{ + "source-single-node-ec2": { + "suffix": "ec2-source-", + "networkStackSuffix": "ec2-source-", + "vpcId": "vpc-07d3e089b8e9139e4", + "distVersion": "7.10.2", + "cidr": "12.0.0.0/16", + "distributionUrl": "https://artifacts.elastic.co/downloads/elasticsearch/elasticsearch-oss-7.10.2-linux-x86_64.tar.gz", + "captureProxyEnabled": true, + "securityDisabled": true, + "minDistribution": false, + "cpuArch": "x64", + "isInternal": true, + "singleNodeCluster": true, + "networkAvailabilityZones": 2, + "dataNodeCount": 1, + "managerNodeCount": 0, + "serverAccessType": "ipv4", + "restrictServerAccessTo": "0.0.0.0/0" + } +} +""" +def migration_cdk_context = """ +{ + "migration-default": { + "stage": "", + "vpcId": "vpc-07d3e089b8e9139e4", + "engineVersion": "OS_2.11", + "domainName": "os-cluster-", + "dataNodeCount": 2, + "openAccessPolicyEnabled": true, + "domainRemovalPolicy": "DESTROY", + "artifactBucketRemovalPolicy": "DESTROY", + "trafficReplayerExtraArgs": "--speedup-factor 10.0", + "fetchMigrationEnabled": true, + "reindexFromSnapshotServiceEnabled": true, + "sourceClusterEndpoint": "", + "dpPipelineTemplatePath": "../../../test/dp_pipeline_aws_integ.yaml", + "migrationConsoleEnableOSI": true, + "migrationAPIEnabled": true + } +} +""" +def source_context_file_name = 'sourceJenkinsContext.json' +def migration_context_file_name = 'migrationJenkinsContext.json' +void call(Map arguments = [:], Closure body) { + pipeline { + environment { + // GIT_URL = 'https://github.com/mikaylathompson/opensearch-migrations.git' + // GIT_BRANCH = 'add-metric-verification-to-tests' + GIT_URL = 'https://github.com/opensearch-project/opensearch-migrations.git' + GIT_BRANCH = 'main' + STAGE = 'aws-integ' + } + + parameters { + string(name: 'BRANCH_NAME', defaultValue: 'main', description: 'The branch to build') + string(name: 'DEPLOY_STAGE', description: 'Deployment environment') + } + + agent { label 'Jenkins-Default-Agent-X64-C5xlarge-Single-Host' } + + stages { + stage('Checkout') { + steps { + git branch: "${env.GIT_BRANCH}", url: "${env.GIT_URL}" + } + } + + stage('Test Caller Identity') { + steps { + sh 'aws sts get-caller-identity' + } + } + + stage('Setup E2E CDK Context') { + steps { + writeFile (file: "test/$source_context_file_name", text: source_cdk_context) + sh "echo 'Using source context file options: ' && cat test/$source_context_file_name" + writeFile (file: "test/$migration_context_file_name", text: migration_cdk_context) + sh "echo 'Using migration context file options: ' && cat test/$migration_context_file_name" + } + } + + stage('Build') { + steps { + timeout(time: 1, unit: 'HOURS') { + sh 'sudo ./gradlew clean build' + } + } + } + + stage('Deploy') { + steps { + dir('test') { + sh 'sudo usermod -aG docker $USER' + sh 'sudo newgrp docker' + sh "sudo ./awsE2ESolutionSetup.sh --source-context-file './$source_context_file_name' --migration-context-file './$migration_context_file_name' --source-context-id source-single-node-ec2 --migration-context-id migration-default --stage ${env.STAGE} --migrations-git-url ${env.GIT_URL} --migrations-git-branch ${env.GIT_BRANCH}" + } + } + } + + stage('Integ Tests') { + steps { + dir('test') { + script { + def time = new Date().getTime() + def uniqueId = "integ_min_${time}_${currentBuild.number}" + sh "sudo ./awsRunIntegTests.sh --stage ${env.STAGE} --migrations-git-url ${env.GIT_URL} --migrations-git-branch ${env.GIT_BRANCH} --unique-id ${uniqueId}" + } + } + + } + } + } + post { + always { + dir('test') { + sh "sudo ./awsE2ESolutionSetup.sh --stage ${env.STAGE} --run-post-actions" + } + } + } + } +} diff --git a/jenkins/migration-pipelines/e2eSetup.jenkinsFile b/jenkins/migration-pipelines/e2eSetup.jenkinsFile index 25cbab35f..a62d85843 100644 --- a/jenkins/migration-pipelines/e2eSetup.jenkinsFile +++ b/jenkins/migration-pipelines/e2eSetup.jenkinsFile @@ -1,128 +1,2 @@ -// Note: -// 1. We are using an existing common VPC for now until we move to a proper Jenkins accounts and can create a setup without -// public subnets as well as request an extension to allow more than 5 VPCs per region -// 2. There is a still a manual step needed on the EC2 source load balancer to replace its security group rule which allows all traffic (0.0.0.0/0) to -// allow traffic for the relevant service security group. This needs a better story around accepting user security groups in our Migration CDK. -def source_cdk_context = """ -{ - "source-single-node-ec2": { - "suffix": "ec2-source-", - "networkStackSuffix": "ec2-source-", - "vpcId": "vpc-07d3e089b8e9139e4", - "distVersion": "7.10.2", - "cidr": "12.0.0.0/16", - "distributionUrl": "https://artifacts.elastic.co/downloads/elasticsearch/elasticsearch-oss-7.10.2-linux-x86_64.tar.gz", - "captureProxyEnabled": true, - "securityDisabled": true, - "minDistribution": false, - "cpuArch": "x64", - "isInternal": true, - "singleNodeCluster": true, - "networkAvailabilityZones": 2, - "dataNodeCount": 1, - "managerNodeCount": 0, - "serverAccessType": "ipv4", - "restrictServerAccessTo": "0.0.0.0/0" - } -} -""" -def migration_cdk_context = """ -{ - "migration-default": { - "stage": "", - "vpcId": "vpc-07d3e089b8e9139e4", - "engineVersion": "OS_2.11", - "domainName": "os-cluster-", - "dataNodeCount": 2, - "openAccessPolicyEnabled": true, - "domainRemovalPolicy": "DESTROY", - "artifactBucketRemovalPolicy": "DESTROY", - "trafficReplayerExtraArgs": "--speedup-factor 10.0", - "fetchMigrationEnabled": true, - "reindexFromSnapshotServiceEnabled": true, - "sourceClusterEndpoint": "", - "dpPipelineTemplatePath": "../../../test/dp_pipeline_aws_integ.yaml", - "migrationConsoleEnableOSI": true, - "migrationAPIEnabled": true - } -} -""" -def source_context_file_name = 'sourceJenkinsContext.json' -def migration_context_file_name = 'migrationJenkinsContext.json' -pipeline { - environment { - // GIT_URL = 'https://github.com/mikaylathompson/opensearch-migrations.git' - // GIT_BRANCH = 'add-metric-verification-to-tests' - GIT_URL = 'https://github.com/opensearch-project/opensearch-migrations.git' - GIT_BRANCH = 'main' - STAGE = 'aws-integ' - } - - parameters { - string(name: 'BRANCH_NAME', defaultValue: 'main', description: 'The branch to build') - choice(name: 'DEPLOY_STAGE', description: 'Deployment environment') - } - - agent { label 'Jenkins-Default-Agent-X64-C5xlarge-Single-Host' } - - stages { - stage('Checkout') { - steps { - git branch: "${env.GIT_BRANCH}", url: "${env.GIT_URL}" - } - } - - stage('Test Caller Identity') { - steps { - sh 'aws sts get-caller-identity' - } - } - - stage('Setup E2E CDK Context') { - steps { - writeFile (file: "test/$source_context_file_name", text: source_cdk_context) - sh "echo 'Using source context file options: ' && cat test/$source_context_file_name" - writeFile (file: "test/$migration_context_file_name", text: migration_cdk_context) - sh "echo 'Using migration context file options: ' && cat test/$migration_context_file_name" - } - } - - stage('Build') { - steps { - timeout(time: 1, unit: 'HOURS') { - sh 'sudo ./gradlew clean build' - } - } - } - - stage('Deploy') { - steps { - dir('test') { - sh 'sudo usermod -aG docker $USER' - sh 'sudo newgrp docker' - sh "sudo ./awsE2ESolutionSetup.sh --source-context-file './$source_context_file_name' --migration-context-file './$migration_context_file_name' --source-context-id source-single-node-ec2 --migration-context-id migration-default --stage ${env.STAGE} --migrations-git-url ${env.GIT_URL} --migrations-git-branch ${env.GIT_BRANCH}" - } - } - } - - stage('Integ Tests') { - steps { - dir('test') { - script { - def time = new Date().getTime() - def uniqueId = "integ_min_${time}_${currentBuild.number}" - sh "sudo ./awsRunIntegTests.sh --stage ${env.STAGE} --migrations-git-url ${env.GIT_URL} --migrations-git-branch ${env.GIT_BRANCH} --unique-id ${uniqueId}" - } - } - - } - } - } - post { - always { - dir('test') { - sh "sudo ./awsE2ESolutionSetup.sh --stage ${env.STAGE} --run-post-actions" - } - } - } -} +def defaultStructure = load 'defaultStructure.groovy' +defaultStructure.call() From 2fea84afa33c6e6f03e8eb8afa972b2eb58a6453 Mon Sep 17 00:00:00 2001 From: Tanner Lewis Date: Mon, 17 Jun 2024 14:19:52 -0400 Subject: [PATCH 03/34] Test 3 Signed-off-by: Tanner Lewis --- .../migration-pipelines/e2eSetup.jenkinsFile | 18 ++++++++++++++++-- 1 file changed, 16 insertions(+), 2 deletions(-) diff --git a/jenkins/migration-pipelines/e2eSetup.jenkinsFile b/jenkins/migration-pipelines/e2eSetup.jenkinsFile index a62d85843..270ebe670 100644 --- a/jenkins/migration-pipelines/e2eSetup.jenkinsFile +++ b/jenkins/migration-pipelines/e2eSetup.jenkinsFile @@ -1,2 +1,16 @@ -def defaultStructure = load 'defaultStructure.groovy' -defaultStructure.call() + +pipeline { + agent any + + stages { + stage('Load Pipeline') { + steps { + script { + // Load and execute the pipeline from the helper script + def defaultStructure = load 'defaultStructure.groovy' + defaultStructure.call() + } + } + } + } +} From dcf9096f3b6ef8358e08589b611e7cae4374b135 Mon Sep 17 00:00:00 2001 From: Tanner Lewis Date: Mon, 17 Jun 2024 14:21:15 -0400 Subject: [PATCH 04/34] Update agent Signed-off-by: Tanner Lewis --- jenkins/migration-pipelines/e2eSetup.jenkinsFile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/jenkins/migration-pipelines/e2eSetup.jenkinsFile b/jenkins/migration-pipelines/e2eSetup.jenkinsFile index 270ebe670..a0ec64496 100644 --- a/jenkins/migration-pipelines/e2eSetup.jenkinsFile +++ b/jenkins/migration-pipelines/e2eSetup.jenkinsFile @@ -1,6 +1,6 @@ pipeline { - agent any + agent { label 'Jenkins-Default-Agent-X64-C5xlarge-Single-Host' } stages { stage('Load Pipeline') { From a63765e797c5afbdc647451767e4ed58de08a569 Mon Sep 17 00:00:00 2001 From: Tanner Lewis Date: Mon, 17 Jun 2024 14:25:07 -0400 Subject: [PATCH 05/34] Load pipeline Signed-off-by: Tanner Lewis --- jenkins/migration-pipelines/e2eSetup.jenkinsFile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/jenkins/migration-pipelines/e2eSetup.jenkinsFile b/jenkins/migration-pipelines/e2eSetup.jenkinsFile index a0ec64496..bc53c1fbd 100644 --- a/jenkins/migration-pipelines/e2eSetup.jenkinsFile +++ b/jenkins/migration-pipelines/e2eSetup.jenkinsFile @@ -7,7 +7,7 @@ pipeline { steps { script { // Load and execute the pipeline from the helper script - def defaultStructure = load 'defaultStructure.groovy' + def defaultStructure = load 'opensearch-migrations/jenkins/migration-pipelines/defaultStructure.groovy' defaultStructure.call() } } From ab555d693c844cf995663585136ab0f57d94c4bd Mon Sep 17 00:00:00 2001 From: Tanner Lewis Date: Mon, 17 Jun 2024 14:27:10 -0400 Subject: [PATCH 06/34] Load pipeline 2 Signed-off-by: Tanner Lewis --- jenkins/migration-pipelines/e2eSetup.jenkinsFile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/jenkins/migration-pipelines/e2eSetup.jenkinsFile b/jenkins/migration-pipelines/e2eSetup.jenkinsFile index bc53c1fbd..1d5cd9d1e 100644 --- a/jenkins/migration-pipelines/e2eSetup.jenkinsFile +++ b/jenkins/migration-pipelines/e2eSetup.jenkinsFile @@ -7,7 +7,7 @@ pipeline { steps { script { // Load and execute the pipeline from the helper script - def defaultStructure = load 'opensearch-migrations/jenkins/migration-pipelines/defaultStructure.groovy' + def defaultStructure = load 'jenkins/migration-pipelines/defaultStructure.groovy' defaultStructure.call() } } From 97dd3607d35e9fa3cea88b8b2b8932979fba3014 Mon Sep 17 00:00:00 2001 From: Tanner Lewis Date: Wed, 19 Jun 2024 10:28:45 -0400 Subject: [PATCH 07/34] Add shared library Signed-off-by: Tanner Lewis --- .../vars/defaultIntegPipeline.groovy | 44 +++++++++++++++++++ .../defaultStructure.groovy | 0 .../e2eSetup.jenkinsFile | 0 3 files changed, 44 insertions(+) create mode 100644 jenkins/sharedLibrary/vars/defaultIntegPipeline.groovy rename {jenkins/migration-pipelines => jenkinsdocker}/defaultStructure.groovy (100%) rename {jenkins/migration-pipelines => jenkinsdocker}/e2eSetup.jenkinsFile (100%) diff --git a/jenkins/sharedLibrary/vars/defaultIntegPipeline.groovy b/jenkins/sharedLibrary/vars/defaultIntegPipeline.groovy new file mode 100644 index 000000000..6d119a20e --- /dev/null +++ b/jenkins/sharedLibrary/vars/defaultIntegPipeline.groovy @@ -0,0 +1,44 @@ +def call(Map config = [:]) { + pipeline { + agent any + + stages { + stage('Build') { + steps { + script { + if (config.buildStep) { + config.buildStep() + } else { + echo 'Default Build Step' + // Add default build steps here + } + } + } + } + stage('Test') { + steps { + script { + if (config.testStep) { + config.testStep() + } else { + echo 'Default Test Step' + // Add default test steps here + } + } + } + } + stage('Deploy') { + steps { + script { + if (config.deployStep) { + config.deployStep() + } else { + echo 'Default Deploy Step' + // Add default deploy steps here + } + } + } + } + } + } +} diff --git a/jenkins/migration-pipelines/defaultStructure.groovy b/jenkinsdocker/defaultStructure.groovy similarity index 100% rename from jenkins/migration-pipelines/defaultStructure.groovy rename to jenkinsdocker/defaultStructure.groovy diff --git a/jenkins/migration-pipelines/e2eSetup.jenkinsFile b/jenkinsdocker/e2eSetup.jenkinsFile similarity index 100% rename from jenkins/migration-pipelines/e2eSetup.jenkinsFile rename to jenkinsdocker/e2eSetup.jenkinsFile From dd676fd0c6a6d9b739c3138fa6ffd596f37efea0 Mon Sep 17 00:00:00 2001 From: Tanner Lewis Date: Wed, 19 Jun 2024 10:58:57 -0400 Subject: [PATCH 08/34] Update agent default pipeline Signed-off-by: Tanner Lewis --- jenkins/sharedLibrary/vars/defaultIntegPipeline.groovy | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/jenkins/sharedLibrary/vars/defaultIntegPipeline.groovy b/jenkins/sharedLibrary/vars/defaultIntegPipeline.groovy index 6d119a20e..55b767b6a 100644 --- a/jenkins/sharedLibrary/vars/defaultIntegPipeline.groovy +++ b/jenkins/sharedLibrary/vars/defaultIntegPipeline.groovy @@ -1,6 +1,6 @@ def call(Map config = [:]) { pipeline { - agent any + agent { label 'Jenkins-Default-Agent-X64-C5xlarge-Single-Host' } stages { stage('Build') { From b34da812bda31d5cf4609a449f353f7a72520087 Mon Sep 17 00:00:00 2001 From: Tanner Lewis Date: Wed, 19 Jun 2024 11:27:50 -0400 Subject: [PATCH 09/34] Shared library changes Signed-off-by: Tanner Lewis --- .../ec2SourceE2EPipeline.groovy | 8 ++ .../vars/defaultIntegPipeline.groovy | 130 ++++++++++++++---- 2 files changed, 115 insertions(+), 23 deletions(-) create mode 100644 jenkins/migrationPipelines/ec2SourceE2EPipeline.groovy diff --git a/jenkins/migrationPipelines/ec2SourceE2EPipeline.groovy b/jenkins/migrationPipelines/ec2SourceE2EPipeline.groovy new file mode 100644 index 000000000..60822618d --- /dev/null +++ b/jenkins/migrationPipelines/ec2SourceE2EPipeline.groovy @@ -0,0 +1,8 @@ +@Library('migrations-shared-lib@checkin-jenkinsfile')_ + +defaultIntegPipeline( + checkout: { + echo 'Custom Test Step' + git branch: "${env.GIT_BRANCH}", url: "${env.GIT_URL}" + } +) diff --git a/jenkins/sharedLibrary/vars/defaultIntegPipeline.groovy b/jenkins/sharedLibrary/vars/defaultIntegPipeline.groovy index 55b767b6a..c35351a63 100644 --- a/jenkins/sharedLibrary/vars/defaultIntegPipeline.groovy +++ b/jenkins/sharedLibrary/vars/defaultIntegPipeline.groovy @@ -1,42 +1,126 @@ +// Note: +// 1. We are using an existing common VPC for now until we move to a proper Jenkins accounts and can create a setup without +// public subnets as well as request an extension to allow more than 5 VPCs per region +// 2. There is a still a manual step needed on the EC2 source load balancer to replace its security group rule which allows all traffic (0.0.0.0/0) to +// allow traffic for the relevant service security group. This needs a better story around accepting user security groups in our Migration CDK. +def source_cdk_context = """ +{ + "source-single-node-ec2": { + "suffix": "ec2-source-", + "networkStackSuffix": "ec2-source-", + "vpcId": "vpc-07d3e089b8e9139e4", + "distVersion": "7.10.2", + "cidr": "12.0.0.0/16", + "distributionUrl": "https://artifacts.elastic.co/downloads/elasticsearch/elasticsearch-oss-7.10.2-linux-x86_64.tar.gz", + "captureProxyEnabled": true, + "securityDisabled": true, + "minDistribution": false, + "cpuArch": "x64", + "isInternal": true, + "singleNodeCluster": true, + "networkAvailabilityZones": 2, + "dataNodeCount": 1, + "managerNodeCount": 0, + "serverAccessType": "ipv4", + "restrictServerAccessTo": "0.0.0.0/0" + } +} +""" +def migration_cdk_context = """ +{ + "migration-default": { + "stage": "", + "vpcId": "vpc-07d3e089b8e9139e4", + "engineVersion": "OS_2.11", + "domainName": "os-cluster-", + "dataNodeCount": 2, + "openAccessPolicyEnabled": true, + "domainRemovalPolicy": "DESTROY", + "artifactBucketRemovalPolicy": "DESTROY", + "trafficReplayerExtraArgs": "--speedup-factor 10.0", + "fetchMigrationEnabled": true, + "reindexFromSnapshotServiceEnabled": true, + "sourceClusterEndpoint": "", + "dpPipelineTemplatePath": "../../../test/dp_pipeline_aws_integ.yaml", + "migrationConsoleEnableOSI": true, + "migrationAPIEnabled": true + } +} +""" +def source_context_file_name = 'sourceJenkinsContext.json' +def migration_context_file_name = 'migrationJenkinsContext.json' + def call(Map config = [:]) { pipeline { - agent { label 'Jenkins-Default-Agent-X64-C5xlarge-Single-Host' } + agent { label arguments.overrideAgent ?: 'Jenkins-Default-Agent-X64-C5xlarge-Single-Host' } + + environment { + GIT_URL = arguments.overrideGitUrl ?: 'https://github.com/opensearch-project/opensearch-migrations.git' + GIT_BRANCH = arguments.overrideGitBranch ?: 'main' + STAGE = arguments.overrideStage ?: 'aws-integ' + } stages { - stage('Build') { + stage('Checkout') { steps { - script { - if (config.buildStep) { - config.buildStep() - } else { - echo 'Default Build Step' - // Add default build steps here - } + if (config.checkout) { + config.checkout() + } else { + git branch: "${env.GIT_BRANCH}", url: "${env.GIT_URL}" } } } - stage('Test') { + + stage('Test Caller Identity') { steps { - script { - if (config.testStep) { - config.testStep() - } else { - echo 'Default Test Step' - // Add default test steps here - } + sh 'aws sts get-caller-identity' + } + } + + stage('Setup E2E CDK Context') { + steps { + writeFile (file: "test/$source_context_file_name", text: source_cdk_context) + sh "echo 'Using source context file options: ' && cat test/$source_context_file_name" + writeFile (file: "test/$migration_context_file_name", text: migration_cdk_context) + sh "echo 'Using migration context file options: ' && cat test/$migration_context_file_name" + } + } + + stage('Build') { + steps { + timeout(time: 1, unit: 'HOURS') { + sh 'sudo ./gradlew clean build' } } } + stage('Deploy') { steps { - script { - if (config.deployStep) { - config.deployStep() - } else { - echo 'Default Deploy Step' - // Add default deploy steps here + dir('test') { + sh 'sudo usermod -aG docker $USER' + sh 'sudo newgrp docker' + sh "sudo ./awsE2ESolutionSetup.sh --source-context-file './$source_context_file_name' --migration-context-file './$migration_context_file_name' --source-context-id source-single-node-ec2 --migration-context-id migration-default --stage ${env.STAGE} --migrations-git-url ${env.GIT_URL} --migrations-git-branch ${env.GIT_BRANCH}" + } + } + } + + stage('Integ Tests') { + steps { + dir('test') { + script { + def time = new Date().getTime() + def uniqueId = "integ_min_${time}_${currentBuild.number}" + sh "sudo ./awsRunIntegTests.sh --stage ${env.STAGE} --migrations-git-url ${env.GIT_URL} --migrations-git-branch ${env.GIT_BRANCH} --unique-id ${uniqueId}" } } + + } + } + } + post { + always { + dir('test') { + sh "sudo ./awsE2ESolutionSetup.sh --stage ${env.STAGE} --run-post-actions" } } } From 3a9d6fc544b3d4559014f227822090bbd411ac66 Mon Sep 17 00:00:00 2001 From: Tanner Lewis Date: Wed, 19 Jun 2024 11:31:54 -0400 Subject: [PATCH 10/34] Update shared lib Signed-off-by: Tanner Lewis --- jenkins/sharedLibrary/vars/defaultIntegPipeline.groovy | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/jenkins/sharedLibrary/vars/defaultIntegPipeline.groovy b/jenkins/sharedLibrary/vars/defaultIntegPipeline.groovy index c35351a63..8ac14c736 100644 --- a/jenkins/sharedLibrary/vars/defaultIntegPipeline.groovy +++ b/jenkins/sharedLibrary/vars/defaultIntegPipeline.groovy @@ -52,12 +52,12 @@ def migration_context_file_name = 'migrationJenkinsContext.json' def call(Map config = [:]) { pipeline { - agent { label arguments.overrideAgent ?: 'Jenkins-Default-Agent-X64-C5xlarge-Single-Host' } + agent { label config.overrideAgent ?: 'Jenkins-Default-Agent-X64-C5xlarge-Single-Host' } environment { - GIT_URL = arguments.overrideGitUrl ?: 'https://github.com/opensearch-project/opensearch-migrations.git' - GIT_BRANCH = arguments.overrideGitBranch ?: 'main' - STAGE = arguments.overrideStage ?: 'aws-integ' + GIT_URL = config.overrideGitUrl ?: 'https://github.com/opensearch-project/opensearch-migrations.git' + GIT_BRANCH = config.overrideGitBranch ?: 'main' + STAGE = config.overrideStage ?: 'aws-integ' } stages { From f5226c19d39df42206c3db4f83510b4a81ca03e2 Mon Sep 17 00:00:00 2001 From: Tanner Lewis Date: Wed, 19 Jun 2024 11:57:46 -0400 Subject: [PATCH 11/34] Test parameters Signed-off-by: Tanner Lewis --- .../vars/defaultIntegPipeline.groovy | 30 +++++++++++-------- 1 file changed, 18 insertions(+), 12 deletions(-) diff --git a/jenkins/sharedLibrary/vars/defaultIntegPipeline.groovy b/jenkins/sharedLibrary/vars/defaultIntegPipeline.groovy index 8ac14c736..b7765fd13 100644 --- a/jenkins/sharedLibrary/vars/defaultIntegPipeline.groovy +++ b/jenkins/sharedLibrary/vars/defaultIntegPipeline.groovy @@ -54,20 +54,26 @@ def call(Map config = [:]) { pipeline { agent { label config.overrideAgent ?: 'Jenkins-Default-Agent-X64-C5xlarge-Single-Host' } - environment { - GIT_URL = config.overrideGitUrl ?: 'https://github.com/opensearch-project/opensearch-migrations.git' - GIT_BRANCH = config.overrideGitBranch ?: 'main' - STAGE = config.overrideStage ?: 'aws-integ' + parameters { + string(name: 'GIT_URL', defaultValue: 'https://github.com/opensearch-project/opensearch-migrations.git', description: 'Git URL') + string(name: 'GIT_BRANCH', defaultValue: 'main', description: 'Git branch') + string(name: 'STAGE', defaultValue: 'aws-integ', description: 'Deployment stage') } +// environment { +// GIT_URL = config.overrideGitUrl ?: 'https://github.com/opensearch-project/opensearch-migrations.git' +// GIT_BRANCH = config.overrideGitBranch ?: 'main' +// STAGE = config.overrideStage ?: 'aws-integ' +// } stages { stage('Checkout') { steps { - if (config.checkout) { - config.checkout() - } else { - git branch: "${env.GIT_BRANCH}", url: "${env.GIT_URL}" - } +// if (config.checkout) { +// config.checkout() +// } else { +// git branch: "${params.GIT_BRANCH}", url: "${params.GIT_URL}" +// } + git branch: "${params.GIT_BRANCH}", url: "${params.GIT_URL}" } } @@ -99,7 +105,7 @@ def call(Map config = [:]) { dir('test') { sh 'sudo usermod -aG docker $USER' sh 'sudo newgrp docker' - sh "sudo ./awsE2ESolutionSetup.sh --source-context-file './$source_context_file_name' --migration-context-file './$migration_context_file_name' --source-context-id source-single-node-ec2 --migration-context-id migration-default --stage ${env.STAGE} --migrations-git-url ${env.GIT_URL} --migrations-git-branch ${env.GIT_BRANCH}" + sh "sudo ./awsE2ESolutionSetup.sh --source-context-file './$source_context_file_name' --migration-context-file './$migration_context_file_name' --source-context-id source-single-node-ec2 --migration-context-id migration-default --stage ${params.STAGE} --migrations-git-url ${params.GIT_URL} --migrations-git-branch ${params.GIT_BRANCH}" } } } @@ -110,7 +116,7 @@ def call(Map config = [:]) { script { def time = new Date().getTime() def uniqueId = "integ_min_${time}_${currentBuild.number}" - sh "sudo ./awsRunIntegTests.sh --stage ${env.STAGE} --migrations-git-url ${env.GIT_URL} --migrations-git-branch ${env.GIT_BRANCH} --unique-id ${uniqueId}" + sh "sudo ./awsRunIntegTests.sh --stage ${params.STAGE} --migrations-git-url ${params.GIT_URL} --migrations-git-branch ${params.GIT_BRANCH} --unique-id ${uniqueId}" } } @@ -120,7 +126,7 @@ def call(Map config = [:]) { post { always { dir('test') { - sh "sudo ./awsE2ESolutionSetup.sh --stage ${env.STAGE} --run-post-actions" + sh "sudo ./awsE2ESolutionSetup.sh --stage ${params.STAGE} --run-post-actions" } } } From 6c5c2c495ea4c6b22544031a88f8dbd8934513e4 Mon Sep 17 00:00:00 2001 From: Tanner Lewis Date: Wed, 19 Jun 2024 12:03:57 -0400 Subject: [PATCH 12/34] Update vars Signed-off-by: Tanner Lewis --- .../vars/defaultIntegPipeline.groovy | 92 +++++++++---------- 1 file changed, 46 insertions(+), 46 deletions(-) diff --git a/jenkins/sharedLibrary/vars/defaultIntegPipeline.groovy b/jenkins/sharedLibrary/vars/defaultIntegPipeline.groovy index b7765fd13..b291a5fb9 100644 --- a/jenkins/sharedLibrary/vars/defaultIntegPipeline.groovy +++ b/jenkins/sharedLibrary/vars/defaultIntegPipeline.groovy @@ -3,54 +3,54 @@ // public subnets as well as request an extension to allow more than 5 VPCs per region // 2. There is a still a manual step needed on the EC2 source load balancer to replace its security group rule which allows all traffic (0.0.0.0/0) to // allow traffic for the relevant service security group. This needs a better story around accepting user security groups in our Migration CDK. -def source_cdk_context = """ -{ - "source-single-node-ec2": { - "suffix": "ec2-source-", - "networkStackSuffix": "ec2-source-", - "vpcId": "vpc-07d3e089b8e9139e4", - "distVersion": "7.10.2", - "cidr": "12.0.0.0/16", - "distributionUrl": "https://artifacts.elastic.co/downloads/elasticsearch/elasticsearch-oss-7.10.2-linux-x86_64.tar.gz", - "captureProxyEnabled": true, - "securityDisabled": true, - "minDistribution": false, - "cpuArch": "x64", - "isInternal": true, - "singleNodeCluster": true, - "networkAvailabilityZones": 2, - "dataNodeCount": 1, - "managerNodeCount": 0, - "serverAccessType": "ipv4", - "restrictServerAccessTo": "0.0.0.0/0" - } -} -""" -def migration_cdk_context = """ -{ - "migration-default": { - "stage": "", - "vpcId": "vpc-07d3e089b8e9139e4", - "engineVersion": "OS_2.11", - "domainName": "os-cluster-", - "dataNodeCount": 2, - "openAccessPolicyEnabled": true, - "domainRemovalPolicy": "DESTROY", - "artifactBucketRemovalPolicy": "DESTROY", - "trafficReplayerExtraArgs": "--speedup-factor 10.0", - "fetchMigrationEnabled": true, - "reindexFromSnapshotServiceEnabled": true, - "sourceClusterEndpoint": "", - "dpPipelineTemplatePath": "../../../test/dp_pipeline_aws_integ.yaml", - "migrationConsoleEnableOSI": true, - "migrationAPIEnabled": true - } -} -""" -def source_context_file_name = 'sourceJenkinsContext.json' -def migration_context_file_name = 'migrationJenkinsContext.json' def call(Map config = [:]) { + def source_cdk_context = """ + { + "source-single-node-ec2": { + "suffix": "ec2-source-", + "networkStackSuffix": "ec2-source-", + "vpcId": "vpc-07d3e089b8e9139e4", + "distVersion": "7.10.2", + "cidr": "12.0.0.0/16", + "distributionUrl": "https://artifacts.elastic.co/downloads/elasticsearch/elasticsearch-oss-7.10.2-linux-x86_64.tar.gz", + "captureProxyEnabled": true, + "securityDisabled": true, + "minDistribution": false, + "cpuArch": "x64", + "isInternal": true, + "singleNodeCluster": true, + "networkAvailabilityZones": 2, + "dataNodeCount": 1, + "managerNodeCount": 0, + "serverAccessType": "ipv4", + "restrictServerAccessTo": "0.0.0.0/0" + } + } + """ + def migration_cdk_context = """ + { + "migration-default": { + "stage": "", + "vpcId": "vpc-07d3e089b8e9139e4", + "engineVersion": "OS_2.11", + "domainName": "os-cluster-", + "dataNodeCount": 2, + "openAccessPolicyEnabled": true, + "domainRemovalPolicy": "DESTROY", + "artifactBucketRemovalPolicy": "DESTROY", + "trafficReplayerExtraArgs": "--speedup-factor 10.0", + "fetchMigrationEnabled": true, + "reindexFromSnapshotServiceEnabled": true, + "sourceClusterEndpoint": "", + "dpPipelineTemplatePath": "../../../test/dp_pipeline_aws_integ.yaml", + "migrationConsoleEnableOSI": true, + "migrationAPIEnabled": true + } + } + """ + def source_context_file_name = 'sourceJenkinsContext.json' + def migration_context_file_name = 'migrationJenkinsContext.json' pipeline { agent { label config.overrideAgent ?: 'Jenkins-Default-Agent-X64-C5xlarge-Single-Host' } From 1a98a1cf3cfd92f6f5cbfc9cecd64d6c24f4fc03 Mon Sep 17 00:00:00 2001 From: Tanner Lewis Date: Wed, 19 Jun 2024 12:33:05 -0400 Subject: [PATCH 13/34] Update vars Signed-off-by: Tanner Lewis --- .../ec2SourceE2EPipeline.groovy | 11 +++++---- .../vars/defaultIntegPipeline.groovy | 23 +++++++++++-------- 2 files changed, 20 insertions(+), 14 deletions(-) diff --git a/jenkins/migrationPipelines/ec2SourceE2EPipeline.groovy b/jenkins/migrationPipelines/ec2SourceE2EPipeline.groovy index 60822618d..e296c3a9f 100644 --- a/jenkins/migrationPipelines/ec2SourceE2EPipeline.groovy +++ b/jenkins/migrationPipelines/ec2SourceE2EPipeline.groovy @@ -1,8 +1,11 @@ @Library('migrations-shared-lib@checkin-jenkinsfile')_ defaultIntegPipeline( - checkout: { - echo 'Custom Test Step' - git branch: "${env.GIT_BRANCH}", url: "${env.GIT_URL}" - } + gitUrl: 'https://github.com/lewijacn/opensearch-migrations.git', + gitBranch: 'checkin-jenkinsfile', + stage: 'test' +// checkout: { +// echo 'Custom Test Step' +// git branch: "${env.GIT_BRANCH}", url: "${env.GIT_URL}" +// } ) diff --git a/jenkins/sharedLibrary/vars/defaultIntegPipeline.groovy b/jenkins/sharedLibrary/vars/defaultIntegPipeline.groovy index b291a5fb9..4bfc737f1 100644 --- a/jenkins/sharedLibrary/vars/defaultIntegPipeline.groovy +++ b/jenkins/sharedLibrary/vars/defaultIntegPipeline.groovy @@ -51,14 +51,17 @@ def call(Map config = [:]) { """ def source_context_file_name = 'sourceJenkinsContext.json' def migration_context_file_name = 'migrationJenkinsContext.json' + def gitUrl = config.gitUrl ?: 'https://github.com/opensearch-project/opensearch-migrations.git' + def gitBranch = config.gitBranch ?: 'main' + def stage = config.stage ?: 'aws-integ' pipeline { agent { label config.overrideAgent ?: 'Jenkins-Default-Agent-X64-C5xlarge-Single-Host' } - parameters { - string(name: 'GIT_URL', defaultValue: 'https://github.com/opensearch-project/opensearch-migrations.git', description: 'Git URL') - string(name: 'GIT_BRANCH', defaultValue: 'main', description: 'Git branch') - string(name: 'STAGE', defaultValue: 'aws-integ', description: 'Deployment stage') - } +// parameters { +// string(name: 'GIT_URL', defaultValue: 'https://github.com/opensearch-project/opensearch-migrations.git', description: 'Git URL') +// string(name: 'GIT_BRANCH', defaultValue: 'main', description: 'Git branch') +// string(name: 'STAGE', defaultValue: 'aws-integ', description: 'Deployment stage') +// } // environment { // GIT_URL = config.overrideGitUrl ?: 'https://github.com/opensearch-project/opensearch-migrations.git' // GIT_BRANCH = config.overrideGitBranch ?: 'main' @@ -71,9 +74,9 @@ def call(Map config = [:]) { // if (config.checkout) { // config.checkout() // } else { -// git branch: "${params.GIT_BRANCH}", url: "${params.GIT_URL}" +// git branch: "${gitBranch}", url: "${gitUrl}" // } - git branch: "${params.GIT_BRANCH}", url: "${params.GIT_URL}" + git branch: "${gitBranch}", url: "${gitUrl}" } } @@ -105,7 +108,7 @@ def call(Map config = [:]) { dir('test') { sh 'sudo usermod -aG docker $USER' sh 'sudo newgrp docker' - sh "sudo ./awsE2ESolutionSetup.sh --source-context-file './$source_context_file_name' --migration-context-file './$migration_context_file_name' --source-context-id source-single-node-ec2 --migration-context-id migration-default --stage ${params.STAGE} --migrations-git-url ${params.GIT_URL} --migrations-git-branch ${params.GIT_BRANCH}" + sh "sudo ./awsE2ESolutionSetup.sh --source-context-file './$source_context_file_name' --migration-context-file './$migration_context_file_name' --source-context-id source-single-node-ec2 --migration-context-id migration-default --stage ${stage} --migrations-git-url ${gitUrl} --migrations-git-branch ${gitBranch}" } } } @@ -116,7 +119,7 @@ def call(Map config = [:]) { script { def time = new Date().getTime() def uniqueId = "integ_min_${time}_${currentBuild.number}" - sh "sudo ./awsRunIntegTests.sh --stage ${params.STAGE} --migrations-git-url ${params.GIT_URL} --migrations-git-branch ${params.GIT_BRANCH} --unique-id ${uniqueId}" + sh "sudo ./awsRunIntegTests.sh --stage ${stage} --migrations-git-url ${gitUrl} --migrations-git-branch ${gitBranch} --unique-id ${uniqueId}" } } @@ -126,7 +129,7 @@ def call(Map config = [:]) { post { always { dir('test') { - sh "sudo ./awsE2ESolutionSetup.sh --stage ${params.STAGE} --run-post-actions" + sh "sudo ./awsE2ESolutionSetup.sh --stage ${stage} --run-post-actions" } } } From 708df686f9f07c003f21effae967ba535dd70370 Mon Sep 17 00:00:00 2001 From: Tanner Lewis Date: Wed, 19 Jun 2024 12:37:05 -0400 Subject: [PATCH 14/34] Test shared lib Signed-off-by: Tanner Lewis --- .../vars/defaultIntegPipeline.groovy | 16 ---------------- 1 file changed, 16 deletions(-) diff --git a/jenkins/sharedLibrary/vars/defaultIntegPipeline.groovy b/jenkins/sharedLibrary/vars/defaultIntegPipeline.groovy index 4bfc737f1..93cc208eb 100644 --- a/jenkins/sharedLibrary/vars/defaultIntegPipeline.groovy +++ b/jenkins/sharedLibrary/vars/defaultIntegPipeline.groovy @@ -57,25 +57,9 @@ def call(Map config = [:]) { pipeline { agent { label config.overrideAgent ?: 'Jenkins-Default-Agent-X64-C5xlarge-Single-Host' } -// parameters { -// string(name: 'GIT_URL', defaultValue: 'https://github.com/opensearch-project/opensearch-migrations.git', description: 'Git URL') -// string(name: 'GIT_BRANCH', defaultValue: 'main', description: 'Git branch') -// string(name: 'STAGE', defaultValue: 'aws-integ', description: 'Deployment stage') -// } -// environment { -// GIT_URL = config.overrideGitUrl ?: 'https://github.com/opensearch-project/opensearch-migrations.git' -// GIT_BRANCH = config.overrideGitBranch ?: 'main' -// STAGE = config.overrideStage ?: 'aws-integ' -// } - stages { stage('Checkout') { steps { -// if (config.checkout) { -// config.checkout() -// } else { -// git branch: "${gitBranch}", url: "${gitUrl}" -// } git branch: "${gitBranch}", url: "${gitUrl}" } } From 3f6b900d2cb1bef7639f801faedf05cfcbcd85f3 Mon Sep 17 00:00:00 2001 From: Tanner Lewis Date: Wed, 19 Jun 2024 12:38:03 -0400 Subject: [PATCH 15/34] Test shared lib Signed-off-by: Tanner Lewis --- jenkins/sharedLibrary/vars/defaultIntegPipeline.groovy | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/jenkins/sharedLibrary/vars/defaultIntegPipeline.groovy b/jenkins/sharedLibrary/vars/defaultIntegPipeline.groovy index 93cc208eb..1071048c4 100644 --- a/jenkins/sharedLibrary/vars/defaultIntegPipeline.groovy +++ b/jenkins/sharedLibrary/vars/defaultIntegPipeline.groovy @@ -51,9 +51,9 @@ def call(Map config = [:]) { """ def source_context_file_name = 'sourceJenkinsContext.json' def migration_context_file_name = 'migrationJenkinsContext.json' - def gitUrl = config.gitUrl ?: 'https://github.com/opensearch-project/opensearch-migrations.git' - def gitBranch = config.gitBranch ?: 'main' - def stage = config.stage ?: 'aws-integ' + def gitUrl = 'https://github.com/opensearch-project/opensearch-migrations.git' + def gitBranch = 'main' + def stage = 'aws-integ' pipeline { agent { label config.overrideAgent ?: 'Jenkins-Default-Agent-X64-C5xlarge-Single-Host' } From 1abb6a49353f7f843ba9553857a20016b0b7bd85 Mon Sep 17 00:00:00 2001 From: Tanner Lewis Date: Wed, 19 Jun 2024 12:40:46 -0400 Subject: [PATCH 16/34] Test shared lib Signed-off-by: Tanner Lewis --- jenkins/sharedLibrary/vars/defaultIntegPipeline.groovy | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/jenkins/sharedLibrary/vars/defaultIntegPipeline.groovy b/jenkins/sharedLibrary/vars/defaultIntegPipeline.groovy index 1071048c4..cb79fec9e 100644 --- a/jenkins/sharedLibrary/vars/defaultIntegPipeline.groovy +++ b/jenkins/sharedLibrary/vars/defaultIntegPipeline.groovy @@ -53,7 +53,7 @@ def call(Map config = [:]) { def migration_context_file_name = 'migrationJenkinsContext.json' def gitUrl = 'https://github.com/opensearch-project/opensearch-migrations.git' def gitBranch = 'main' - def stage = 'aws-integ' + def stageId = 'aws-integ' pipeline { agent { label config.overrideAgent ?: 'Jenkins-Default-Agent-X64-C5xlarge-Single-Host' } @@ -92,7 +92,7 @@ def call(Map config = [:]) { dir('test') { sh 'sudo usermod -aG docker $USER' sh 'sudo newgrp docker' - sh "sudo ./awsE2ESolutionSetup.sh --source-context-file './$source_context_file_name' --migration-context-file './$migration_context_file_name' --source-context-id source-single-node-ec2 --migration-context-id migration-default --stage ${stage} --migrations-git-url ${gitUrl} --migrations-git-branch ${gitBranch}" + sh "sudo ./awsE2ESolutionSetup.sh --source-context-file './$source_context_file_name' --migration-context-file './$migration_context_file_name' --source-context-id source-single-node-ec2 --migration-context-id migration-default --stage ${stageId} --migrations-git-url ${gitUrl} --migrations-git-branch ${gitBranch}" } } } @@ -103,7 +103,7 @@ def call(Map config = [:]) { script { def time = new Date().getTime() def uniqueId = "integ_min_${time}_${currentBuild.number}" - sh "sudo ./awsRunIntegTests.sh --stage ${stage} --migrations-git-url ${gitUrl} --migrations-git-branch ${gitBranch} --unique-id ${uniqueId}" + sh "sudo ./awsRunIntegTests.sh --stage ${stageId} --migrations-git-url ${gitUrl} --migrations-git-branch ${gitBranch} --unique-id ${uniqueId}" } } @@ -113,7 +113,7 @@ def call(Map config = [:]) { post { always { dir('test') { - sh "sudo ./awsE2ESolutionSetup.sh --stage ${stage} --run-post-actions" + sh "sudo ./awsE2ESolutionSetup.sh --stage ${stageId} --run-post-actions" } } } From 24c0a37875095ab232d6020591b2103f540271b2 Mon Sep 17 00:00:00 2001 From: Tanner Lewis Date: Wed, 19 Jun 2024 12:45:37 -0400 Subject: [PATCH 17/34] Test shared lib Signed-off-by: Tanner Lewis --- jenkins/sharedLibrary/vars/defaultIntegPipeline.groovy | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/jenkins/sharedLibrary/vars/defaultIntegPipeline.groovy b/jenkins/sharedLibrary/vars/defaultIntegPipeline.groovy index cb79fec9e..982a5a790 100644 --- a/jenkins/sharedLibrary/vars/defaultIntegPipeline.groovy +++ b/jenkins/sharedLibrary/vars/defaultIntegPipeline.groovy @@ -51,9 +51,9 @@ def call(Map config = [:]) { """ def source_context_file_name = 'sourceJenkinsContext.json' def migration_context_file_name = 'migrationJenkinsContext.json' - def gitUrl = 'https://github.com/opensearch-project/opensearch-migrations.git' - def gitBranch = 'main' - def stageId = 'aws-integ' + def gitUrl = config.gitUrl ?: 'https://github.com/opensearch-project/opensearch-migrations.git' + def gitBranch = config.gitBranch ?: 'main' + def stageId = config.stageId ?: 'aws-integ' pipeline { agent { label config.overrideAgent ?: 'Jenkins-Default-Agent-X64-C5xlarge-Single-Host' } From 63eae8a8d1aaa2c94a5049a6f5de2de667c3bf8f Mon Sep 17 00:00:00 2001 From: Tanner Lewis Date: Wed, 19 Jun 2024 13:27:11 -0400 Subject: [PATCH 18/34] Test shared lib Signed-off-by: Tanner Lewis --- .../vars/defaultIntegPipeline.groovy | 59 +++---------------- 1 file changed, 7 insertions(+), 52 deletions(-) diff --git a/jenkins/sharedLibrary/vars/defaultIntegPipeline.groovy b/jenkins/sharedLibrary/vars/defaultIntegPipeline.groovy index 982a5a790..9068b983f 100644 --- a/jenkins/sharedLibrary/vars/defaultIntegPipeline.groovy +++ b/jenkins/sharedLibrary/vars/defaultIntegPipeline.groovy @@ -1,59 +1,14 @@ -// Note: -// 1. We are using an existing common VPC for now until we move to a proper Jenkins accounts and can create a setup without -// public subnets as well as request an extension to allow more than 5 VPCs per region -// 2. There is a still a manual step needed on the EC2 source load balancer to replace its security group rule which allows all traffic (0.0.0.0/0) to -// allow traffic for the relevant service security group. This needs a better story around accepting user security groups in our Migration CDK. def call(Map config = [:]) { - def source_cdk_context = """ - { - "source-single-node-ec2": { - "suffix": "ec2-source-", - "networkStackSuffix": "ec2-source-", - "vpcId": "vpc-07d3e089b8e9139e4", - "distVersion": "7.10.2", - "cidr": "12.0.0.0/16", - "distributionUrl": "https://artifacts.elastic.co/downloads/elasticsearch/elasticsearch-oss-7.10.2-linux-x86_64.tar.gz", - "captureProxyEnabled": true, - "securityDisabled": true, - "minDistribution": false, - "cpuArch": "x64", - "isInternal": true, - "singleNodeCluster": true, - "networkAvailabilityZones": 2, - "dataNodeCount": 1, - "managerNodeCount": 0, - "serverAccessType": "ipv4", - "restrictServerAccessTo": "0.0.0.0/0" - } - } - """ - def migration_cdk_context = """ - { - "migration-default": { - "stage": "", - "vpcId": "vpc-07d3e089b8e9139e4", - "engineVersion": "OS_2.11", - "domainName": "os-cluster-", - "dataNodeCount": 2, - "openAccessPolicyEnabled": true, - "domainRemovalPolicy": "DESTROY", - "artifactBucketRemovalPolicy": "DESTROY", - "trafficReplayerExtraArgs": "--speedup-factor 10.0", - "fetchMigrationEnabled": true, - "reindexFromSnapshotServiceEnabled": true, - "sourceClusterEndpoint": "", - "dpPipelineTemplatePath": "../../../test/dp_pipeline_aws_integ.yaml", - "migrationConsoleEnableOSI": true, - "migrationAPIEnabled": true - } - } - """ - def source_context_file_name = 'sourceJenkinsContext.json' - def migration_context_file_name = 'migrationJenkinsContext.json' + def source_cdk_context = config.sourceContext + def migration_cdk_context = config.migrationContext + def source_context_id = config.sourceContextId ?: 'source-single-node-ec2' + def migration_context_id = config.migrationContextId ?: 'migration-default' def gitUrl = config.gitUrl ?: 'https://github.com/opensearch-project/opensearch-migrations.git' def gitBranch = config.gitBranch ?: 'main' def stageId = config.stageId ?: 'aws-integ' + def source_context_file_name = 'sourceJenkinsContext.json' + def migration_context_file_name = 'migrationJenkinsContext.json' pipeline { agent { label config.overrideAgent ?: 'Jenkins-Default-Agent-X64-C5xlarge-Single-Host' } @@ -92,7 +47,7 @@ def call(Map config = [:]) { dir('test') { sh 'sudo usermod -aG docker $USER' sh 'sudo newgrp docker' - sh "sudo ./awsE2ESolutionSetup.sh --source-context-file './$source_context_file_name' --migration-context-file './$migration_context_file_name' --source-context-id source-single-node-ec2 --migration-context-id migration-default --stage ${stageId} --migrations-git-url ${gitUrl} --migrations-git-branch ${gitBranch}" + sh "sudo ./awsE2ESolutionSetup.sh --source-context-file './$source_context_file_name' --migration-context-file './$migration_context_file_name' --source-context-id $source_context_id --migration-context-id $migration_context_id --stage ${stageId} --migrations-git-url ${gitUrl} --migrations-git-branch ${gitBranch}" } } } From 81563a1ade9bb4255ddd542c4e395682ff6bd5bc Mon Sep 17 00:00:00 2001 From: Tanner Lewis Date: Wed, 19 Jun 2024 14:11:21 -0400 Subject: [PATCH 19/34] Test shared lib Signed-off-by: Tanner Lewis --- .../ec2SourceE2EPipeline.groovy | 66 +++++++++++++++++++ .../ec2SourceE2EPipeline.groovy | 11 ---- .../vars/defaultIntegPipeline.groovy | 32 +++++++-- 3 files changed, 91 insertions(+), 18 deletions(-) create mode 100644 jenkins/migrationIntegPipelines/ec2SourceE2EPipeline.groovy delete mode 100644 jenkins/migrationPipelines/ec2SourceE2EPipeline.groovy diff --git a/jenkins/migrationIntegPipelines/ec2SourceE2EPipeline.groovy b/jenkins/migrationIntegPipelines/ec2SourceE2EPipeline.groovy new file mode 100644 index 000000000..f9bfc09e2 --- /dev/null +++ b/jenkins/migrationIntegPipelines/ec2SourceE2EPipeline.groovy @@ -0,0 +1,66 @@ +// Note: +// 1. We are using an existing common VPC for now until we move to a proper Jenkins accounts and can create a setup without +// public subnets as well as request an extension to allow more than 5 VPCs per region +// 2. There is a still a manual step needed on the EC2 source load balancer to replace its security group rule which allows all traffic (0.0.0.0/0) to +// allow traffic for the relevant service security group. This needs a better story around accepting user security groups in our Migration CDK. + +@Library('migrations-shared-lib@checkin-jenkinsfile')_ + +def source_cdk_context = """ + { + "source-single-node-ec2": { + "suffix": "ec2-source-", + "networkStackSuffix": "ec2-source-", + "vpcId": "vpc-07d3e089b8e9139e4", + "distVersion": "7.10.2", + "cidr": "12.0.0.0/16", + "distributionUrl": "https://artifacts.elastic.co/downloads/elasticsearch/elasticsearch-oss-7.10.2-linux-x86_64.tar.gz", + "captureProxyEnabled": true, + "securityDisabled": true, + "minDistribution": false, + "cpuArch": "x64", + "isInternal": true, + "singleNodeCluster": true, + "networkAvailabilityZones": 2, + "dataNodeCount": 1, + "managerNodeCount": 0, + "serverAccessType": "ipv4", + "restrictServerAccessTo": "0.0.0.0/0" + } + } + """ +def migration_cdk_context = """ + { + "migration-default": { + "stage": "", + "vpcId": "vpc-07d3e089b8e9139e4", + "engineVersion": "OS_2.11", + "domainName": "os-cluster-", + "dataNodeCount": 2, + "openAccessPolicyEnabled": true, + "domainRemovalPolicy": "DESTROY", + "artifactBucketRemovalPolicy": "DESTROY", + "trafficReplayerExtraArgs": "--speedup-factor 10.0", + "fetchMigrationEnabled": true, + "reindexFromSnapshotServiceEnabled": true, + "sourceClusterEndpoint": "", + "dpPipelineTemplatePath": "../../../test/dp_pipeline_aws_integ.yaml", + "migrationConsoleEnableOSI": true, + "migrationAPIEnabled": true + } + } +""" + +defaultIntegPipeline( + sourceContext: source_cdk_context, + migrationContext: migration_cdk_context, + sourceContextId: 'source-single-node-ec2', + migrationContextId: 'migration-default', + gitUrl: 'https://github.com/lewijacn/opensearch-migrations.git', + gitBranch: 'checkin-jenkinsfile', + stageId: 'test' +// checkout: { +// echo 'Custom Test Step' +// git branch: "${env.GIT_BRANCH}", url: "${env.GIT_URL}" +// } +) diff --git a/jenkins/migrationPipelines/ec2SourceE2EPipeline.groovy b/jenkins/migrationPipelines/ec2SourceE2EPipeline.groovy deleted file mode 100644 index e296c3a9f..000000000 --- a/jenkins/migrationPipelines/ec2SourceE2EPipeline.groovy +++ /dev/null @@ -1,11 +0,0 @@ -@Library('migrations-shared-lib@checkin-jenkinsfile')_ - -defaultIntegPipeline( - gitUrl: 'https://github.com/lewijacn/opensearch-migrations.git', - gitBranch: 'checkin-jenkinsfile', - stage: 'test' -// checkout: { -// echo 'Custom Test Step' -// git branch: "${env.GIT_BRANCH}", url: "${env.GIT_URL}" -// } -) diff --git a/jenkins/sharedLibrary/vars/defaultIntegPipeline.groovy b/jenkins/sharedLibrary/vars/defaultIntegPipeline.groovy index 9068b983f..5f5c744dd 100644 --- a/jenkins/sharedLibrary/vars/defaultIntegPipeline.groovy +++ b/jenkins/sharedLibrary/vars/defaultIntegPipeline.groovy @@ -2,6 +2,12 @@ def call(Map config = [:]) { def source_cdk_context = config.sourceContext def migration_cdk_context = config.migrationContext + if(source_cdk_context == null || source_cdk_context.isEmpty()){ + throw new RuntimeException("The sourceContext argument must be provided"); + } + if(migration_cdk_context == null || migration_cdk_context.isEmpty()){ + throw new RuntimeException("The migrationContext argument must be provided"); + } def source_context_id = config.sourceContextId ?: 'source-single-node-ec2' def migration_context_id = config.migrationContextId ?: 'migration-default' def gitUrl = config.gitUrl ?: 'https://github.com/opensearch-project/opensearch-migrations.git' @@ -10,7 +16,7 @@ def call(Map config = [:]) { def source_context_file_name = 'sourceJenkinsContext.json' def migration_context_file_name = 'migrationJenkinsContext.json' pipeline { - agent { label config.overrideAgent ?: 'Jenkins-Default-Agent-X64-C5xlarge-Single-Host' } + agent { label config.workerAgent ?: 'Jenkins-Default-Agent-X64-C5xlarge-Single-Host' } stages { stage('Checkout') { @@ -45,9 +51,16 @@ def call(Map config = [:]) { stage('Deploy') { steps { dir('test') { - sh 'sudo usermod -aG docker $USER' - sh 'sudo newgrp docker' - sh "sudo ./awsE2ESolutionSetup.sh --source-context-file './$source_context_file_name' --migration-context-file './$migration_context_file_name' --source-context-id $source_context_id --migration-context-id $migration_context_id --stage ${stageId} --migrations-git-url ${gitUrl} --migrations-git-branch ${gitBranch}" + script { + // Allow overwriting this step + if (config.deployStep) { + config.deployStep() + } else { + sh 'sudo usermod -aG docker $USER' + sh 'sudo newgrp docker' + sh "sudo ./awsE2ESolutionSetup.sh --source-context-file './$source_context_file_name' --migration-context-file './$migration_context_file_name' --source-context-id $source_context_id --migration-context-id $migration_context_id --stage ${stageId} --migrations-git-url ${gitUrl} --migrations-git-branch ${gitBranch}" + } + } } } } @@ -56,9 +69,14 @@ def call(Map config = [:]) { steps { dir('test') { script { - def time = new Date().getTime() - def uniqueId = "integ_min_${time}_${currentBuild.number}" - sh "sudo ./awsRunIntegTests.sh --stage ${stageId} --migrations-git-url ${gitUrl} --migrations-git-branch ${gitBranch} --unique-id ${uniqueId}" + // Allow overwriting this step + if (config.integTestStep) { + config.integTestStep() + } else { + def time = new Date().getTime() + def uniqueId = "integ_min_${time}_${currentBuild.number}" + sh "sudo ./awsRunIntegTests.sh --stage ${stageId} --migrations-git-url ${gitUrl} --migrations-git-branch ${gitBranch} --unique-id ${uniqueId}" + } } } From ff62416019718a9a6ad8502deb81a323c8d0fa95 Mon Sep 17 00:00:00 2001 From: Tanner Lewis Date: Wed, 19 Jun 2024 14:35:07 -0400 Subject: [PATCH 20/34] Test shared lib Signed-off-by: Tanner Lewis --- .../ec2SourceE2EPipeline.groovy | 29 +++++++++++-------- 1 file changed, 17 insertions(+), 12 deletions(-) diff --git a/jenkins/migrationIntegPipelines/ec2SourceE2EPipeline.groovy b/jenkins/migrationIntegPipelines/ec2SourceE2EPipeline.groovy index f9bfc09e2..e7ce4b5e5 100644 --- a/jenkins/migrationIntegPipelines/ec2SourceE2EPipeline.groovy +++ b/jenkins/migrationIntegPipelines/ec2SourceE2EPipeline.groovy @@ -4,8 +4,11 @@ // 2. There is a still a manual step needed on the EC2 source load balancer to replace its security group rule which allows all traffic (0.0.0.0/0) to // allow traffic for the relevant service security group. This needs a better story around accepting user security groups in our Migration CDK. -@Library('migrations-shared-lib@checkin-jenkinsfile')_ - +def sourceContextId = 'source-single-node-ec2' +def migrationContextId = 'migration-default' +def gitUrl = 'https://github.com/lewijacn/opensearch-migrations.git' +def gitBranch = 'checkin-jenkinsfile' +def stageId = 'test' def source_cdk_context = """ { "source-single-node-ec2": { @@ -28,7 +31,7 @@ def source_cdk_context = """ "restrictServerAccessTo": "0.0.0.0/0" } } - """ +""" def migration_cdk_context = """ { "migration-default": { @@ -50,17 +53,19 @@ def migration_cdk_context = """ } } """ +// This library declaration likely needs to change in the near future to be more dynamic in picking up library +// changes that may have happened on the given branch being tested +@Library("migrations-shared-lib@checkin-jenkinsfile")_ defaultIntegPipeline( sourceContext: source_cdk_context, migrationContext: migration_cdk_context, - sourceContextId: 'source-single-node-ec2', - migrationContextId: 'migration-default', - gitUrl: 'https://github.com/lewijacn/opensearch-migrations.git', - gitBranch: 'checkin-jenkinsfile', - stageId: 'test' -// checkout: { -// echo 'Custom Test Step' -// git branch: "${env.GIT_BRANCH}", url: "${env.GIT_URL}" -// } + sourceContextId: sourceContextId, + migrationContextId: migrationContextId, + gitUrl: gitUrl, + gitBranch: gitBranch, + stageId: stageId + //deployStep: { + // echo 'Custom Test Step' + //} ) From 3c7ad9dcf647ed48d0a6da9ea786b3d79500247e Mon Sep 17 00:00:00 2001 From: Tanner Lewis Date: Wed, 19 Jun 2024 15:23:21 -0400 Subject: [PATCH 21/34] Test shared lib Signed-off-by: Tanner Lewis --- .../ec2SourceE2EPipeline.groovy | 6 +- .../rfsBackfillE2EPipeline.groovy | 67 +++++++++++++++++++ .../vars/defaultIntegPipeline.groovy | 9 ++- 3 files changed, 78 insertions(+), 4 deletions(-) create mode 100644 jenkins/migrationIntegPipelines/rfsBackfillE2EPipeline.groovy diff --git a/jenkins/migrationIntegPipelines/ec2SourceE2EPipeline.groovy b/jenkins/migrationIntegPipelines/ec2SourceE2EPipeline.groovy index e7ce4b5e5..3e28de3e1 100644 --- a/jenkins/migrationIntegPipelines/ec2SourceE2EPipeline.groovy +++ b/jenkins/migrationIntegPipelines/ec2SourceE2EPipeline.groovy @@ -8,13 +8,13 @@ def sourceContextId = 'source-single-node-ec2' def migrationContextId = 'migration-default' def gitUrl = 'https://github.com/lewijacn/opensearch-migrations.git' def gitBranch = 'checkin-jenkinsfile' -def stageId = 'test' +def stageId = 'aws-integ' def source_cdk_context = """ { "source-single-node-ec2": { "suffix": "ec2-source-", "networkStackSuffix": "ec2-source-", - "vpcId": "vpc-07d3e089b8e9139e4", + "vpcId": "$vpcId", "distVersion": "7.10.2", "cidr": "12.0.0.0/16", "distributionUrl": "https://artifacts.elastic.co/downloads/elasticsearch/elasticsearch-oss-7.10.2-linux-x86_64.tar.gz", @@ -36,7 +36,7 @@ def migration_cdk_context = """ { "migration-default": { "stage": "", - "vpcId": "vpc-07d3e089b8e9139e4", + "vpcId": "$vpcId", "engineVersion": "OS_2.11", "domainName": "os-cluster-", "dataNodeCount": 2, diff --git a/jenkins/migrationIntegPipelines/rfsBackfillE2EPipeline.groovy b/jenkins/migrationIntegPipelines/rfsBackfillE2EPipeline.groovy new file mode 100644 index 000000000..c50fbdfaf --- /dev/null +++ b/jenkins/migrationIntegPipelines/rfsBackfillE2EPipeline.groovy @@ -0,0 +1,67 @@ +// Note: +// 1. We are using an existing common VPC for now until we move to a proper Jenkins accounts and can create a setup without +// public subnets as well as request an extension to allow more than 5 VPCs per region +// 2. There is a still a manual step needed on the EC2 source load balancer to replace its security group rule which allows all traffic (0.0.0.0/0) to +// allow traffic for the relevant service security group. This needs a better story around accepting user security groups in our Migration CDK. + +def sourceContextId = 'source-single-node-ec2' +def migrationContextId = 'migration-rfs' +def gitUrl = 'https://github.com/lewijacn/opensearch-migrations.git' +def gitBranch = 'checkin-jenkinsfile' +def stageId = 'rfs-integ' +def source_cdk_context = """ + { + "source-single-node-ec2": { + "suffix": "ec2-source-", + "networkStackSuffix": "ec2-source-", + "vpcId": "$vpcId", + "distVersion": "7.10.2", + "distributionUrl": "https://artifacts.elastic.co/downloads/elasticsearch/elasticsearch-oss-7.10.2-linux-x86_64.tar.gz", + "captureProxyEnabled": false, + "securityDisabled": true, + "minDistribution": false, + "cpuArch": "x64", + "isInternal": true, + "singleNodeCluster": true, + "networkAvailabilityZones": 2, + "dataNodeCount": 1, + "managerNodeCount": 0, + "serverAccessType": "ipv4", + "restrictServerAccessTo": "0.0.0.0/0" + } + } +""" +def migration_cdk_context = """ + { + "migration-rfs": { + "stage": "", + "vpcId": "$vpcId", + "engineVersion": "OS_2.11", + "domainName": "os-cluster-", + "dataNodeCount": 2, + "openAccessPolicyEnabled": true, + "domainRemovalPolicy": "DESTROY", + "artifactBucketRemovalPolicy": "DESTROY", + "kafkaBrokerServiceEnabled": true, + "trafficReplayerServiceEnabled": false, + "reindexFromSnapshotServiceEnabled": true, + "sourceClusterEndpoint": "" + } + } +""" +// This library declaration likely needs to change in the near future to be more dynamic in picking up library +// changes that may have happened on the given branch being tested +@Library("migrations-shared-lib@checkin-jenkinsfile")_ + +defaultIntegPipeline( + sourceContext: source_cdk_context, + migrationContext: migration_cdk_context, + sourceContextId: sourceContextId, + migrationContextId: migrationContextId, + gitUrl: gitUrl, + gitBranch: gitBranch, + stageId: stageId + //deployStep: { + // echo 'Custom Test Step' + //} +) diff --git a/jenkins/sharedLibrary/vars/defaultIntegPipeline.groovy b/jenkins/sharedLibrary/vars/defaultIntegPipeline.groovy index 5f5c744dd..eb943724b 100644 --- a/jenkins/sharedLibrary/vars/defaultIntegPipeline.groovy +++ b/jenkins/sharedLibrary/vars/defaultIntegPipeline.groovy @@ -86,7 +86,14 @@ def call(Map config = [:]) { post { always { dir('test') { - sh "sudo ./awsE2ESolutionSetup.sh --stage ${stageId} --run-post-actions" + script { + // Allow overwriting this step + if (config.finishStep) { + config.finishStep() + } else { + sh "sudo ./awsE2ESolutionSetup.sh --stage ${stageId} --run-post-actions" + } + } } } } From ff1d9ac9be7f1f071517e61571320bdf4126b91d Mon Sep 17 00:00:00 2001 From: Tanner Lewis Date: Wed, 19 Jun 2024 15:33:44 -0400 Subject: [PATCH 22/34] Update pipeline files for main Signed-off-by: Tanner Lewis --- .../ec2SourceE2EPipeline.groovy | 4 +- .../rfsBackfillE2EPipeline.groovy | 4 +- jenkinsdocker/defaultStructure.groovy | 125 ------------------ jenkinsdocker/e2eSetup.jenkinsFile | 16 --- 4 files changed, 4 insertions(+), 145 deletions(-) delete mode 100644 jenkinsdocker/defaultStructure.groovy delete mode 100644 jenkinsdocker/e2eSetup.jenkinsFile diff --git a/jenkins/migrationIntegPipelines/ec2SourceE2EPipeline.groovy b/jenkins/migrationIntegPipelines/ec2SourceE2EPipeline.groovy index 3e28de3e1..337367946 100644 --- a/jenkins/migrationIntegPipelines/ec2SourceE2EPipeline.groovy +++ b/jenkins/migrationIntegPipelines/ec2SourceE2EPipeline.groovy @@ -6,8 +6,8 @@ def sourceContextId = 'source-single-node-ec2' def migrationContextId = 'migration-default' -def gitUrl = 'https://github.com/lewijacn/opensearch-migrations.git' -def gitBranch = 'checkin-jenkinsfile' +def gitUrl = 'https://github.com/opensearch-project/opensearch-migrations.git' +def gitBranch = 'main' def stageId = 'aws-integ' def source_cdk_context = """ { diff --git a/jenkins/migrationIntegPipelines/rfsBackfillE2EPipeline.groovy b/jenkins/migrationIntegPipelines/rfsBackfillE2EPipeline.groovy index c50fbdfaf..7e4eb5606 100644 --- a/jenkins/migrationIntegPipelines/rfsBackfillE2EPipeline.groovy +++ b/jenkins/migrationIntegPipelines/rfsBackfillE2EPipeline.groovy @@ -6,8 +6,8 @@ def sourceContextId = 'source-single-node-ec2' def migrationContextId = 'migration-rfs' -def gitUrl = 'https://github.com/lewijacn/opensearch-migrations.git' -def gitBranch = 'checkin-jenkinsfile' +def gitUrl = 'https://github.com/opensearch-project/opensearch-migrations.git' +def gitBranch = 'main' def stageId = 'rfs-integ' def source_cdk_context = """ { diff --git a/jenkinsdocker/defaultStructure.groovy b/jenkinsdocker/defaultStructure.groovy deleted file mode 100644 index 93e0d855b..000000000 --- a/jenkinsdocker/defaultStructure.groovy +++ /dev/null @@ -1,125 +0,0 @@ -def source_cdk_context = """ -{ - "source-single-node-ec2": { - "suffix": "ec2-source-", - "networkStackSuffix": "ec2-source-", - "vpcId": "vpc-07d3e089b8e9139e4", - "distVersion": "7.10.2", - "cidr": "12.0.0.0/16", - "distributionUrl": "https://artifacts.elastic.co/downloads/elasticsearch/elasticsearch-oss-7.10.2-linux-x86_64.tar.gz", - "captureProxyEnabled": true, - "securityDisabled": true, - "minDistribution": false, - "cpuArch": "x64", - "isInternal": true, - "singleNodeCluster": true, - "networkAvailabilityZones": 2, - "dataNodeCount": 1, - "managerNodeCount": 0, - "serverAccessType": "ipv4", - "restrictServerAccessTo": "0.0.0.0/0" - } -} -""" -def migration_cdk_context = """ -{ - "migration-default": { - "stage": "", - "vpcId": "vpc-07d3e089b8e9139e4", - "engineVersion": "OS_2.11", - "domainName": "os-cluster-", - "dataNodeCount": 2, - "openAccessPolicyEnabled": true, - "domainRemovalPolicy": "DESTROY", - "artifactBucketRemovalPolicy": "DESTROY", - "trafficReplayerExtraArgs": "--speedup-factor 10.0", - "fetchMigrationEnabled": true, - "reindexFromSnapshotServiceEnabled": true, - "sourceClusterEndpoint": "", - "dpPipelineTemplatePath": "../../../test/dp_pipeline_aws_integ.yaml", - "migrationConsoleEnableOSI": true, - "migrationAPIEnabled": true - } -} -""" -def source_context_file_name = 'sourceJenkinsContext.json' -def migration_context_file_name = 'migrationJenkinsContext.json' -void call(Map arguments = [:], Closure body) { - pipeline { - environment { - // GIT_URL = 'https://github.com/mikaylathompson/opensearch-migrations.git' - // GIT_BRANCH = 'add-metric-verification-to-tests' - GIT_URL = 'https://github.com/opensearch-project/opensearch-migrations.git' - GIT_BRANCH = 'main' - STAGE = 'aws-integ' - } - - parameters { - string(name: 'BRANCH_NAME', defaultValue: 'main', description: 'The branch to build') - string(name: 'DEPLOY_STAGE', description: 'Deployment environment') - } - - agent { label 'Jenkins-Default-Agent-X64-C5xlarge-Single-Host' } - - stages { - stage('Checkout') { - steps { - git branch: "${env.GIT_BRANCH}", url: "${env.GIT_URL}" - } - } - - stage('Test Caller Identity') { - steps { - sh 'aws sts get-caller-identity' - } - } - - stage('Setup E2E CDK Context') { - steps { - writeFile (file: "test/$source_context_file_name", text: source_cdk_context) - sh "echo 'Using source context file options: ' && cat test/$source_context_file_name" - writeFile (file: "test/$migration_context_file_name", text: migration_cdk_context) - sh "echo 'Using migration context file options: ' && cat test/$migration_context_file_name" - } - } - - stage('Build') { - steps { - timeout(time: 1, unit: 'HOURS') { - sh 'sudo ./gradlew clean build' - } - } - } - - stage('Deploy') { - steps { - dir('test') { - sh 'sudo usermod -aG docker $USER' - sh 'sudo newgrp docker' - sh "sudo ./awsE2ESolutionSetup.sh --source-context-file './$source_context_file_name' --migration-context-file './$migration_context_file_name' --source-context-id source-single-node-ec2 --migration-context-id migration-default --stage ${env.STAGE} --migrations-git-url ${env.GIT_URL} --migrations-git-branch ${env.GIT_BRANCH}" - } - } - } - - stage('Integ Tests') { - steps { - dir('test') { - script { - def time = new Date().getTime() - def uniqueId = "integ_min_${time}_${currentBuild.number}" - sh "sudo ./awsRunIntegTests.sh --stage ${env.STAGE} --migrations-git-url ${env.GIT_URL} --migrations-git-branch ${env.GIT_BRANCH} --unique-id ${uniqueId}" - } - } - - } - } - } - post { - always { - dir('test') { - sh "sudo ./awsE2ESolutionSetup.sh --stage ${env.STAGE} --run-post-actions" - } - } - } - } -} diff --git a/jenkinsdocker/e2eSetup.jenkinsFile b/jenkinsdocker/e2eSetup.jenkinsFile deleted file mode 100644 index 1d5cd9d1e..000000000 --- a/jenkinsdocker/e2eSetup.jenkinsFile +++ /dev/null @@ -1,16 +0,0 @@ - -pipeline { - agent { label 'Jenkins-Default-Agent-X64-C5xlarge-Single-Host' } - - stages { - stage('Load Pipeline') { - steps { - script { - // Load and execute the pipeline from the helper script - def defaultStructure = load 'jenkins/migration-pipelines/defaultStructure.groovy' - defaultStructure.call() - } - } - } - } -} From 958fe73191076eb64ad41f1573066a75a9f25754 Mon Sep 17 00:00:00 2001 From: Tanner Lewis Date: Wed, 19 Jun 2024 15:42:47 -0400 Subject: [PATCH 23/34] Update comments Signed-off-by: Tanner Lewis --- jenkins/migrationIntegPipelines/ec2SourceE2EPipeline.groovy | 4 ++-- jenkins/migrationIntegPipelines/rfsBackfillE2EPipeline.groovy | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/jenkins/migrationIntegPipelines/ec2SourceE2EPipeline.groovy b/jenkins/migrationIntegPipelines/ec2SourceE2EPipeline.groovy index 337367946..777ad7d55 100644 --- a/jenkins/migrationIntegPipelines/ec2SourceE2EPipeline.groovy +++ b/jenkins/migrationIntegPipelines/ec2SourceE2EPipeline.groovy @@ -1,6 +1,6 @@ // Note: -// 1. We are using an existing common VPC for now until we move to a proper Jenkins accounts and can create a setup without -// public subnets as well as request an extension to allow more than 5 VPCs per region +// 1. We are using an existing common VPC that we provide through a 'vpcId' parameter on the pipeline for now until we move +// to a proper Jenkins accounts and can create a setup without public subnets as well as request an extension to allow more than 5 VPCs per region // 2. There is a still a manual step needed on the EC2 source load balancer to replace its security group rule which allows all traffic (0.0.0.0/0) to // allow traffic for the relevant service security group. This needs a better story around accepting user security groups in our Migration CDK. diff --git a/jenkins/migrationIntegPipelines/rfsBackfillE2EPipeline.groovy b/jenkins/migrationIntegPipelines/rfsBackfillE2EPipeline.groovy index 7e4eb5606..9e35b7a9c 100644 --- a/jenkins/migrationIntegPipelines/rfsBackfillE2EPipeline.groovy +++ b/jenkins/migrationIntegPipelines/rfsBackfillE2EPipeline.groovy @@ -1,6 +1,6 @@ // Note: -// 1. We are using an existing common VPC for now until we move to a proper Jenkins accounts and can create a setup without -// public subnets as well as request an extension to allow more than 5 VPCs per region +// 1. We are using an existing common VPC that we provide through a 'vpcId' parameter on the pipeline for now until we move +// to a proper Jenkins accounts and can create a setup without public subnets as well as request an extension to allow more than 5 VPCs per region // 2. There is a still a manual step needed on the EC2 source load balancer to replace its security group rule which allows all traffic (0.0.0.0/0) to // allow traffic for the relevant service security group. This needs a better story around accepting user security groups in our Migration CDK. From 6d5a5190e2ebbdb948479e32bb3265ae55aef369 Mon Sep 17 00:00:00 2001 From: Tanner Lewis Date: Wed, 19 Jun 2024 17:45:39 -0400 Subject: [PATCH 24/34] Update for testing Signed-off-by: Tanner Lewis --- .../migrationIntegPipelines/rfsBackfillE2EPipeline.groovy | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/jenkins/migrationIntegPipelines/rfsBackfillE2EPipeline.groovy b/jenkins/migrationIntegPipelines/rfsBackfillE2EPipeline.groovy index 9e35b7a9c..82f5946f9 100644 --- a/jenkins/migrationIntegPipelines/rfsBackfillE2EPipeline.groovy +++ b/jenkins/migrationIntegPipelines/rfsBackfillE2EPipeline.groovy @@ -21,13 +21,13 @@ def source_cdk_context = """ "securityDisabled": true, "minDistribution": false, "cpuArch": "x64", - "isInternal": true, + "isInternal": false, "singleNodeCluster": true, "networkAvailabilityZones": 2, "dataNodeCount": 1, "managerNodeCount": 0, - "serverAccessType": "ipv4", - "restrictServerAccessTo": "0.0.0.0/0" + "serverAccessType": "securityGroupId", + "restrictServerAccessTo": "sg-07ff03367fb0c372f" } } """ From 94071fc03979079e22d73145560dfd79e33c00b5 Mon Sep 17 00:00:00 2001 From: Tanner Lewis Date: Wed, 19 Jun 2024 17:57:12 -0400 Subject: [PATCH 25/34] Update backfill test Signed-off-by: Tanner Lewis --- .../migrationIntegPipelines/rfsBackfillE2EPipeline.groovy | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/jenkins/migrationIntegPipelines/rfsBackfillE2EPipeline.groovy b/jenkins/migrationIntegPipelines/rfsBackfillE2EPipeline.groovy index 82f5946f9..92ec421f1 100644 --- a/jenkins/migrationIntegPipelines/rfsBackfillE2EPipeline.groovy +++ b/jenkins/migrationIntegPipelines/rfsBackfillE2EPipeline.groovy @@ -60,8 +60,8 @@ defaultIntegPipeline( migrationContextId: migrationContextId, gitUrl: gitUrl, gitBranch: gitBranch, - stageId: stageId - //deployStep: { - // echo 'Custom Test Step' - //} + stageId: stageId, + finishStep: { + echo 'Skipping step for RFS' + } ) From ca798d565dc0d3938c8579b501655a993c1741e2 Mon Sep 17 00:00:00 2001 From: Tanner Lewis Date: Thu, 20 Jun 2024 11:11:00 -0400 Subject: [PATCH 26/34] Common functions added to console library Signed-off-by: Tanner Lewis --- .../docker-compose-console-only.yml | 3 +- .../lib/console_link/console_link/cli.py | 16 +++++ .../console_link/logic/clusters.py | 41 +++++++++++- .../console_link/models/cluster.py | 28 ++++++++- .../service-stacks/migration-console-stack.ts | 2 +- .../ec2SourceE2EPipeline.groovy | 3 +- .../rfsBackfillE2EPipeline.groovy | 3 +- .../vars/defaultIntegPipeline.groovy | 63 +++++++++++-------- 8 files changed, 123 insertions(+), 36 deletions(-) diff --git a/TrafficCapture/dockerSolution/src/main/docker/migrationConsole/docker-compose-console-only.yml b/TrafficCapture/dockerSolution/src/main/docker/migrationConsole/docker-compose-console-only.yml index cab04e97d..5392b0fda 100644 --- a/TrafficCapture/dockerSolution/src/main/docker/migrationConsole/docker-compose-console-only.yml +++ b/TrafficCapture/dockerSolution/src/main/docker/migrationConsole/docker-compose-console-only.yml @@ -15,7 +15,8 @@ services: # this is a convenience thing for testing -- it should be removed before this makes it to prod. - ./lib/console_link:/root/lib/console_link environment: - # Copy local AWS env variables to Docker container + # Copy local AWS env to Docker container + #- ~/.aws:/root/.aws - AWS_ACCESS_KEY_ID=${AWS_ACCESS_KEY_ID} - AWS_SECRET_ACCESS_KEY=${AWS_SECRET_ACCESS_KEY} - AWS_SESSION_TOKEN=${AWS_SESSION_TOKEN} diff --git a/TrafficCapture/dockerSolution/src/main/docker/migrationConsole/lib/console_link/console_link/cli.py b/TrafficCapture/dockerSolution/src/main/docker/migrationConsole/lib/console_link/console_link/cli.py index 1f6daa43d..73792f567 100644 --- a/TrafficCapture/dockerSolution/src/main/docker/migrationConsole/lib/console_link/console_link/cli.py +++ b/TrafficCapture/dockerSolution/src/main/docker/migrationConsole/lib/console_link/console_link/cli.py @@ -73,6 +73,22 @@ def cat_indices_cmd(ctx): click.echo(logic_clusters.cat_indices(ctx.env.target_cluster)) +@cluster_group.command(name="connection-check") +@click.pass_obj +def connection_check_cmd(ctx): + """Checks if a connection can be established to source and target clusters""" + click.echo("SOURCE CLUSTER") + click.echo(logic_clusters.connection_check(ctx.env.source_cluster)) + click.echo("TARGET CLUSTER") + click.echo(logic_clusters.connection_check(ctx.env.target_cluster)) + + +@cluster_group.command(name="run-test-benchmarks") +@click.pass_obj +def run_test_benchmarks_cmd(ctx): + """Run a series of OpenSearch Benchmark workloads against the source cluster""" + click.echo(logic_clusters.run_test_benchmarks(ctx.env.source_cluster)) + # ##################### REPLAYER ################### @cli.group(name="replayer") diff --git a/TrafficCapture/dockerSolution/src/main/docker/migrationConsole/lib/console_link/console_link/logic/clusters.py b/TrafficCapture/dockerSolution/src/main/docker/migrationConsole/lib/console_link/console_link/logic/clusters.py index c399cce7e..1ed3012c4 100644 --- a/TrafficCapture/dockerSolution/src/main/docker/migrationConsole/lib/console_link/console_link/logic/clusters.py +++ b/TrafficCapture/dockerSolution/src/main/docker/migrationConsole/lib/console_link/console_link/logic/clusters.py @@ -1,8 +1,45 @@ -from console_link.models.cluster import Cluster +from console_link.models.cluster import Cluster, HttpMethod +import logging + +logger = logging.getLogger(__name__) def cat_indices(cluster: Cluster, as_json=False): - as_json_suffix = "?format=json" if as_json else "" + as_json_suffix = "?format=json" if as_json else "?v" cat_indices_path = f"/_cat/indices{as_json_suffix}" r = cluster.call_api(cat_indices_path) return r.json() if as_json else r.content + + +def connection_check(cluster: Cluster): + cluster_details_path = "/" + caught_exception = None + r = None + try: + r = cluster.call_api(cluster_details_path, timeout=3) + except Exception as e: + caught_exception = e + logging.debug(f"Unable to access cluster: {cluster} with exception: {e}") + access_result = {} + if caught_exception is None: + response_json = r.json() + access_result['connection_message'] = "Successfully connected!" + access_result['cluster_version'] = response_json['version']['number'] + access_result['connection_established'] = True + else: + access_result['connection_message'] = f"Unable to connect to cluster with error: {caught_exception}" + access_result['connection_established'] = False + return access_result + + +def run_test_benchmarks(cluster: Cluster): + cluster.execute_benchmark_workload(workload="geonames") + cluster.execute_benchmark_workload(workload="http_logs") + cluster.execute_benchmark_workload(workload="nested") + cluster.execute_benchmark_workload(workload="nyc_taxis") + + +def clear_indices(cluster: Cluster): + clear_indices_path = "/*,-.*,-searchguard*,-sg7*" + r = cluster.call_api(clear_indices_path, method=HttpMethod.DELETE) + return r.content diff --git a/TrafficCapture/dockerSolution/src/main/docker/migrationConsole/lib/console_link/console_link/models/cluster.py b/TrafficCapture/dockerSolution/src/main/docker/migrationConsole/lib/console_link/console_link/models/cluster.py index ade376e45..b05aaafdd 100644 --- a/TrafficCapture/dockerSolution/src/main/docker/migrationConsole/lib/console_link/console_link/models/cluster.py +++ b/TrafficCapture/dockerSolution/src/main/docker/migrationConsole/lib/console_link/console_link/models/cluster.py @@ -4,6 +4,7 @@ from requests.auth import HTTPBasicAuth from cerberus import Validator import logging +import subprocess from console_link.models.schema_tools import contains_one_of requests.packages.urllib3.disable_warnings() # ignore: type @@ -76,6 +77,8 @@ def __init__(self, config: Dict) -> None: self.endpoint = config["endpoint"] if self.endpoint.startswith("https"): self.allow_insecure = config.get("allow_insecure", False) + else: + self.allow_insecure = True if 'no_auth' in config: self.auth_type = AuthMethod.NO_AUTH elif 'basic_auth' in config: @@ -84,7 +87,7 @@ def __init__(self, config: Dict) -> None: elif 'sigv4' in config: self.auth_type = AuthMethod.SIGV4 - def call_api(self, path, method: HttpMethod = HttpMethod.GET) -> requests.Response: + def call_api(self, path, method: HttpMethod = HttpMethod.GET, timeout=None) -> requests.Response: """ Calls an API on the cluster. """ @@ -105,7 +108,30 @@ def call_api(self, path, method: HttpMethod = HttpMethod.GET) -> requests.Respon f"{self.endpoint}{path}", verify=(not self.allow_insecure), auth=auth, + timeout=timeout ) logger.debug(f"Cluster API call request: {r.request}") r.raise_for_status() return r + + def execute_benchmark_workload(self, workload: str, + workload_params='target_throughput:0.5,bulk_size:10,bulk_indexing_clients:1,' + 'search_clients:1'): + client_options = "" + if not self.allow_insecure: + client_options += "use_ssl:true,verify_certs:false" + if self.auth_type == AuthMethod.BASIC_AUTH: + if self.auth_details['password'] is not None: + client_options += (f"basic_auth_user:{self.auth_details['username']}," + f"basic_auth_password:{self.auth_details['password']}") + else: + raise NotImplementedError(f"Auth type {self.auth_type} with AWS Secret ARN is not currently support " + f"for executing benchmark workloads") + elif self.auth_type == AuthMethod.SIGV4: + 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 " + f"--target-host={self.endpoint} --workload={workload} --pipeline=benchmark-only --test-mode " + f"--kill-running-processes --workload-params={workload_params} " + f"--client-options={client_options}", shell=True) diff --git a/deployment/cdk/opensearch-service-migration/lib/service-stacks/migration-console-stack.ts b/deployment/cdk/opensearch-service-migration/lib/service-stacks/migration-console-stack.ts index 434a93c19..b05d6c7c2 100644 --- a/deployment/cdk/opensearch-service-migration/lib/service-stacks/migration-console-stack.ts +++ b/deployment/cdk/opensearch-service-migration/lib/service-stacks/migration-console-stack.ts @@ -133,7 +133,7 @@ export class MigrationConsoleStack extends MigrationServiceCore { let servicePortMappings: PortMapping[]|undefined let serviceDiscoveryPort: number|undefined let serviceDiscoveryEnabled = false - let imageCommand: string[]|undefined + let imageCommand = ['/bin/sh', '-c', '/root/loadServicesFromParameterStore.sh'] const osClusterEndpoint = getMigrationStringParameterValue(this, { ...props, diff --git a/jenkins/migrationIntegPipelines/ec2SourceE2EPipeline.groovy b/jenkins/migrationIntegPipelines/ec2SourceE2EPipeline.groovy index 777ad7d55..4f47acdff 100644 --- a/jenkins/migrationIntegPipelines/ec2SourceE2EPipeline.groovy +++ b/jenkins/migrationIntegPipelines/ec2SourceE2EPipeline.groovy @@ -53,8 +53,7 @@ def migration_cdk_context = """ } } """ -// This library declaration likely needs to change in the near future to be more dynamic in picking up library -// changes that may have happened on the given branch being tested + @Library("migrations-shared-lib@checkin-jenkinsfile")_ defaultIntegPipeline( diff --git a/jenkins/migrationIntegPipelines/rfsBackfillE2EPipeline.groovy b/jenkins/migrationIntegPipelines/rfsBackfillE2EPipeline.groovy index 92ec421f1..3505da677 100644 --- a/jenkins/migrationIntegPipelines/rfsBackfillE2EPipeline.groovy +++ b/jenkins/migrationIntegPipelines/rfsBackfillE2EPipeline.groovy @@ -49,8 +49,7 @@ def migration_cdk_context = """ } } """ -// This library declaration likely needs to change in the near future to be more dynamic in picking up library -// changes that may have happened on the given branch being tested + @Library("migrations-shared-lib@checkin-jenkinsfile")_ defaultIntegPipeline( diff --git a/jenkins/sharedLibrary/vars/defaultIntegPipeline.groovy b/jenkins/sharedLibrary/vars/defaultIntegPipeline.groovy index eb943724b..a1c641e11 100644 --- a/jenkins/sharedLibrary/vars/defaultIntegPipeline.groovy +++ b/jenkins/sharedLibrary/vars/defaultIntegPipeline.groovy @@ -1,4 +1,8 @@ - +// The parent 'vars' folder is not at the root of the repo which presents issues for Jenkins to dynamically load +// this library for a given branch in our pipelines, as Jenkins typically expects a shared library to be its own +// repository. This means that if a branch makes changes to this shared library and also wants to use those changes +// in a given pipeline, the library version declaration will need to be manually updated to that branch. Potentially, +// this issue could be resolved by simply moving this 'vars' folder to the repo root. def call(Map config = [:]) { def source_cdk_context = config.sourceContext def migration_cdk_context = config.migrationContext @@ -50,15 +54,17 @@ def call(Map config = [:]) { stage('Deploy') { steps { - dir('test') { - script { - // Allow overwriting this step - if (config.deployStep) { - config.deployStep() - } else { - sh 'sudo usermod -aG docker $USER' - sh 'sudo newgrp docker' - sh "sudo ./awsE2ESolutionSetup.sh --source-context-file './$source_context_file_name' --migration-context-file './$migration_context_file_name' --source-context-id $source_context_id --migration-context-id $migration_context_id --stage ${stageId} --migrations-git-url ${gitUrl} --migrations-git-branch ${gitBranch}" + timeout(time: 90, unit: 'MINUTES') { + dir('test') { + script { + // Allow overwriting this step + if (config.deployStep) { + config.deployStep() + } else { + sh 'sudo usermod -aG docker $USER' + sh 'sudo newgrp docker' + sh "sudo ./awsE2ESolutionSetup.sh --source-context-file './$source_context_file_name' --migration-context-file './$migration_context_file_name' --source-context-id $source_context_id --migration-context-id $migration_context_id --stage ${stageId} --migrations-git-url ${gitUrl} --migrations-git-branch ${gitBranch}" + } } } } @@ -67,31 +73,34 @@ def call(Map config = [:]) { stage('Integ Tests') { steps { - dir('test') { - script { - // Allow overwriting this step - if (config.integTestStep) { - config.integTestStep() - } else { - def time = new Date().getTime() - def uniqueId = "integ_min_${time}_${currentBuild.number}" - sh "sudo ./awsRunIntegTests.sh --stage ${stageId} --migrations-git-url ${gitUrl} --migrations-git-branch ${gitBranch} --unique-id ${uniqueId}" + timeout(time: 1, unit: 'HOURS') { + dir('test') { + script { + // Allow overwriting this step + if (config.integTestStep) { + config.integTestStep() + } else { + def time = new Date().getTime() + def uniqueId = "integ_min_${time}_${currentBuild.number}" + sh "sudo ./awsRunIntegTests.sh --stage ${stageId} --migrations-git-url ${gitUrl} --migrations-git-branch ${gitBranch} --unique-id ${uniqueId}" + } } } } - } } } post { always { - dir('test') { - script { - // Allow overwriting this step - if (config.finishStep) { - config.finishStep() - } else { - sh "sudo ./awsE2ESolutionSetup.sh --stage ${stageId} --run-post-actions" + timeout(time: 10, unit: 'MINUTES') { + dir('test') { + script { + // Allow overwriting this step + if (config.finishStep) { + config.finishStep() + } else { + sh "sudo ./awsE2ESolutionSetup.sh --stage ${stageId} --run-post-actions" + } } } } From b08cdc12f9e7305bfba3d2488f4ed1d2460f3521 Mon Sep 17 00:00:00 2001 From: Tanner Lewis Date: Thu, 20 Jun 2024 11:20:03 -0400 Subject: [PATCH 27/34] Minor fixes Signed-off-by: Tanner Lewis --- .../migrationConsole/lib/console_link/console_link/cli.py | 1 + .../lib/console_link/console_link/logic/clusters.py | 1 + .../migrationIntegPipelines/ec2SourceE2EPipeline.groovy | 2 +- .../migrationIntegPipelines/rfsBackfillE2EPipeline.groovy | 8 ++++---- 4 files changed, 7 insertions(+), 5 deletions(-) diff --git a/TrafficCapture/dockerSolution/src/main/docker/migrationConsole/lib/console_link/console_link/cli.py b/TrafficCapture/dockerSolution/src/main/docker/migrationConsole/lib/console_link/console_link/cli.py index 73792f567..c92945117 100644 --- a/TrafficCapture/dockerSolution/src/main/docker/migrationConsole/lib/console_link/console_link/cli.py +++ b/TrafficCapture/dockerSolution/src/main/docker/migrationConsole/lib/console_link/console_link/cli.py @@ -91,6 +91,7 @@ def run_test_benchmarks_cmd(ctx): # ##################### REPLAYER ################### + @cli.group(name="replayer") @click.pass_obj def replayer_group(ctx): diff --git a/TrafficCapture/dockerSolution/src/main/docker/migrationConsole/lib/console_link/console_link/logic/clusters.py b/TrafficCapture/dockerSolution/src/main/docker/migrationConsole/lib/console_link/console_link/logic/clusters.py index 1ed3012c4..832a4748a 100644 --- a/TrafficCapture/dockerSolution/src/main/docker/migrationConsole/lib/console_link/console_link/logic/clusters.py +++ b/TrafficCapture/dockerSolution/src/main/docker/migrationConsole/lib/console_link/console_link/logic/clusters.py @@ -39,6 +39,7 @@ def run_test_benchmarks(cluster: Cluster): cluster.execute_benchmark_workload(workload="nyc_taxis") +# As a default we exclude system indices and searchguard indices def clear_indices(cluster: Cluster): clear_indices_path = "/*,-.*,-searchguard*,-sg7*" r = cluster.call_api(clear_indices_path, method=HttpMethod.DELETE) diff --git a/jenkins/migrationIntegPipelines/ec2SourceE2EPipeline.groovy b/jenkins/migrationIntegPipelines/ec2SourceE2EPipeline.groovy index 4f47acdff..5bbe222b6 100644 --- a/jenkins/migrationIntegPipelines/ec2SourceE2EPipeline.groovy +++ b/jenkins/migrationIntegPipelines/ec2SourceE2EPipeline.groovy @@ -54,7 +54,7 @@ def migration_cdk_context = """ } """ -@Library("migrations-shared-lib@checkin-jenkinsfile")_ +@Library("migrations-shared-lib@main")_ defaultIntegPipeline( sourceContext: source_cdk_context, diff --git a/jenkins/migrationIntegPipelines/rfsBackfillE2EPipeline.groovy b/jenkins/migrationIntegPipelines/rfsBackfillE2EPipeline.groovy index 3505da677..224852dfc 100644 --- a/jenkins/migrationIntegPipelines/rfsBackfillE2EPipeline.groovy +++ b/jenkins/migrationIntegPipelines/rfsBackfillE2EPipeline.groovy @@ -21,13 +21,13 @@ def source_cdk_context = """ "securityDisabled": true, "minDistribution": false, "cpuArch": "x64", - "isInternal": false, + "isInternal": true, "singleNodeCluster": true, "networkAvailabilityZones": 2, "dataNodeCount": 1, "managerNodeCount": 0, - "serverAccessType": "securityGroupId", - "restrictServerAccessTo": "sg-07ff03367fb0c372f" + "serverAccessType": "ipv4", + "restrictServerAccessTo": "0.0.0.0/0" } } """ @@ -50,7 +50,7 @@ def migration_cdk_context = """ } """ -@Library("migrations-shared-lib@checkin-jenkinsfile")_ +@Library("migrations-shared-lib@main")_ defaultIntegPipeline( sourceContext: source_cdk_context, From 32dd6f7cc45f2d77569b9ead2c09a3e9c9c173da Mon Sep 17 00:00:00 2001 From: Tanner Lewis Date: Fri, 21 Jun 2024 10:46:15 -0400 Subject: [PATCH 28/34] PR feedback part 1 Signed-off-by: Tanner Lewis --- .../lib/console_link/console_link/cli.py | 11 ++++++++++ .../console_link/logic/clusters.py | 21 ++++++++++++------- 2 files changed, 25 insertions(+), 7 deletions(-) diff --git a/TrafficCapture/dockerSolution/src/main/docker/migrationConsole/lib/console_link/console_link/cli.py b/TrafficCapture/dockerSolution/src/main/docker/migrationConsole/lib/console_link/console_link/cli.py index c92945117..45d4753d3 100644 --- a/TrafficCapture/dockerSolution/src/main/docker/migrationConsole/lib/console_link/console_link/cli.py +++ b/TrafficCapture/dockerSolution/src/main/docker/migrationConsole/lib/console_link/console_link/cli.py @@ -89,6 +89,17 @@ def run_test_benchmarks_cmd(ctx): """Run a series of OpenSearch Benchmark workloads against the source cluster""" click.echo(logic_clusters.run_test_benchmarks(ctx.env.source_cluster)) + +@cluster_group.command(name="clear-indices") +@click.option('--cluster',type=click.Choice(['source', 'target'], case_sensitive=False)) +@click.pass_obj +def clear_indices_cmd(ctx, cluster): + """[Caution] Clear indices on a source or target cluster""" + if click.confirm('Do you want to continue?'): + click.echo('Well done!') + cluster_focus = ctx.env.source_cluster if cluster.lower() == 'source' else ctx.env.target_cluster + click.echo(logic_clusters.clear_indices(cluster_focus)) + # ##################### REPLAYER ################### diff --git a/TrafficCapture/dockerSolution/src/main/docker/migrationConsole/lib/console_link/console_link/logic/clusters.py b/TrafficCapture/dockerSolution/src/main/docker/migrationConsole/lib/console_link/console_link/logic/clusters.py index 832a4748a..062b54c9f 100644 --- a/TrafficCapture/dockerSolution/src/main/docker/migrationConsole/lib/console_link/console_link/logic/clusters.py +++ b/TrafficCapture/dockerSolution/src/main/docker/migrationConsole/lib/console_link/console_link/logic/clusters.py @@ -1,8 +1,15 @@ from console_link.models.cluster import Cluster, HttpMethod +from dataclasses import dataclass import logging logger = logging.getLogger(__name__) +@dataclass +class ConnectionResult: + connection_message: str + connection_established: bool + cluster_version: str + def cat_indices(cluster: Cluster, as_json=False): as_json_suffix = "?format=json" if as_json else "?v" @@ -11,7 +18,7 @@ def cat_indices(cluster: Cluster, as_json=False): return r.json() if as_json else r.content -def connection_check(cluster: Cluster): +def connection_check(cluster: Cluster) -> ConnectionResult: cluster_details_path = "/" caught_exception = None r = None @@ -23,13 +30,13 @@ def connection_check(cluster: Cluster): access_result = {} if caught_exception is None: response_json = r.json() - access_result['connection_message'] = "Successfully connected!" - access_result['cluster_version'] = response_json['version']['number'] - access_result['connection_established'] = True + return ConnectionResult(connection_message="Successfully connected!", + connection_established=True, + cluster_version=response_json['version']['number']) else: - access_result['connection_message'] = f"Unable to connect to cluster with error: {caught_exception}" - access_result['connection_established'] = False - return access_result + return ConnectionResult(connection_message=f"Unable to connect to cluster with error: {caught_exception}", + connection_established=False, + cluster_version=None) def run_test_benchmarks(cluster: Cluster): From 9b5993a72a482cd55d18ab2a048c39a1c2d5cee3 Mon Sep 17 00:00:00 2001 From: Tanner Lewis Date: Fri, 21 Jun 2024 11:07:38 -0400 Subject: [PATCH 29/34] PR feedback part 2 Signed-off-by: Tanner Lewis --- .../lib/console_link/console_link/cli.py | 25 +++++++++++++------ 1 file changed, 18 insertions(+), 7 deletions(-) diff --git a/TrafficCapture/dockerSolution/src/main/docker/migrationConsole/lib/console_link/console_link/cli.py b/TrafficCapture/dockerSolution/src/main/docker/migrationConsole/lib/console_link/console_link/cli.py index 45d4753d3..b0e733861 100644 --- a/TrafficCapture/dockerSolution/src/main/docker/migrationConsole/lib/console_link/console_link/cli.py +++ b/TrafficCapture/dockerSolution/src/main/docker/migrationConsole/lib/console_link/console_link/cli.py @@ -25,7 +25,7 @@ def __init__(self, config_file) -> None: @click.group() @click.option( - "--config-file", default="/etc/migration_services.yaml", help="Path to config file" + "--config-file", default="/Volumes/workplace/opensearch/lewijacn-migrations/opensearch-migrations/TrafficCapture/dockerSolution/src/main/docker/migrationConsole/lib/console_link/services.yaml", help="Path to config file" ) @click.option("--json", is_flag=True) @click.option('-v', '--verbose', count=True, help="Verbosity level. Default is warn, -v is info, -vv is debug.") @@ -91,14 +91,25 @@ def run_test_benchmarks_cmd(ctx): @cluster_group.command(name="clear-indices") -@click.option('--cluster',type=click.Choice(['source', 'target'], case_sensitive=False)) -@click.pass_obj -def clear_indices_cmd(ctx, cluster): +@click.option("--acknowledge-risk", is_flag=True, show_default=True, default=False, + help="Flag to acknowledge risk and skip confirmation") +@click.option('--cluster', + type=click.Choice(['source', 'target'], case_sensitive=False), + help="Cluster to perform clear indices action on", + required=True) +@click.pass_obj +def clear_indices_cmd(ctx, acknowledge_risk, cluster): """[Caution] Clear indices on a source or target cluster""" - if click.confirm('Do you want to continue?'): - click.echo('Well done!') cluster_focus = ctx.env.source_cluster if cluster.lower() == 'source' else ctx.env.target_cluster - click.echo(logic_clusters.clear_indices(cluster_focus)) + if acknowledge_risk: + 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?'): + click.echo("Performing clear indices operation...") + click.echo(logic_clusters.clear_indices(cluster_focus)) + else: + click.echo("Aborting command.") # ##################### REPLAYER ################### From 02d955128047b751f95368285978fae9aa11a91e Mon Sep 17 00:00:00 2001 From: Tanner Lewis Date: Fri, 21 Jun 2024 11:14:58 -0400 Subject: [PATCH 30/34] Remove user string Signed-off-by: Tanner Lewis --- .../migrationConsole/lib/console_link/console_link/cli.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/TrafficCapture/dockerSolution/src/main/docker/migrationConsole/lib/console_link/console_link/cli.py b/TrafficCapture/dockerSolution/src/main/docker/migrationConsole/lib/console_link/console_link/cli.py index 748e71c8c..f9f35bfbd 100644 --- a/TrafficCapture/dockerSolution/src/main/docker/migrationConsole/lib/console_link/console_link/cli.py +++ b/TrafficCapture/dockerSolution/src/main/docker/migrationConsole/lib/console_link/console_link/cli.py @@ -30,7 +30,7 @@ def __init__(self, config_file) -> None: @click.group() @click.option( - "--config-file", default="/Volumes/workplace/opensearch/lewijacn-migrations/opensearch-migrations/TrafficCapture/dockerSolution/src/main/docker/migrationConsole/lib/console_link/services.yaml", help="Path to config file" + "--config-file", default="/etc/migration_services.yaml", help="Path to config file" ) @click.option("--json", is_flag=True) @click.option('-v', '--verbose', count=True, help="Verbosity level. Default is warn, -v is info, -vv is debug.") From 93563edf1297dd84131e69f26fe674c3f7d87860 Mon Sep 17 00:00:00 2001 From: Tanner Lewis Date: Fri, 21 Jun 2024 11:22:32 -0400 Subject: [PATCH 31/34] Lint fixes Signed-off-by: Tanner Lewis --- .../migrationConsole/lib/console_link/console_link/cli.py | 2 +- .../lib/console_link/console_link/logic/clusters.py | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/TrafficCapture/dockerSolution/src/main/docker/migrationConsole/lib/console_link/console_link/cli.py b/TrafficCapture/dockerSolution/src/main/docker/migrationConsole/lib/console_link/console_link/cli.py index f9f35bfbd..02945ed94 100644 --- a/TrafficCapture/dockerSolution/src/main/docker/migrationConsole/lib/console_link/console_link/cli.py +++ b/TrafficCapture/dockerSolution/src/main/docker/migrationConsole/lib/console_link/console_link/cli.py @@ -105,7 +105,7 @@ def run_test_benchmarks_cmd(ctx): @click.pass_obj def clear_indices_cmd(ctx, acknowledge_risk, cluster): """[Caution] Clear indices on a source or target cluster""" - cluster_focus = ctx.env.source_cluster if cluster.lower() == 'source' else ctx.env.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...") click.echo(logic_clusters.clear_indices(cluster_focus)) diff --git a/TrafficCapture/dockerSolution/src/main/docker/migrationConsole/lib/console_link/console_link/logic/clusters.py b/TrafficCapture/dockerSolution/src/main/docker/migrationConsole/lib/console_link/console_link/logic/clusters.py index 062b54c9f..25c1145c4 100644 --- a/TrafficCapture/dockerSolution/src/main/docker/migrationConsole/lib/console_link/console_link/logic/clusters.py +++ b/TrafficCapture/dockerSolution/src/main/docker/migrationConsole/lib/console_link/console_link/logic/clusters.py @@ -4,6 +4,7 @@ logger = logging.getLogger(__name__) + @dataclass class ConnectionResult: connection_message: str @@ -27,7 +28,6 @@ def connection_check(cluster: Cluster) -> ConnectionResult: except Exception as e: caught_exception = e logging.debug(f"Unable to access cluster: {cluster} with exception: {e}") - access_result = {} if caught_exception is None: response_json = r.json() return ConnectionResult(connection_message="Successfully connected!", From fc6287344c05acd40c35cdbd406e722818f16d96 Mon Sep 17 00:00:00 2001 From: Tanner Lewis Date: Fri, 21 Jun 2024 11:57:41 -0400 Subject: [PATCH 32/34] Add basic cli test cases Signed-off-by: Tanner Lewis --- .../lib/console_link/tests/test_cli.py | 37 ++++++++++++++++--- 1 file changed, 31 insertions(+), 6 deletions(-) diff --git a/TrafficCapture/dockerSolution/src/main/docker/migrationConsole/lib/console_link/tests/test_cli.py b/TrafficCapture/dockerSolution/src/main/docker/migrationConsole/lib/console_link/tests/test_cli.py index 0b464a37c..36f70db08 100644 --- a/TrafficCapture/dockerSolution/src/main/docker/migrationConsole/lib/console_link/tests/test_cli.py +++ b/TrafficCapture/dockerSolution/src/main/docker/migrationConsole/lib/console_link/tests/test_cli.py @@ -50,6 +50,31 @@ def test_cli_cluster_cat_indices(runner, env, mocker): assert 'TARGET CLUSTER' in result.output mock.assert_called() +def test_cli_cluster_connection_check(runner, env, mocker): + mock = mocker.patch('console_link.logic.clusters.connection_check') + result = runner.invoke(cli, ['--config-file', str(VALID_SERVICES_YAML), 'clusters', 'connection-check'], + catch_exceptions=True) + # Should have been called two times. + assert result.exit_code == 0 + assert 'SOURCE CLUSTER' in result.output + assert 'TARGET CLUSTER' in result.output + mock.assert_called() + +def test_cli_cluster_run_test_benchmarks(runner, env, mocker): + mock = mocker.patch('console_link.logic.clusters.run_test_benchmarks') + result = runner.invoke(cli, ['--config-file', str(VALID_SERVICES_YAML), 'clusters', 'run-test-benchmarks'], + catch_exceptions=True) + mock.assert_called_once() + assert result.exit_code == 0 + +def test_cli_cluster_clear_indices(runner, env, mocker): + mock = mocker.patch('console_link.logic.clusters.clear_indices') + result = runner.invoke(cli, + ['--config-file', str(VALID_SERVICES_YAML), 'clusters', 'clear-indices', + '--cluster', 'source', '--acknowledge-risk'], + catch_exceptions=True) + mock.assert_called_once() + assert result.exit_code == 0 def test_cli_with_metrics_get_data(runner, env, mocker): mock = mocker.patch('console_link.models.metrics_source.PrometheusMetricsSource.get_metrics') @@ -69,10 +94,10 @@ def test_cli_with_backfill_describe(runner, env, mocker): def test_cli_snapshot_create(runner, env, mocker): mock = mocker.patch('console_link.logic.snapshot.create') - + # Set the mock return value mock.return_value = SnapshotStatus.COMPLETED, "Snapshot created successfully." - + # Test snapshot creation result = runner.invoke(cli, ['--config-file', str(VALID_SERVICES_YAML), 'snapshot', 'create'], catch_exceptions=True) @@ -87,16 +112,16 @@ def test_cli_snapshot_create(runner, env, mocker): @pytest.mark.skip(reason="Not implemented yet") def test_cli_snapshot_status(runner, env, mocker): mock = mocker.patch('console_link.logic.snapshot.status') - + # Set the mock return value mock.return_value = SnapshotStatus.COMPLETED, "Snapshot status: COMPLETED" - + # Test snapshot status result = runner.invoke(cli, ['--config-file', str(VALID_SERVICES_YAML), 'snapshot', 'status'], catch_exceptions=True) assert result.exit_code == 0 assert "Snapshot status: COMPLETED" in result.output - + # Ensure the mocks were called mock.assert_called_once() @@ -124,7 +149,7 @@ def test_cli_cat_indices_e2e(runner, env): text=target_cat_indices) result = runner.invoke(cli, ['--config-file', str(VALID_SERVICES_YAML), 'clusters', 'cat-indices'], catch_exceptions=True) - + assert result.exit_code == 0 assert 'SOURCE CLUSTER' in result.output assert 'TARGET CLUSTER' in result.output From 14c4ceef7a4b207142bf712aae4c2d143a5412f9 Mon Sep 17 00:00:00 2001 From: Tanner Lewis Date: Fri, 21 Jun 2024 11:58:32 -0400 Subject: [PATCH 33/34] Lint fixes Signed-off-by: Tanner Lewis --- .../migrationConsole/lib/console_link/tests/test_cli.py | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/TrafficCapture/dockerSolution/src/main/docker/migrationConsole/lib/console_link/tests/test_cli.py b/TrafficCapture/dockerSolution/src/main/docker/migrationConsole/lib/console_link/tests/test_cli.py index 36f70db08..c13f1f464 100644 --- a/TrafficCapture/dockerSolution/src/main/docker/migrationConsole/lib/console_link/tests/test_cli.py +++ b/TrafficCapture/dockerSolution/src/main/docker/migrationConsole/lib/console_link/tests/test_cli.py @@ -50,6 +50,7 @@ def test_cli_cluster_cat_indices(runner, env, mocker): assert 'TARGET CLUSTER' in result.output mock.assert_called() + def test_cli_cluster_connection_check(runner, env, mocker): mock = mocker.patch('console_link.logic.clusters.connection_check') result = runner.invoke(cli, ['--config-file', str(VALID_SERVICES_YAML), 'clusters', 'connection-check'], @@ -60,6 +61,7 @@ def test_cli_cluster_connection_check(runner, env, mocker): assert 'TARGET CLUSTER' in result.output mock.assert_called() + def test_cli_cluster_run_test_benchmarks(runner, env, mocker): mock = mocker.patch('console_link.logic.clusters.run_test_benchmarks') result = runner.invoke(cli, ['--config-file', str(VALID_SERVICES_YAML), 'clusters', 'run-test-benchmarks'], @@ -67,6 +69,7 @@ def test_cli_cluster_run_test_benchmarks(runner, env, mocker): mock.assert_called_once() assert result.exit_code == 0 + def test_cli_cluster_clear_indices(runner, env, mocker): mock = mocker.patch('console_link.logic.clusters.clear_indices') result = runner.invoke(cli, @@ -76,6 +79,7 @@ def test_cli_cluster_clear_indices(runner, env, mocker): mock.assert_called_once() assert result.exit_code == 0 + def test_cli_with_metrics_get_data(runner, env, mocker): mock = mocker.patch('console_link.models.metrics_source.PrometheusMetricsSource.get_metrics') result = runner.invoke(cli, ['--config-file', str(VALID_SERVICES_YAML), 'metrics', 'list'], From 2ca87d00edd8d8baef6cd74e70f3f995e051f5b1 Mon Sep 17 00:00:00 2001 From: Tanner Lewis Date: Fri, 21 Jun 2024 13:16:43 -0400 Subject: [PATCH 34/34] PR feedback adjustments Signed-off-by: Tanner Lewis --- .../lib/console_link/console_link/cli.py | 5 +++-- .../migrationConsole/lib/console_link/tests/test_cli.py | 9 +++++++++ 2 files changed, 12 insertions(+), 2 deletions(-) diff --git a/TrafficCapture/dockerSolution/src/main/docker/migrationConsole/lib/console_link/console_link/cli.py b/TrafficCapture/dockerSolution/src/main/docker/migrationConsole/lib/console_link/console_link/cli.py index 02945ed94..320cbc32a 100644 --- a/TrafficCapture/dockerSolution/src/main/docker/migrationConsole/lib/console_link/console_link/cli.py +++ b/TrafficCapture/dockerSolution/src/main/docker/migrationConsole/lib/console_link/console_link/cli.py @@ -110,8 +110,9 @@ def clear_indices_cmd(ctx, acknowledge_risk, cluster): 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?'): - click.echo("Performing clear indices operation...") + if click.confirm(f'Clearing indices WILL result in the loss of all data on the {cluster.lower()} cluster. ' + f'Are you sure you want to continue?'): + click.echo(f"Performing clear indices operation on {cluster.lower()} cluster...") click.echo(logic_clusters.clear_indices(cluster_focus)) else: click.echo("Aborting command.") diff --git a/TrafficCapture/dockerSolution/src/main/docker/migrationConsole/lib/console_link/tests/test_cli.py b/TrafficCapture/dockerSolution/src/main/docker/migrationConsole/lib/console_link/tests/test_cli.py index c13f1f464..2ec241838 100644 --- a/TrafficCapture/dockerSolution/src/main/docker/migrationConsole/lib/console_link/tests/test_cli.py +++ b/TrafficCapture/dockerSolution/src/main/docker/migrationConsole/lib/console_link/tests/test_cli.py @@ -80,6 +80,15 @@ def test_cli_cluster_clear_indices(runner, env, mocker): assert result.exit_code == 0 +def test_cli_cluster_clear_indices_no_acknowledge(runner, env, mocker): + mock = mocker.patch('console_link.logic.clusters.clear_indices') + runner.invoke(cli, + ['--config-file', str(VALID_SERVICES_YAML), 'clusters', 'clear-indices', + '--cluster', 'source'], + catch_exceptions=True) + assert not mock.called + + def test_cli_with_metrics_get_data(runner, env, mocker): mock = mocker.patch('console_link.models.metrics_source.PrometheusMetricsSource.get_metrics') result = runner.invoke(cli, ['--config-file', str(VALID_SERVICES_YAML), 'metrics', 'list'],