From fc2c980fee6b8198bf4228b3be0759b0be802c3d Mon Sep 17 00:00:00 2001 From: ehaligow Date: Fri, 30 Jun 2023 12:05:48 -0700 Subject: [PATCH 1/3] Created Github actions workflow for testing successful integration between ODIM's services and Device Manager. Signed-off-by: ehaligow --- .github/workflows/integration.yml | 122 ++++++++++++++++++++++++++++++ 1 file changed, 122 insertions(+) create mode 100644 .github/workflows/integration.yml diff --git a/.github/workflows/integration.yml b/.github/workflows/integration.yml new file mode 100644 index 0000000..34148f3 --- /dev/null +++ b/.github/workflows/integration.yml @@ -0,0 +1,122 @@ +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 + + - 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: 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 From f4a85fa38eadf2af69c7e8352e0b803584a7fb9d Mon Sep 17 00:00:00 2001 From: ehaligow Date: Tue, 4 Jul 2023 11:30:29 -0700 Subject: [PATCH 2/3] Added go paths to env after installing go Signed-off-by: ehaligow --- .github/workflows/integration.yml | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/.github/workflows/integration.yml b/.github/workflows/integration.yml index 34148f3..31421b4 100644 --- a/.github/workflows/integration.yml +++ b/.github/workflows/integration.yml @@ -22,6 +22,10 @@ jobs: 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: | From 0e25414a6df09f237890ac2df06a3831c1b1b40d Mon Sep 17 00:00:00 2001 From: ehaligow Date: Sun, 16 Jul 2023 19:33:57 -0700 Subject: [PATCH 3/3] Added step for setting passwords. Signed-off-by: ehaligow --- .github/workflows/integration.yml | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/.github/workflows/integration.yml b/.github/workflows/integration.yml index 31421b4..8efd157 100644 --- a/.github/workflows/integration.yml +++ b/.github/workflows/integration.yml @@ -34,6 +34,11 @@ jobs: 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