Skip to content

Commit

Permalink
feat(test): test health endpoint with docker
Browse files Browse the repository at this point in the history
Signed-off-by: Gaurav Mishra <[email protected]>
  • Loading branch information
GMishx committed Nov 15, 2024
1 parent 75e3bc8 commit c3c4d8b
Show file tree
Hide file tree
Showing 2 changed files with 76 additions and 0 deletions.
55 changes: 55 additions & 0 deletions .github/workflows/docker-test.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
# -----------------------------------------------------------------------------
# Copyright 2024, Siemens AG
# Part of the SW360 Project.
#
# This program and the accompanying materials are made
# available under the terms of the Eclipse Public License 2.0
# which is available at https://www.eclipse.org/legal/epl-2.0/
#
# SPDX-License-Identifier: EPL-2.0
# SPDX-FileCopyrightText: 2024, Siemens AG
# SPDX-FileContributor: Gaurav Mishra <[email protected]>
#
# -----------------------------------------------------------------------------

name: Docker test

on:
pull_request

env:
REGISTRY: ghcr.io

permissions:
contents: read

jobs:
docker-test:
runs-on: ubuntu-latest
steps:
- name: Harden Runner
uses: step-security/harden-runner@91182cccc01eb5e619899d80e4e971d6181294a7 # v2.10.1
with:
egress-policy: audit

- name: Checkout main repository
uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2

- name: Set up QEMU
uses: docker/setup-qemu-action@49b3bc8e6bdd4a60e6116a5414239cba5943d3cf # v3.2.0

- name: Set up Docker Buildx
uses: docker/setup-buildx-action@c47758b77c9736f4b2ef4073d4d51994fabfe349 # v3.7.1

- name: Login to GitHub Container Registry
uses: docker/login-action@9780b0c442fbb1117ed29e0efdff1e18412f7567 # v3.3.0
with:
registry: ${{ env.REGISTRY }}
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}

- name: Build images
run: ./docker_build.sh

- name: Test cluster
run: ./utils/test-cluster.sh
21 changes: 21 additions & 0 deletions utils/test-cluster.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
#!/usr/bin/env bash
# SPDX-FileCopyrightText: © 2024 Siemens AG
# SPDX-FileContributor: Gaurav Mishra <[email protected]>
# SPDX-License-Identifier: EPL-2.0

set -o errexit -o nounset -o xtrace

docker compose up -d

#### Sleep for Tomcat to start
sleep 60

readonly HOST="127.0.0.1:8080"

#### Check health endpoint
curl --location -vv "http://${HOST}/resource/api/health"
curl --silent --location "http://${HOST}/resource/api/health" | grep -q '"status":"UP"'
curl --silent --location "http://${HOST}/resource/api/health" | grep -q '"isDbReachable":true'
curl --silent --location "http://${HOST}/resource/api/health" | grep -q '"isThriftReachable":true'

docker compose down

0 comments on commit c3c4d8b

Please sign in to comment.