-
Notifications
You must be signed in to change notification settings - Fork 13
131 lines (112 loc) · 5.36 KB
/
integration.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
name: integration
on:
pull_request:
types: [opened, edited, synchronize, reopened]
workflow_dispatch:
jobs:
build:
runs-on: ubuntu-20.04
steps:
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v2
- name: Set up repository
uses: actions/checkout@v3
with:
ref: main
- name: Install go
run: |
sudo make go-install
make prereq
echo "GOROOT=/usr/local/go" >> "$GITHUB_ENV"
echo "GOPATH=$HOME/app" >> "$GITHUB_ENV"
echo "${{ env.GOPATH }}/bin" >> "$GITHUB_PATH"
echo "${{ env.GOROOT }}/bin" >> "$GITHUB_PATH"
- name: Download scripts for generating certs
run: |
mkdir -p /tmp/certs
wget -P /tmp/certs https://raw.githubusercontent.com/ODIM-Project/ODIM/main/build/cert_generator/generate_client_crt.sh
wget -P /tmp/certs https://raw.githubusercontent.com/ODIM-Project/ODIM/main/build/cert_generator/generate_etcd_certs.sh
wget -P /tmp/certs https://raw.githubusercontent.com/ODIM-Project/ODIM/main/build/cert_generator/generate_odimra_cert.sh
- name: Set passwords
run: |
sed -i 's/#insert_your_password_here/YmzjkpHW8NIKoLJ6Lp5bufhl6bosH8U7Gy7rLeo8t8ixFk5soWalYa4FX8m8cjnfI6AKtoxTo7DfGdphNk3Y8g==/' $GITHUB_WORKSPACE/svc-device-manager/config/config.yml
sed -i 's/your_password_here/YmzjkpHW8NIKoLJ6Lp5bufhl6bosH8U7Gy7rLeo8t8ixFk5soWalYa4FX8m8cjnfI6AKtoxTo7DfGdphNk3Y8g==/' $GITHUB_WORKSPACE/build/redis/createSchema.sh
- name: Generate certs
run: |
sed -i 's/URP/device-manager/' /tmp/certs/generate_odimra_cert.sh
cp /tmp/certs/* build/certs
cd $GITHUB_WORKSPACE/build/certs
chmod +x generate_odimra_cert.sh
./generate_odimra_cert.sh deviceManager
- name: Install Device Manager and ODIM's services
id: installDeviceMgrAndODIM
run: |
sudo apt -y install jq
cd $GITHUB_WORKSPACE
make all
- name: Add BMC hostname to hosts file
run: |
ip=$(hostname -I | awk '{print $1}')
sudo sed -i '$a '"$ip"' bmcsim' /etc/hosts
echo "IP=$ip" >> "$GITHUB_ENV"
- name: Install BMC
run: |
sudo apt -y install default-jre
cd ..
git clone https://github.com/ODIM-Project/BMCSimulator.git
cd BMCSimulator
./gradlew executableJar
sudo cp $GITHUB_WORKSPACE/build/certs/rootCA.* .
sudo chown $USER rootCA.*
./generate_bmc_certs.sh bmcsim
cp src/main/resources/odim-simulator-config.json .
echo "$(jq '.security.httpClient.basicCredentials = "admin:D3v1ceMgr"' odim-simulator-config.json)" > odim-simulator-config.json
echo "$(jq -r --arg IP "${{ env.IP }}" '.binding.ip = $IP' odim-simulator-config.json)" > odim-simulator-config.json
java -jar build/libs/simulator-runner-1.0-SNAPSHOT.jar run BMC --port 55555 -c odim-simulator-config.json &
- name: Retrieve Connection method URI
id: retrieveConnectionMethodURI
if: steps.installDeviceMgrAndODIM.outcome == 'success'
run: |
connectionMethodURI=$(curl -k -u 'admin:D3v1ceMgr' https://127.0.0.1:45000/redfish/v1/AggregationService/ConnectionMethods | jq '.Members[0]."@odata.id"')
echo "CONNECTION_METHOD_URI=$connectionMethodURI" >> "$GITHUB_ENV"
- name: Add Device Manager as an Aggregation Source
run: |
responseType=$(curl --location -X POST -k -u 'admin:D3v1ceMgr' 'https://127.0.0.1:45000/redfish/v1/AggregationService/AggregationSources' \
--header 'Content-Type: application/json' \
--data-raw '{
"HostName": "device-manager:45003",
"UserName": "admin",
"Password": "D3v1ceMgr",
"Links": {
"ConnectionMethod": {
"@odata.id": ${{ env.CONNECTION_METHOD_URI }}
}
}
}'| jq -e '."@odata.type"?' )
if [[ $responseType != *"Task"* ]]; then exit 1; fi
- name: Add BMC as an Aggregation Source
run: |
aggregationResponse=$(curl --location -X POST -k -u 'admin:D3v1ceMgr' 'https://127.0.0.1:45000/redfish/v1/AggregationService/AggregationSources' \
--header 'Content-Type: application/json' \
--data-raw '{
"HostName": "bmcsim:55555",
"UserName": "admin",
"Password": "admin",
"Links": {
"ConnectionMethod": {
"@odata.id": ${{ env.CONNECTION_METHOD_URI }}
}
}
}')
if [[ $(echo $aggregationResponse | jq -e '."@odata.type"?') != *"Task"* ]]; then exit 1; fi
taskURI=$(echo $aggregationResponse | jq --raw-output -e '."@odata.id"?')
baseURI="https://127.0.0.1:45000"
while [[ $(curl -k -u 'admin:D3v1ceMgr' ${baseURI}${taskURI} | jq -e '."TaskState"?') == *"Running"* ]]; do sleep 10; done
if [[ $(curl -k -u 'admin:D3v1ceMgr' ${baseURI}${taskURI} | jq -e '."TaskState"?') == *"Exception"* ]]; then exit 1; fi
- name: Get number of AggregationSources
run: |
numberOfAggregationSources=$(curl -k -u 'admin:D3v1ceMgr' https://127.0.0.1:45000/redfish/v1/AggregationService/AggregationSources | jq '.Members | length')
echo "NUMBER_OF_AGGREGATION_SOURCES=$numberOfAggregationSources" >> "$GITHUB_ENV"
- name: Check number of AggregationSources
if: env.NUMBER_OF_AGGREGATION_SOURCES !=2
run: exit 1