Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 12 additions & 3 deletions .github/workflows/maven.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@ on:

jobs:
build:

runs-on: ubuntu-20.04

steps:
Expand All @@ -23,5 +22,15 @@ jobs:
distribution: 'adopt'
- name: Maven version
run: mvn -version
- name: Build with Maven
run: mvn -B package
- name: API testing with Maven
Comment thread
wgu-edwin marked this conversation as resolved.
run: mvn clean install -Prun-api-tests
env:
OAUTH_CLIENTID: "${{secrets.OAUTH_CLIENTID}}"
OAUTH_CLIENTSECRET: "${{secrets.OAUTH_CLIENTSECRET}}"
OAUTH_AUDIENCE: "${{secrets.OAUTH_AUDIENCE}}"
OAUTH_ISSUER: "${{secrets.OAUTH_ISSUER}}"
OKTA_USERNAME: "${{secrets.OKTA_USERNAME}}"
OKTA_PASSWORD: "${{secrets.OKTA_PASSWORD}}"
OKTA_URL: "${{secrets.OKTA_URL}}"
BASE_URL: "http://localhost:8080"
APP_START_CHECK_RETRY_LIMIT: 100
15 changes: 15 additions & 0 deletions osmt_cli.sh
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,10 @@ declare -r MYSQL_USER="${MYSQL_USER:-osmt_db_user}"
declare -r MYSQL_PASSWORD="${MYSQL_PASSWORD:-password}"
declare -r ELASTICSEARCH_HTTP_PORT="${ELASTICSEARCH_HTTP_PORT:-9200}"
declare -r ELASTICSEARCH_TRANSPORT_PORT="${ELASTICSEARCH_TRANSPORT_PORT:-9300}"
declare OAUTH_ISSUER="${OAUTH_ISSUER:-}"
declare OAUTH_CLIENTID="${OAUTH_CLIENTID:-}"
declare OAUTH_CLIENTSECRET="${OAUTH_CLIENTSECRET:-}"
declare OAUTH_AUDIENCE="${OAUTH_AUDIENCE:-}"


# new line formatted to indent with echo_err / echo_info etc
Expand Down Expand Up @@ -47,6 +51,17 @@ _cd_osmt_project_dir() {
_source_osmt_env_file() {
local env_file="${1}"

# gracefully bypass sourcing env file if these 4 OAUTH values are provided
if [[ \
-n "${OAUTH_ISSUER}" && \
-n "${OAUTH_CLIENTID}" &&\
-n "${OAUTH_CLIENTSECRET}" && \
-n "${OAUTH_AUDIENCE}" \
]]; then
echo_info "Using OAUTH environment variables, not using ${env_file} env file."
return 0
fi

if [[ ! -f "${env_file}" || ! -r "${env_file}" ]]; then
echo_err "Can not access ${env_file}. You can initialize the environment files by running $(basename "${0}") -i$"
return 1
Expand Down
11 changes: 9 additions & 2 deletions test/bin/pre_test_setup.sh
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ export BASE_URL="http://${BASE_DOMAIN}"
export OSMT_FRONT_END_PORT="${APP_PORT}"

declare -ri LOAD_CI_DATASET="${LOAD_CI_DATASET:-0}"
declare -i APP_START_CHECK_RETRY_LIMIT="${APP_START_CHECK_RETRY_LIMIT:-12}"

_get_osmt_project_dir() {
local project_dir; project_dir="$(git rev-parse --show-toplevel 2> /dev/null)"
Expand Down Expand Up @@ -51,18 +52,24 @@ inject_tests() {
}

curl_with_retry() {
local log_file; log_file="${project_dir}/test/target/osmt_spring_app.log"
local -i rc=-1
local -i retry_limit=12
local -i retry_limit=${APP_START_CHECK_RETRY_LIMIT}
until [ ${rc} -eq 0 ] && [ ${retry_limit} -eq 0 ]; do
echo_info "Attempting to request the index page of the OSMT Spring app with curl..."
echo_info "${BASE_URL}"
curl -s "${BASE_URL}" 1>/dev/null 2>/dev/null
rc=$?
if [[ ${rc} -eq 0 ]]; then
echo_info "Index page loaded. Proceeding..."
return 0
fi
if [[ ${retry_limit} -eq 0 ]]; then
echo
echo_info "osmt_spring_app log file below..."
echo
echo_err "Could not load the index page."
cat "${log_file}"
return 1
fi
if [[ ${rc} -ne 0 ]]; then
Expand Down Expand Up @@ -116,7 +123,7 @@ error_handler() {

main() {
local project_dir; project_dir="$(_get_osmt_project_dir)" || exit 135
local log_file; log_file="${project_dir}/api/target/osmt_spring_app.log"
local log_file; log_file="${project_dir}/test/target/osmt_spring_app.log"

# Adding docker clean up at the beginning to keep previous test state
# in case we need to debug and cleaning up docker could remove logs.
Expand Down
13 changes: 8 additions & 5 deletions test/bin/run_api_tests.sh
Original file line number Diff line number Diff line change
Expand Up @@ -15,11 +15,14 @@ _get_osmt_project_dir() {
}

function source_osmt_apitest_env_file() {
echo "Sourcing $apitest_env_file"
set -o allexport
# shellcheck source="test/osmt-apitest.env"
source "$apitest_env_file"
set +o allexport
# Checks to see if osmt-apitest.env file exists
if [[ -f "${apitest_env_file}" || -r "${apitest_env_file}" ]]; then
echo "Sourcing $apitest_env_file"
set -o allexport
# shellcheck source="test/osmt-apitest.env"
source "$apitest_env_file"
set +o allexport
fi
}

function get_bearer_token() {
Expand Down
1 change: 1 addition & 0 deletions test/postman/test-injector.js
Original file line number Diff line number Diff line change
Expand Up @@ -97,6 +97,7 @@ function main() {
console.log(`\nERROR: Could not parse test information for the following `
+ `${failedEndpoints.length} endpoint(s):`);
console.log(failedEndpoints);
throw 135
}
else {
console.log("INFO: All collection endpoints successfully populated with tests.");
Expand Down