Skip to content

Commit

Permalink
issue-1922 merged with main and fixed minor args error with issue-2211
Browse files Browse the repository at this point in the history
Signed-off-by: Robin Arnold <robin.arnold23@ibm.com>
  • Loading branch information
punktilious committed Jun 21, 2021
2 parents bf6b18a + e26a302 commit 6c18b9b
Show file tree
Hide file tree
Showing 871 changed files with 68,037 additions and 11,713 deletions.
1 change: 1 addition & 0 deletions .github/ISSUE_TEMPLATE/feature_request.md
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ A clear and concise description of what you want to happen.
A clear and concise description of any alternative solutions or features you've considered.

**Acceptance Criteria**

1.
GIVEN [a precondition]
AND [another precondition]
Expand Down
47 changes: 47 additions & 0 deletions .github/workflows/reindex.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
name: Reindex - Integration Tests

on:
pull_request:
paths-ignore:
- 'docs/**'
- 'demo/**'
- '.github/workflows/site.yml'
- '.github/workflows/release.yml'

jobs:
reindex:
runs-on: ubuntu-latest
if: "!contains(github.event.pull_request.labels.*.name, 'ci-skip')"
strategy:
matrix:
datastore: [ 'db2', 'derby', 'postgres' ]
fail-fast: false
steps:
- name: Checkout source code
uses: actions/checkout@v2.3.4
- name: Set up java
uses: joschi/setup-jdk@v2.3.0
with:
java-version: 11
- name: Setup prerequisites
env:
WORKSPACE: ${{ github.workspace }}
run: bash build/reindex/bin/setup-prerequisites.sh ${{matrix.datastore}}
- name: Integration Tests
env:
WORKSPACE: ${{ github.workspace }}
run: |
bash build/reindex/bin/pre-integration-test.sh ${{matrix.datastore}}
bash build/reindex/bin/integration-test.sh ${{matrix.datastore}}
bash build/reindex/bin/post-integration-test.sh ${{matrix.datastore}}
- name: Gather error logs
if: failure()
env:
WORKSPACE: ${{ github.workspace }}
run: bash build/common/gather-logs.sh reindex ${{matrix.datastore}}
- name: Upload logs
if: always()
uses: actions/upload-artifact@v2.2.0
with:
name: integration-test-results-${{ matrix.datastore }}
path: build/reindex/integration-test-results
8 changes: 4 additions & 4 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -26,9 +26,9 @@ pull request so it can be tracked.

### Merge approval

