Skip to content

Commit 4b43447

Browse files
committed
feat(test): test health endpoint with docker
Signed-off-by: Gaurav Mishra <mishra.gaurav@siemens.com>
1 parent 75e3bc8 commit 4b43447

File tree

2 files changed

+76
-0
lines changed

2 files changed

+76
-0
lines changed

.github/workflows/docker-test.yml

Lines changed: 55 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,55 @@
1+
# -----------------------------------------------------------------------------
2+
# Copyright 2024, Siemens AG
3+
# Part of the SW360 Project.
4+
#
5+
# This program and the accompanying materials are made
6+
# available under the terms of the Eclipse Public License 2.0
7+
# which is available at https://www.eclipse.org/legal/epl-2.0/
8+
#
9+
# SPDX-License-Identifier: EPL-2.0
10+
# SPDX-FileCopyrightText: 2024, Siemens AG
11+
# SPDX-FileContributor: Gaurav Mishra <mishra.gaurav@siemens.com>
12+
#
13+
# -----------------------------------------------------------------------------
14+
15+
name: Docker test
16+
17+
on:
18+
pull_request
19+
20+
env:
21+
REGISTRY: ghcr.io
22+
23+
permissions:
24+
contents: read
25+
26+
jobs:
27+
docker-test:
28+
runs-on: ubuntu-latest
29+
steps:
30+
- name: Harden Runner
31+
uses: step-security/harden-runner@91182cccc01eb5e619899d80e4e971d6181294a7 # v2.10.1
32+
with:
33+
egress-policy: audit
34+
35+
- name: Checkout main repository
36+
uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
37+
38+
- name: Set up QEMU
39+
uses: docker/setup-qemu-action@49b3bc8e6bdd4a60e6116a5414239cba5943d3cf # v3.2.0
40+
41+
- name: Set up Docker Buildx
42+
uses: docker/setup-buildx-action@c47758b77c9736f4b2ef4073d4d51994fabfe349 # v3.7.1
43+
44+
- name: Login to GitHub Container Registry
45+
uses: docker/login-action@9780b0c442fbb1117ed29e0efdff1e18412f7567 # v3.3.0
46+
with:
47+
registry: ${{ env.REGISTRY }}
48+
username: ${{ github.actor }}
49+
password: ${{ secrets.GITHUB_TOKEN }}
50+
51+
- name: Build images
52+
run: ./docker_build.sh
53+
54+
- name: Test cluster
55+
run: ./utils/test-cluster.sh

utils/test-cluster.sh

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
#!/usr/bin/env bash
2+
# SPDX-FileCopyrightText: © 2024 Siemens AG
3+
# SPDX-FileContributor: Gaurav Mishra <mishra.gaurav@siemens.com>
4+
# SPDX-License-Identifier: EPL-2.0
5+
6+
set -o errexit -o nounset -o xtrace
7+
8+
docker compose up -d
9+
10+
#### Sleep for Tomcat to start
11+
sleep 15
12+
13+
readonly HOST="127.0.0.1:8080"
14+
15+
#### Check health endpoint
16+
curl --location "http://${HOST}/resource/api/health"
17+
curl --silent --location "http://${HOST}/resource/api/health" | grep -q '"status":"UP"'
18+
curl --silent --location "http://${HOST}/resource/api/health" | grep -q '"isDbReachable":true'
19+
curl --silent --location "http://${HOST}/resource/api/health" | grep -q '"isThriftReachable":true'
20+
21+
docker compose down

0 commit comments

Comments
 (0)