Skip to content

Running Individual Unit Tests

James McMullan edited this page May 15, 2024 · 3 revisions

Checkout HPCC4j & Project Setup

Clone the project:

git clone https://github.com/hpcc4j.git hpcc4j
cd hpcc4j

IDE & Environment Setup

Ensure that Maven is installed on your system. If not, you can download and install it from the official Apache Maven website: https://maven.apache.org.

Our team uses VSCode for development and have found that the Extension Pack for Java provides a lot of useful functionality including being able to execute individual unit tests from with VScode.

Finally a running HPCC Systems cluster is required to run integration tests. See: Using HPCC4j with K8s for information on configuring a local K8s cluster for testing.

Project Structure & Test Locations

HPCC4j is comprised of a few subprojects:

  • Commons-HPCC
    • Contains utility code shared between the other subprojects
    • Ex: ECL Parsing, Compression etc
  • WSClient
    • Contains Java service APIs that correspond to ESP services. Ex: HPCCWsDFUClient, HPCCWsWorkUnitsClient, etc
  • DFSClient
    • Contains code to communicate with dafilesrv to read / write files as well as wrappers around the WsDFU services to make file reading / writing easier.

Each subproject contains a suite of unit and integration tests in their respective src/test/java directories.

Integration tests that require a running HPCC Systems cluster inherit from the BaseRemoteTest which is part of the WSClient subproject. Any and all future integration tests should also inherit from this class.

Running the Entire Unit Test Suite

Note: Before running tests make sure SSL certificates for the target HPCC Systems cluster are trusted on your system. See: Using HPCC4j with K8s for details.

Running the entire test suite can be done via the following command: (Note: The cluster URL below should be updated)

mvn -B --activate-profiles jenkins-on-demand -Dhpccconn=http://eclwatch.default:8010 -Dwssqlconn=http://sql2ecl.default:8510 package

Running Individual Unit Tests

Note: Before running tests make sure SSL certificates for the target HPCC Systems cluster are trusted on your system. See: Using HPCC4j with K8s for details.

Running individual tests can either be done via the following command: (Note: The cluster URL below should be updated)

mvn -B --activate-profiles jenkins-on-demand -pl wsclient -Dhpccconn=https://eclwatch.default:8010 -Dwssqlconn=http://sql2ecl.default:8510 -Dtest={fully.qualified.classname}#{testMethod} test

Running Tests from VSCode

If you have installed VSCode with the recommended extensions the test suite can also be run from the Testing tab within VSCode.

Each subproject, test class and even individual test methods can be run from within the Testing tab in VScode.

Note: When running tests the test suite look for specific environment variables to configure the HPCC Systems cluster to run against. These environment variables can be set at an OS level or you can temporarily change the defaults in BaseRemoteTest.java for testing purposes.

Relevant Env. Variables:

  • hpccconn
    • URL to the target HPCC Systems cluster
  • hpccuser
    • HPCC Systems user credentials
  • hpccpass
    • HPCC Systems user credentials
  • thorclustername
    • Name of the Thor cluster group to use for testing