Skip to content

Commit

Permalink
Test
Browse files Browse the repository at this point in the history
  • Loading branch information
harrryr committed Sep 25, 2024
1 parent 1b2453f commit 0514d26
Showing 1 changed file with 49 additions and 49 deletions.
98 changes: 49 additions & 49 deletions .github/workflows/k8s-patch-os-jobs.yml
Original file line number Diff line number Diff line change
Expand Up @@ -135,8 +135,8 @@ jobs:
# caller-repository: ${{ inputs.repo_name }}

update-secrets:
# needs: [ run-java-k8s-test, run-python-k8s-test, run-dotnet-k8s-test, run-node-k8s-test ]
# if: ${{ always() && (needs.run-java-k8s-test.result == 'success' || needs.run-python-k8s-test.result == 'success' || needs.run-dotnet-k8s-test.result == 'success' || needs.run-node-k8s-test.result == 'success') }}
needs: create-k8s-on-ec2
# if: ${{ always() && (needs.run-java-k8s-test.result == 'success' || needs.run-python-k8s-test.result == 'success' || needs.run-dotnet-k8s-test.result == 'success' || needs.run-node-k8s-test.result == 'success') }}
runs-on: ubuntu-latest
steps:
- name: Configure AWS Credentials
Expand Down Expand Up @@ -181,50 +181,50 @@ jobs:
aws secretsmanager update-secret --secret-id "${CURRENT_SECRET_KEYS[0]}" --secret-string "$endpoint_secret"
aws secretsmanager update-secret --secret-id "${CURRENT_SECRET_KEYS[1]}" --secret-string "$ssh_secret"
publish-metric:
needs: [ update-secrets ]
if: always()
uses: ./.github/workflows/enablement-test-publish-result.yml
secrets: inherit
with:
aws-region: 'us-east-1'
caller-workflow-name: 'enablement-test-k8s-patch-os'
validation-result: ${{ needs.update-secrets.result }}

cleanup-if-failed:
needs: [ run-java-k8s-test, run-python-k8s-test, run-dotnet-k8s-test, run-node-k8s-test ]
if: ${{ always() && (needs.run-java-k8s-test.result != 'success' && needs.run-python-k8s-test.result != 'success' && needs.run-dotnet-k8s-test.result != 'success' && needs.run-node-k8s-test.result != 'success') }}
runs-on: ubuntu-latest
steps:
- name: Delete Key Pair and EC2 Instance
run: |
PENDING_SECRET_KEYS=(
"e2e-test/${{ matrix.instance.repo_name }}/${{ matrix.instance.language }}-k8s-master-node-endpoint-pending-value"
)
endpoint_secret=$(aws secretsmanager get-secret-value --secret-id "${PENDING_SECRET_KEYS[0]}" --query SecretString --output text)
instance_name=$(aws ec2 describe-instances \
--filters "Name=ip-address,Values=$endpoint_secret" \
--query "Reservations[*].Instances[*].{Name:Tags[?Key=='Name']|[0].Value}" \
--output text)
if [ -n "$instance_name" ]; then
prev_testing_id=$(echo $instance_name | awk -F'-' '{print $(NF-1)"-"$NF}')
aws ec2 delete-key-pair --key-name "k8s-on-ec2-${{ matrix.instance.ec2_name }}-${{ matrix.instance.language }}-key-pair-$prev_testing_id"
main_instance_name=k8s-on-ec2-${{ matrix.instance.ec2_name }}-${{ matrix.instance.language }}-master-$prev_testing_id
worker_instance_name=k8s-on-ec2-${{ matrix.instance.ec2_name }}-${{ matrix.instance.language }}-worker-$prev_testing_id
main_instance_id=$(aws ec2 describe-instances \
--filters "Name=tag:Name,Values=$main_instance_name" \
--query "Reservations[*].Instances[*].InstanceId" \
--output text)
worker_instance_id=$(aws ec2 describe-instances \
--filters "Name=tag:Name,Values=$worker_instance_name" \
--query "Reservations[*].Instances[*].InstanceId" \
--output text)
aws ec2 terminate-instances --instance-ids $main_instance_id
aws ec2 terminate-instances --instance-ids $worker_instance_id
fi
# publish-metric:
# needs: [ update-secrets ]
# if: always()
# uses: ./.github/workflows/enablement-test-publish-result.yml
# secrets: inherit
# with:
# aws-region: 'us-east-1'
# caller-workflow-name: 'enablement-test-k8s-patch-os'
# validation-result: ${{ needs.update-secrets.result }}
#
# cleanup-if-failed:
# needs: [ run-java-k8s-test, run-python-k8s-test, run-dotnet-k8s-test, run-node-k8s-test ]
# if: ${{ always() && (needs.run-java-k8s-test.result != 'success' && needs.run-python-k8s-test.result != 'success' && needs.run-dotnet-k8s-test.result != 'success' && needs.run-node-k8s-test.result != 'success') }}
# runs-on: ubuntu-latest
# steps:
# - name: Delete Key Pair and EC2 Instance
# run: |
# PENDING_SECRET_KEYS=(
# "e2e-test/${{ matrix.instance.repo_name }}/${{ matrix.instance.language }}-k8s-master-node-endpoint-pending-value"
# )
# endpoint_secret=$(aws secretsmanager get-secret-value --secret-id "${PENDING_SECRET_KEYS[0]}" --query SecretString --output text)
#
# instance_name=$(aws ec2 describe-instances \
# --filters "Name=ip-address,Values=$endpoint_secret" \
# --query "Reservations[*].Instances[*].{Name:Tags[?Key=='Name']|[0].Value}" \
# --output text)
#
# if [ -n "$instance_name" ]; then
# prev_testing_id=$(echo $instance_name | awk -F'-' '{print $(NF-1)"-"$NF}')
#
# aws ec2 delete-key-pair --key-name "k8s-on-ec2-${{ matrix.instance.ec2_name }}-${{ matrix.instance.language }}-key-pair-$prev_testing_id"
#
# main_instance_name=k8s-on-ec2-${{ matrix.instance.ec2_name }}-${{ matrix.instance.language }}-master-$prev_testing_id
# worker_instance_name=k8s-on-ec2-${{ matrix.instance.ec2_name }}-${{ matrix.instance.language }}-worker-$prev_testing_id
# main_instance_id=$(aws ec2 describe-instances \
# --filters "Name=tag:Name,Values=$main_instance_name" \
# --query "Reservations[*].Instances[*].InstanceId" \
# --output text)
#
# worker_instance_id=$(aws ec2 describe-instances \
# --filters "Name=tag:Name,Values=$worker_instance_name" \
# --query "Reservations[*].Instances[*].InstanceId" \
# --output text)
#
# aws ec2 terminate-instances --instance-ids $main_instance_id
# aws ec2 terminate-instances --instance-ids $worker_instance_id
# fi

0 comments on commit 0514d26

Please sign in to comment.