-
Notifications
You must be signed in to change notification settings - Fork 4
146 lines (119 loc) · 5.41 KB
/
release-dev-ci.yml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
name: Upbrella DEV CI
on:
push:
branches: [ "release-dev" ]
env:
WORKING_DIRECTORY: ./
CODE_DEPLOY_APPLICATION_NAME: upbrella-dev-deploy
CODE_DEPLOY_DEPLOYMENT_GROUP_NAME: UpbrellaServerDev
S3_BUCKET_NAME: upbrella-storage
permissions:
contents: read
jobs:
build:
runs-on: ubuntu-latest
steps:
- name: checkout
uses: actions/checkout@v3
- name: Set up JDK 11
uses: actions/setup-java@v3
with:
java-version: '11'
distribution: 'adopt'
- name: Set application properties
run: |
touch src/main/resources/application.properties
echo "${{ secrets.APPLICATION_PROPERTIES_DEV }}" > src/main/resources/application.properties
echo "${{ secrets.APPLICATION_PROPERTIES_TEST }}" > src/test/resources/application.properties
- name: Build with Gradle
run: |
chmod +x gradlew
./gradlew clean build
env:
WORKING_DIRECTORY: ${{ env.WORKING_DIRECTORY }}
- name: Configure AWS credentials
uses: aws-actions/configure-aws-credentials@v1
with:
aws-access-key-id: ${{ secrets.AWS_ACCESS_KEY_ID }}
aws-secret-access-key: ${{ secrets.AWS_SECRET_ACCESS_KEY }}
aws-region: ${{ secrets.AWS_REGION }}
- name: Make zip file
run: zip -r ./$GITHUB_SHA.zip .
shell: bash
- name: Upload to S3
run:
aws s3 cp $GITHUB_SHA.zip s3://${{ env.S3_BUCKET_NAME }}/server-dev-deploy/$GITHUB_SHA.zip --region ${{ secrets.AWS_REGION }}
- name: Code Deploy
run: |
aws deploy create-deployment \
--deployment-config-name CodeDeployDefault.AllAtOnce \
--application-name ${{ env.CODE_DEPLOY_APPLICATION_NAME }} \
--deployment-group-name ${{ env.CODE_DEPLOY_DEPLOYMENT_GROUP_NAME }} \
--s3-location bucket=${{ env.S3_BUCKET_NAME }},bundleType=zip,key=server-dev-deploy/$GITHUB_SHA.zip
# test에 필요한 ec2 인스턴스를 aws cli를 통해 실행
- name: Start nGrinder EC2 - (Controller, Agent)
run: aws ec2 start-instances --instance-ids ${{ secrets.AWS_EC2_NGRINDER_CONTROLLER }} ${{ secrets.AWS_EC2_NGRINDER_AGENT }}
env:
AWS_ACCESS_KEY_ID: ${{ secrets.AWS_ACCESS_KEY_ID }}
AWS_SECRET_ACCESS_KEY: ${{ secrets.AWS_SECRET_ACCESS_KEY }}
AWS_DEFAULT_REGION: ${{ secrets.AWS_DEFAULT_REGION }}
# Dev server 완전히 실행될 때까지 기다림
- name: Sleep for 30 seconds - waiting controller,agent run
run: sleep 30s
shell: bash
# EC2- Ngrinder Controller를 실행
- name: Ngrinder Controller Start
uses: appleboy/ssh-action@master
with:
host: ${{ secrets.AWS_EC2_CONTROLLER_IP }}
username: ubuntu
key: ${{ secrets.AWS_SECRET_PEM }}
script: |
bash ./controller.sh
- name: Ngrinder Agent Start
uses: appleboy/ssh-action@master
with:
host: ${{ secrets.AWS_EC2_AGENT_IP }}
username: ubuntu
key: ${{ secrets.AWS_SECRET_PEM }}
script: |
bash ./agent.sh
- name: waiting controller,agent run
run: sleep 30s
shell: bash
- name: nGrinder Test
uses: fjogeleit/http-request-action@v1
with:
url: 'http://${{ secrets.AWS_EC2_CONTROLLER_IP }}/perftest/api'
method: 'POST'
username: ${{ secrets.NGRINDER_ADMIN_USERNAME }}
password: ${{ secrets.NGRINDER_ADMIN_PASSWORD }}
customHeaders: '{"Content-Type": "application/json"}'
data: '{"param" : "${{ secrets.AWS_EC2_TEST_SERVER_IP }}", "testName" : "upbrella-test", "tagString" : "upbrella-test", "description" : "upbrella-test", "scheduledTime" : "", "useRampUp": false, "rampUpType" : "PROCESS", "threshold" : "D", "scriptName" : "upbrella-test.groovy", "duration" : 240000, "runCount" : 1, "agentCount" : 1, "vuserPerAgent" : 30, "processes" : 2, "rampUpInitCount" : 0, "rampUpInitSleepTime" : 0, "rampUpStep" : 1, "rampUpIncrementInterval" : 1000, "threads": 15, "testComment" : "upbrella-test", "samplingInterval" : 2, "ignoreSampleCount" : 0, "status" : "READY"}'
timeout: '60000'
- name: waiting test for 300 seconds
run: sleep 300s
shell: bash
# Ngrinder Rest Api 를 통해 테스트 결과 조회
- name: Get Ngrinder test result ...
uses: satak/webrequest-action@master
id: NgrinderTestResult
with:
url: 'http://${{ secrets.AWS_EC2_CONTROLLER_IP }}/perftest/api?page=0'
method: GET
username: ${{ secrets.NGRINDER_ADMIN_USERNAME }}
password: ${{ secrets.NGRINDER_ADMIN_PASSWORD }}
- name: send test result to slack
uses: 8398a7/action-slack@v3
with:
text: '${{ steps.NgrinderTestResult.outputs.output }}'
status: ${{ job.status }}
env:
SLACK_WEBHOOK_URL: ${{ secrets.SLACK_WEBHOOK_URL }}
if: always() # Pick up events even if the job fails or is canceled.
- name: Stop Ngrinder EC2 - (Controller, Agent, Test Server)
run: aws ec2 stop-instances --instance-ids ${{ secrets.AWS_EC2_NGRINDER_CONTROLLER }} ${{ secrets.AWS_EC2_NGRINDER_AGENT }}
env:
AWS_ACCESS_KEY_ID: ${{ secrets.AWS_ACCESS_KEY_ID }}
AWS_SECRET_ACCESS_KEY: ${{ secrets.AWS_SECRET_ACCESS_KEY }}
AWS_DEFAULT_REGION: ${{ secrets.AWS_REGION }}