-
Notifications
You must be signed in to change notification settings - Fork 24
148 lines (122 loc) · 5.52 KB
/
fhir-bundle-smoketest.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
147
148
name: FHIR Bundle SmokeTest
on:
schedule:
- cron: '0 */1 * * *'
workflow_dispatch:
jobs:
test:
runs-on: ubuntu-latest
if: ${{ github.repository == 'tech-by-design/polyglot-prime' }}
steps:
- name: Checkout code
uses: actions/checkout@v4
- name: Set up JDK 21
uses: actions/setup-java@v4
with:
java-version: '21'
distribution: 'corretto'
cache: maven
- name: Download and setup JMeter
run: |
curl -O https://dlcdn.apache.org//jmeter/binaries/apache-jmeter-5.6.3.tgz
tar -xzf apache-jmeter-5.6.3.tgz
sudo mv apache-jmeter-5.6.3 ./test-automation/
- name: Decode the .p12 file
env:
P12_FILE_BASE64: ${{ secrets.TECHBD_PHI_QA_KEY_BASE64 }}
run: |
CERT_DIR="./test-automation/Certificates"
mkdir -p $CERT_DIR
echo "$P12_FILE_BASE64" | base64 -d > "$CERT_DIR/techbd-phi-QA-key.p12"
- name: Update SSL paths in JMeter configuration files
run: |
CONFIG_DIR="./test-automation/apache-jmeter-5.6.3/bin"
CERT_PATH="./test-automation/Certificates/techbd-phi-QA-key.p12"
echo "javax.net.ssl.keyStore=$CERT_PATH" >> $CONFIG_DIR/jmeter.properties
echo "javax.net.ssl.keyStorePassword=" >> $CONFIG_DIR/jmeter.properties
echo "javax.net.ssl.keyStoreType=pkcs12" >> $CONFIG_DIR/jmeter.properties
echo "javax.net.ssl.keyStore=$CERT_PATH" >> $CONFIG_DIR/system.properties
echo "javax.net.ssl.keyStorePassword=" >> $CONFIG_DIR/system.properties
echo "javax.net.ssl.keyStoreType=pkcs12" >> $CONFIG_DIR/system.properties
echo "javax.net.ssl.keyStore=$CERT_PATH" >> $CONFIG_DIR/user.properties
echo "javax.net.ssl.keyStorePassword=" >> $CONFIG_DIR/user.properties
echo "javax.net.ssl.keyStoreType=pkcs12" >> $CONFIG_DIR/user.properties
- name: Run FHIR Bundle SmokeTest for Environments
id: run-tests
run: |
# Array of environments and their paths
environments=("Staging" "PHI-QA")
environment_paths=(
"./test-automation/FHIR-Bundle-SmokeTest-Stage/Bundle.jmx"
"./test-automation/FHIR-Bundle-SmokeTest-PHI-QA/Bundle.jmx"
)
# Initialize failure report and attachments arrays
counter=1
failure_report=""
attachments=()
# Loop through environments and run the tests
for i in "${!environments[@]}"; do
env="${environments[$i]}"
path="${environment_paths[$i]}"
result_dir="./test-automation/Jmeter${env}Result"
report_dir="./test-automation/Jmeter${env}Report"
zip_file="./test-automation/Jmeter${env}Report.zip"
# Create necessary directories
mkdir -p "$result_dir"
mkdir -p "$report_dir"
# Run the JMeter test and generate reports
./test-automation/apache-jmeter-5.6.3/bin/jmeter -n -t "$path" -l "$result_dir/bundletest.jtl" > "$result_dir/$env.log"
./test-automation/apache-jmeter-5.6.3/bin/jmeter -g "$result_dir/bundletest.jtl" -o "$report_dir/"
# Check for errors in the JMeter log file
errors=$(grep "summary =" "$result_dir/$env.log" | tail -1 | grep -oP "Err:\s+\K\d+")
echo "${env}_errors=$errors" >> $GITHUB_ENV
# Show the log in console
cat $result_dir/$env.log
# If errors found, add environment and report to failure
if [[ "$errors" -gt 0 ]]; then
failure_report="${failure_report}${counter}. ${env}, "
counter=$((counter + 1))
attachments+=("$zip_file")
fi
done
# If no failures, set a default message
if [[ -z "$failure_report" ]]; then
failure_report="No failures detected."
else
# Remove trailing comma and space
failure_report=$(echo "$failure_report" | sed 's/, $//')
fi
# Convert attachments array to a comma-separated string for GitHub Actions
failure_attachments=$(IFS=,; echo "${attachments[*]}")
echo "failure_attachments=$failure_attachments" >> $GITHUB_ENV
# Export the failure_report to GitHub Actions environment
echo "failure_report=$failure_report" >> $GITHUB_ENV
- name: Archive JMeter Reports into ZIP files
run: |
sudo apt-get install -y zip
cd ./test-automation
# Ensure the report directories are zipped
for env in "Staging" "PHI-QA"; do
mkdir -p "./Jmeter${env}Report"
zip -r "./Jmeter${env}Report.zip" "./Jmeter${env}Report/"
done
- name: Send Email Notification (Conditional)
if: env.failure_report != 'No failures detected.'
uses: dawidd6/action-send-mail@v3
with:
server_address: email-smtp.us-east-1.amazonaws.com
server_port: 587
username: ${{ secrets.SES_SMTP_USERNAME }}
password: ${{ secrets.SES_SMTP_PASSWORD }}
subject: "FHIR Bundle SmokeTest Failures"
body: |
Hello Team,
The FHIR Bundle SmokeTest encountered failures in the following environments:
${{ env.failure_report }}
Please find the attached reports for the same.
Regards,
Tech by Design Automation Team
content_type: "text/plain"
from: "Tech by Design FHIR SmokeTest Result <[email protected]>"
attachments: ${{ env.failure_attachments }}