Skip to content

Latest commit

 

History

History
96 lines (86 loc) · 4.58 KB

validator.md

File metadata and controls

96 lines (86 loc) · 4.58 KB

Initializer Validator

In a nutshell

The Initializer Validator is a standalone fatjar to make dry runs of your OpenMRS configs and to report on any errors. This enables developers and implementers to be warned well ahead of time that a config would fail when loaded on real OpenMRS instances.

How it works

The Initializer Validator replays OpenMRS configs in a Spring context-sensitive test environment, very much like any OpenMRS Spring context-sensitive test. This means that the data (or metadata in this case) is loaded in a real database, in fact an instance of MariaDB. This ensures that the dry run occurs in an environment that is very close to the real app runtime setup.

How to make a dry run

  1. Build Initializer with the validator profile
mvn clean package -P validator
  1. Locate a config that you want to validate, eg. at /Users/mksd/repos/openmrs-config-acme/configuration.
  2. Run it (use absolute paths for arguments):
java -jar ./validator/target/initializer-validator-2.2.0.jar \
  --config-dir=/Users/mksd/repos/openmrs-config-acme/configuration
  1. That's it! The dry run will either pass or fail.
    In case of failures all the relevant logs can be analysed at ./validator/target/initializer.log.

Dry run examples

On top of CIEL
java -jar ./validator/target/initializer-validator-2.2.0.jar \
  --config-dir=/Users/mksd/repos/openmrs-config-acme/configuration \
  --ciel-file=/Users/mksd/Downloads/openmrs_concepts_2.2_20200927.sql
Skipping some domains
java -jar validator/target/initializer-validator-2.2.0.jar \
  --config-dir=/Users/mksd/repos/openmrs-config-acme/configuration \
  --domains='!metadatasharing,privileges,roles'
Including only some domains
java -jar validator/target/initializer-validator-2.2.0.jar \
  --config-dir=/Users/mksd/repos/openmrs-config-acme/configuration \
  --domains='concepts,locations'
Excluding some files in a domain
java -jar validator/target/initializer-validator-2.2.0.jar \
  --config-dir=/Users/mksd/repos/openmrs-config-acme/configuration \
  --exclude.concepts='*diags*,*interventions*'

In the above example all 'concepts' domain files matching the wildcard patterns *diags* and *interventions* will be filtered out.

Unsafe mode
java -jar ./validator/target/initializer-validator-2.2.0.jar \
  --config-dir=/Users/mksd/repos/openmrs-config-acme/configuration --unsafe

The unsafe mode will break as soon as the first loading error occurs, triggering the validation to stop short. This mode is particularly suitable for CI processes that just need to fail early.

CLI arguments

Just run the fatjar with no arguments (or with the --help argument) to get a list of all possible options:

java -jar validator/target/initializer-validator-2.2.0.jar

Kwown issues

mariaDB4j "dyld: Library not loaded" on macOS:
"dyld: Library not loaded: /usr/local/opt/openssl/lib/libssl.1.0.0.dylib"

This will only clearly come out when runnnig the Initializer Validator in --verbose mode.

Try the following commands (assuming you are using Homebrew):

  1. Uninstall openssl:
brew uninstall --ignore-dependencies openssl
  1. Install openssl 1.0.x:
brew tap-new company/team; brew extract --version 1.0.2t openssl company/team; brew install company/team/[email protected]
  1. Link it to the expected path:
ln -s /usr/local/Cellar/[email protected]/1.0.2t /usr/local/opt/openssl

This replaces the openssl vesion currently installed with version 1.0.2t. To undo this, just upgrade openssl: brew upgrade openssl.

References:
mariaDB4j "error while loading shared libraries: libncurses.so.5" on Debian:
mysql: /tmp/MariaDB4j/base/bin/mysql:
  error while loading shared libraries: libncurses.so.5: cannot open shared object file: No such file or directory

This will only clearly come out when runnnig the Initializer Validator in --verbose mode.

Try this suggested solution from Stack Overflow: 'error while loading shared libraries: libncurses.so.5:'