The project maintainers use LGTM (Looks Good To Me) in comments on the code
review to indicate acceptance. A change requires LGTMs from two of the
maintainers of each component affected.
The project maintainers use [GitHub reviews](https://github.com/features/code-review) to indicate acceptance.
A change requires approval from two of the maintainers of each component affected.
Sometimes, reviewers will leave a comment "LGTM" to indicate that the change "looks good to me".

For a list of the maintainers, see the [MAINTAINERS.md](MAINTAINERS.md) page.

Expand Down Expand Up @@ -86,7 +86,7 @@ The IBM FHIR Server has been written by many individuals over many years. Format

2. Use comments. Preferably javadoc.

3. Keep the documentation up-to-date. Project documentation exists under the docs directory. We have a CHANGELOG for tracking user-visible changes, a Conformance page for documenting conformance to the specification, and a User Guide for FHIR Server administrators.
3. Keep the documentation up-to-date. Project documentation exists under the docs directory. We have a Conformance page for documenting conformance to the specification, a User Guide for FHIR Server administrators, and other guides for select topics of interest. In addition to the project site, we also have README.md files for many of the modules.

4. Use spaces (not tabs) in java source. For this we have a checkstyle rule which will fail the build if you're using tabs. We also prefer spaces over tabs in JSON and XML, but its not strictly enforced.

Expand Down
3 changes: 2 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -102,14 +102,15 @@ The IBM FHIR Server is modular and extensible. The following tables provide an o
|fhir-operation-document|Basic support for the Composition `$document` operation defined at https://www.hl7.org/fhir/operation-composition-document.html |false|
|fhir-operation-healthcheck|The `$healthcheck` operation checks for a valid connection to the database and returns the server status|false|
|fhir-operation-term|[Terminology service](https://www.hl7.org/fhir/terminology-service.html) operations which use the default fhir-term TerminologyServiceProvider to implement $expand, $lookup, $subsumes, $closure, $validate and $translate|false|
|fhir-operation-term-cache|Add-on module that provides operations for clearing the terminology subsystem caches for non-production scenarios|false|
|fhir-operation-validate|An implementation of the FHIR resource [$validate operation](https://www.hl7.org/fhir/R4/operation-resource-validate.html)|false|
|fhir-operation-everything|An implementation of the FHIR patient [`$everything`](https://www.hl7.org/fhir/operation-patient-everything.html) operation|false|
|fhir-operation-erase|A hard delete operation for resource instances referred to as the `$erase` operation. See the [README.md](operation/fhir-operation-erase/README.md)|false|

#### Client
|Module|Description|Java API-stable|
|------|-----------|----------|
|fhir-client|A FHIR Client that re-uses the IBM FHIR Server model and its JAX-RS Providers|false|
|fhir-cli|Experimental command line interface utility for working with the IBM FHIR Server client from the command line|false|

#### Tools and Utilities
|Module|Description|Java API-stable|
Expand Down
1 change: 1 addition & 0 deletions build/audit/kafka/pre-integration-test.sh
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@ config(){
mkdir -p $USERLIB
find ${WORKSPACE}/conformance -iname 'fhir-ig*.jar' -not -iname 'fhir*-tests.jar' -not -iname 'fhir*-test-*.jar' -exec cp -f {} ${USERLIB} \;
cp -pr ${WORKSPACE}/operation/fhir-operation-test/target/fhir-operation-*-tests.jar ${USERLIB}
cp -pr ${WORKSPACE}/operation/fhir-operation-term-cache/target/fhir-operation-*.jar ${USERLIB}
echo "Finished copying fhir-server dependencies..."

# Move over the test configurations
Expand Down
74 changes: 74 additions & 0 deletions build/common/gather-logs.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,74 @@
#!/usr/bin/env bash

###############################################################################
# (C) Copyright IBM Corp. 2021
#
# SPDX-License-Identifier: Apache-2.0
###############################################################################

set -ex

# Gathers the logs
package_logs(){
workflow="${1}"
job="${2}"
echo "Gathering logs for [${workflow}/${job}]"

it_results=${WORKSPACE}/build/${workflow}/integration-test-results
if [ ! -d ${it_results} ]
then
rm -fr ${it_results} 2>/dev/null
fi

mkdir -p ${it_results}
mkdir -p ${it_results}/server-logs
mkdir -p ${it_results}/fhir-server-test

# Runtime Date
echo $(date) > ${it_results}/runtime.txt

# Look for the FHIR Server Container
containerId=$(docker ps -a | grep ibm-fhir-server | cut -d ' ' -f 1)
if [ -z "${containerId}" ]
then
echo "Warning: Could not find fhir container!!!"
else
echo "fhir container id: $containerId"
# Grab the container's console log
docker logs $containerId >& ${it_results}/docker-console.txt

echo "Gathering post-test server logs from docker container: $containerId"
docker cp -L $containerId:/logs ${it_results}/server-logs
fi

echo "Gathering integration test output"
if [ -d ${WORKSPACE}/fhir-server-test/target/surefire-reports ]
then
cp -pr ${WORKSPACE}/fhir-server-test/target/surefire-reports/* ${it_results}/fhir-server-test
fi

if [ -f ${WORKSPACE}/build/${workflow}/${job}/workarea/${job}-test1.log ]
then
echo "Move the '${job}' Elements to the output area'"
cp -pr build/${workflow}/${job}/workarea/${job}-test*.log ${it_results}
fi
}

###############################################################################
# Check if the workspace is set.
if [ -z "${WORKSPACE}" ]
then
echo "The WORKSPACE value is unset"
exit -1
fi

# Store the current directory to reset to
pushd $(pwd) > /dev/null

package_logs "${1}" "${2}"

# Reset to Original Directory
popd > /dev/null

# EOF
###############################################################################
1 change: 1 addition & 0 deletions build/docker/copy-test-operations.sh
Original file line number Diff line number Diff line change
Expand Up @@ -19,5 +19,6 @@ mkdir -p $USERLIB
echo "Copying test artifacts to install location..."
find ${WORKSPACE}/conformance -iname 'fhir-ig*.jar' -not -iname 'fhir*-tests.jar' -not -iname 'fhir*-test-*.jar' -exec cp -f {} ${USERLIB} \;
cp -pr ${WORKSPACE}/operation/fhir-operation-test/target/fhir-operation-*-tests.jar ${USERLIB}
cp -pr ${WORKSPACE}/operation/fhir-operation-term-cache/target/fhir-operation-*.jar ${USERLIB}

echo "Finished copying test operations."
1 change: 1 addition & 0 deletions build/notifications/kafka/pre-integration-test.sh
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@ config(){
mkdir -p $USERLIB
find ${WORKSPACE}/conformance -iname 'fhir-ig*.jar' -not -iname 'fhir*-tests.jar' -not -iname 'fhir*-test-*.jar' -exec cp -f {} ${USERLIB} \;
cp -pr ${WORKSPACE}/operation/fhir-operation-test/target/fhir-operation-*-tests.jar ${USERLIB}
cp -pr ${WORKSPACE}/operation/fhir-operation-term-cache/target/fhir-operation-*.jar ${USERLIB}
echo "Finished copying fhir-server dependencies..."

# Move over the test configurations
Expand Down
1 change: 1 addition & 0 deletions build/persistence/postgres/pre-integration-test.sh
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,7 @@ copy_server_config(){
echo "Copying test artifacts to install location..."
find ${WORKSPACE}/conformance -iname 'fhir-ig*.jar' -not -iname 'fhir*-tests.jar' -not -iname 'fhir*-test-*.jar' -exec cp -f {} ${USERLIB} \;
cp -pr ${WORKSPACE}/operation/fhir-operation-test/target/fhir-operation-*-tests.jar ${USERLIB}
cp -pr ${WORKSPACE}/operation/fhir-operation-term-cache/target/fhir-operation-*.jar ${USERLIB}
echo "Finished copying fhir-server dependencies..."
}

Expand Down
3 changes: 3 additions & 0 deletions build/pre-integration-test.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -118,6 +118,9 @@ If (!(Test-Path -Path $USERLIB_DIR) ) {
}
Copy-Item $CP_ITEM -Destination $USERLIB_DST

$CP_ITEM=[string]$DIR_WORKSPACE + '\operation\fhir-operation-term-cache\target\fhir-operation-term-cache-*.jar'
Copy-Item $CP_ITEM -Destination $USERLIB_DST

# Start up the fhir server
$DATE_PS=[System.TimeZoneInfo]::ConvertTimeBySystemTimeZoneId((Get-Date), 'Greenwich Standard Time').ToString('t')
Write-Host '>>> Current time: ' $DATE_PS
Expand Down
1 change: 1 addition & 0 deletions build/pre-integration-test.sh
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,7 @@ cp -p ${WORKSPACE}/fhir-server/liberty-config/configDropins/disabled/datasource-
echo "Copying test artifacts to install location..."
rm -rf ${SIT}/wlp/usr/servers/fhir-server/userlib/fhir-operation-*-tests.jar
cp -pr ${WORKSPACE}/operation/fhir-operation-test/target/fhir-operation-*-tests.jar ${SIT}/wlp/usr/servers/fhir-server/userlib/
cp -pr ${WORKSPACE}/operation/fhir-operation-term-cache/target/fhir-operation-*.jar ${SIT}/wlp/usr/servers/fhir-server/userlib/
find ${WORKSPACE}/conformance -iname 'fhir-ig*.jar' -not -iname 'fhir*-tests.jar' -not -iname 'fhir*-test-*.jar' -exec cp -f {} ${SIT}/wlp/usr/servers/fhir-server/userlib/ \;

# Start up the fhir server
Expand Down
2 changes: 2 additions & 0 deletions build/reindex/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
**/integration-test-results
**/workarea
48 changes: 48 additions & 0 deletions build/reindex/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
# Integration Test Framework for the $reindex Operation

This document outlines the end-to-end reindex automation framework.

The automation runs with these steps:

- **Checkout source code** - Checks out the git code and populates the `github` environment variables.
- **Set up java** - Downloads and setup for Java 11
- **Setup prerequisites** - This step builds the required artifacts necessary to test the build with the reindex.
- **Integration Tests** - The step executes the pre-integration-docker, then integration-test-docker and runs the post-integration-docker scripts.
- **Gather error logs** - This step only runs upon a failure condition.
- **Upload logs** - The step uploads the results of the integration tests and the operational logs are posted to the job.

The GitHub Action is parameterized with a matrix for each new `$reindex` tests. Each additional entry in the array ends up creating multiple automation steps which must complete successfully for the workflow.

``` yaml
strategy:
matrix:
datastore: [ 'db2', 'derby', 'postgres' ]
```
Each datastore layer that is tested as part of the framework uses the default build files and the files that match the `matrix.datastore` name added to the `reindex.yml`.

|Filename|Purpose|
|----------|----------------|
|bin/gather-logs.sh|Gathers the logs from the build|
|bin/integration-test.sh|Run after the tests complete to release resources and package tests results|
|bin/setup-prerequisites.sh|Builds the fhir-server|
|bin/pre-integration-test.sh|Call the pre-integration-test step for `<datastore>`|
|bin/post-integration-test.sh|Call the post-integration-test step for `<datastore>`|
|`<datastore>`/integration-test.sh|if exists, overrides bin/integration-test.sh, replacing the prior test behavior.|
|`<datastore>`/pre-integration-test.sh|Run before integration-test.sh to startup image and services for the integration testing|
|`<datastore>`/post-integration-test.sh|if exists, runs after integration-test.sh to stop image and services from the integration testing|
|`<datastore>`/.gitignore|Ignores files related to the reindex layer's tests|
|`README.md`|This file describing the reindex framework|

Note, `<datastore>` is replaced with your reindex layer such as `db2`.

Transaction Timeout is 300 seconds.

Consult the reference implementation (`db2`) to start a new reindex tests. The minimum that must be implemented are the `pre-integration-test.sh` and `.gitignore`.

## Test the Automation

To test the build, be sure to pre-set the environment variable `WORKSPACE` with `export WORKSPACE=$(pwd)`.
You must also start Docker, so the image is built that supports the IBM FHIR Server.

If you have any questions, please reach out on Zulip.
120 changes: 120 additions & 0 deletions build/reindex/bin/integration-test.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,120 @@
#!/usr/bin/env bash

###############################################################################
# (C) Copyright IBM Corp. 2021
#
# SPDX-License-Identifier: Apache-2.0
###############################################################################

set -ex
set -o pipefail

# spins for a set time until the server is up
wait_for_it(){
# Wait until the fhir server is up and running...
echo "Waiting for fhir-server to complete initialization..."
healthcheck_url='https://localhost:9443/fhir-server/api/v4/$healthcheck'
tries=0
status=0
while [ $status -ne 200 -a $tries -lt 30 ]; do
tries=$((tries + 1))

set +o errexit
cmd="curl -k -o ${WORKSPACE}/health.json --max-time 5 -I -w "%{http_code}" -u fhiruser:change-password $healthcheck_url"
echo "Executing[$tries]: $cmd"
status=$($cmd)
set -o errexit

echo "Status code: $status"
if [ $status -ne 200 ]
then
echo "Sleeping 30 secs..."
sleep 30
fi
done

if [ $status -ne 200 ]
then
echo "Could not establish a connection to the fhir-server within $tries REST API invocations!"
exit 1
fi

echo "The fhir-server appears to be running..."
}

run_tests(){
# The integration tests may be overriden completely, or fall through to the default.
reindex="${1}"

if [ ! -z "${reindex}" ] && [ -f "build/reindex/${reindex}/integration-test.sh" ]
then
echo "Running [${reindex}] specific integration tests"
bash build/reindex/${reindex}/integration-test.sh
else
# Go to the Default
echo "Executing the default integration tests"
sed -i -e 's/test.reindex.enabled = false/test.reindex.enabled = true/g' ${WORKSPACE}/fhir-server-test/src/test/resources/test.properties

# Test 1 - Basic Tests for Reindex
mvn -B test -f fhir-server-test -DskipWebSocketTest=true --no-transfer-progress \
-DskipTests=false -Dtest="com.ibm.fhir.server.test.operation.ReindexOperationTest" | tee build/reindex/${reindex}/workarea/${reindex}-test1.log

# Test 2 - Long Run Tests *895 Resources*
mvn -B test -f fhir-server-test -DskipWebSocketTest=true --no-transfer-progress \
-DskipTests=false -Dtest="com.ibm.fhir.server.test.operation.ReindexOperationLongRunTest" | tee build/reindex/${reindex}/workarea/${reindex}-test2.log

# Test 3 Phase 1
mvn -B test -f fhir-server-test -DskipWebSocketTest=true --no-transfer-progress \
-DskipTests=false -Dtest="com.ibm.fhir.server.test.operation.ReindexOperationPhase1Test" | tee build/reindex/${reindex}/workarea/${reindex}-test3.log

# Update SPs
cp -pr ${WORKSPACE}/fhir-server-test/src/test/resources/testdata/reindex-operation/extension-search-parameters-test1.json \
${WORKSPACE}/build/reindex/${reindex}/workarea/volumes/dist/config/default/extension-search-parameters.json

# Restart
cd build/reindex/${reindex}
docker-compose restart --timeout 30 fhir
cd -
wait_for_it

# Test 3 Phase 2
mvn -B test -f fhir-server-test -DskipWebSocketTest=true --no-transfer-progress \
-DskipTests=false -Dtest="com.ibm.fhir.server.test.operation.ReindexOperationPhase2Test" | tee build/reindex/${reindex}/workarea/${reindex}-test4.log

# Update SPs
cp -pr ${WORKSPACE}/fhir-server-test/src/test/resources/testdata/reindex-operation/extension-search-parameters-test2.json \
${WORKSPACE}/build/reindex/${reindex}/workarea/volumes/dist/config/default/extension-search-parameters.json

# Restart
cd build/reindex/${reindex}
docker-compose restart --timeout 30 fhir
cd -
wait_for_it

# Test 3 Phase 3
mvn -B test -f fhir-server-test -DskipWebSocketTest=true --no-transfer-progress \
-DskipTests=false -Dtest="com.ibm.fhir.server.test.operation.ReindexOperationPhase3Test" | tee build/reindex/${reindex}/workarea/${reindex}-test5.log
fi
}

###############################################################################
# Check if the workspace is set.
if [ -z "${WORKSPACE}" ]
then
echo "The WORKSPACE value is unset"
exit -1
fi

# Store the current directory to reset to
pushd $(pwd) > /dev/null

# Change to the reindex/bin directory
cd "${WORKSPACE}"

run_tests "${1}"

# Reset to Original Directory
popd > /dev/null

# EOF
###############################################################################
Loading

0 comments on commit 6c18b9b

Please sign in to comment.