Skip to content

Commit

Permalink
For publish libraries update the index alias mapping logic (opensearc…
Browse files Browse the repository at this point in the history
…h-project#540)

Signed-off-by: Prudhvi Godithi <[email protected]>
  • Loading branch information
prudhvigodithi authored Oct 18, 2024
1 parent 52f6eac commit bde5ca3
Show file tree
Hide file tree
Showing 3 changed files with 48 additions and 9 deletions.
19 changes: 16 additions & 3 deletions tests/jenkins/TestPublishDistributionBuildResults.groovy
Original file line number Diff line number Diff line change
Expand Up @@ -106,9 +106,6 @@ class TestPublishDistributionBuildResults extends BuildPipelineTest {
"type": "keyword"
}
}
},
"aliases": {
"opensearch-distribution-build-results": {}
}
}'
curl -I "METRICS_HOST_URL/test-index" --aws-sigv4 "aws:amz:us-east-1:es" --user "null:null" -H "x-amz-security-token:null" | grep -E "HTTP\\/[0-9]+(\\.[0-9]+)? 200"
Expand All @@ -119,6 +116,22 @@ class TestPublishDistributionBuildResults extends BuildPipelineTest {
create_index_response=$(curl -s -XPUT "METRICS_HOST_URL/test-index" --aws-sigv4 "aws:amz:us-east-1:es" --user "null:null" -H "x-amz-security-token:null" -H 'Content-Type: application/json' -d "${INDEX_MAPPING}")
if [[ $create_index_response == *'"acknowledged":true'* ]]; then
echo "Index created successfully."
echo "Updating alias..."
update_alias_response=\$(curl -s -XPOST "METRICS_HOST_URL/_aliases" --aws-sigv4 "aws:amz:us-east-1:es" --user "null:null" -H "x-amz-security-token:null" -H "Content-Type: application/json" -d '{
"actions": [
{
"add": {
"index": "test-index",
"alias": "opensearch-distribution-build-results"
}
}
]
}')
if [[ \$update_alias_response == *'"acknowledged":true'* ]]; then
echo "Alias updated successfully."
else
echo "Failed to update alias. Error message: \$update_alias_response"
fi
else
echo "Failed to create index. Error message: $create_index_response"
exit 1
Expand Down
19 changes: 16 additions & 3 deletions vars/publishDistributionBuildResults.groovy
Original file line number Diff line number Diff line change
Expand Up @@ -114,9 +114,6 @@ void indexFailedTestData(indexName, testRecordsFile) {
"type": "keyword"
}
}
},
"aliases": {
"opensearch-distribution-build-results": {}
}
}'
curl -I "${METRICS_HOST_URL}/${indexName}" --aws-sigv4 \"aws:amz:us-east-1:es\" --user \"${awsAccessKey}:${awsSecretKey}\" -H \"x-amz-security-token:${awsSessionToken}\" | grep -E "HTTP\\/[0-9]+(\\.[0-9]+)? 200"
Expand All @@ -127,6 +124,22 @@ void indexFailedTestData(indexName, testRecordsFile) {
create_index_response=\$(curl -s -XPUT "${METRICS_HOST_URL}/${indexName}" --aws-sigv4 \"aws:amz:us-east-1:es\" --user \"${awsAccessKey}:${awsSecretKey}\" -H \"x-amz-security-token:${awsSessionToken}\" -H 'Content-Type: application/json' -d "\${INDEX_MAPPING}")
if [[ \$create_index_response == *'"acknowledged":true'* ]]; then
echo "Index created successfully."
echo "Updating alias..."
update_alias_response=\$(curl -s -XPOST "${METRICS_HOST_URL}/_aliases" --aws-sigv4 "aws:amz:us-east-1:es" --user "${awsAccessKey}:${awsSecretKey}" -H "x-amz-security-token:${awsSessionToken}" -H "Content-Type: application/json" -d '{
"actions": [
{
"add": {
"index": "${indexName}",
"alias": "opensearch-distribution-build-results"
}
}
]
}')
if [[ \$update_alias_response == *'"acknowledged":true'* ]]; then
echo "Alias updated successfully."
else
echo "Failed to update alias. Error message: \$update_alias_response"
fi
else
echo "Failed to create index. Error message: \$create_index_response"
exit 1
Expand Down
19 changes: 16 additions & 3 deletions vars/publishGradleCheckTestResults.groovy
Original file line number Diff line number Diff line change
Expand Up @@ -164,9 +164,6 @@ void indexFailedTestData() {
"type": "keyword"
}
}
},
"aliases": {
"gradle-check": {}
}
}'
echo "INDEX NAME IS \$INDEX_NAME"
Expand All @@ -178,6 +175,22 @@ void indexFailedTestData() {
create_index_response=\$(curl -s -XPUT "${METRICS_HOST_URL}/\${INDEX_NAME}" --aws-sigv4 \"aws:amz:us-east-1:es\" --user \"${awsAccessKey}:${awsSecretKey}\" -H \"x-amz-security-token:${awsSessionToken}\" -H 'Content-Type: application/json' -d "\${INDEX_MAPPING}")
if [[ \$create_index_response == *'"acknowledged":true'* ]]; then
echo "Index created successfully."
echo "Updating alias..."
update_alias_response=\$(curl -s -XPOST "${METRICS_HOST_URL}/_aliases" --aws-sigv4 \"aws:amz:us-east-1:es\" --user \"${awsAccessKey}:${awsSecretKey}\" -H \"x-amz-security-token:${awsSessionToken}\" -H "Content-Type: application/json" -d '{
"actions": [
{
"add": {
"index": "\${INDEX_NAME}",
"alias": "gradle-check"
}
}
]
}')
if [[ \$update_alias_response == *'"acknowledged":true'* ]]; then
echo "Alias updated successfully."
else
echo "Failed to update alias. Error message: \$update_alias_response"
fi
else
echo "Failed to create index. Error message: \$create_index_response"
exit 1
Expand Down

0 comments on commit bde5ca3

Please sign in to comment.