Testing the Changes

The tests in the service need to be updated to take advantage of the skaffold-test-lib that was placed in the pom dependencies earlier. This will allow Skaffold to provide full service URLs or individual host and port assignments as needed. Below are sample implementations where the currently existing URL/port/host would be replaced to use these calls to the test lib instead. In most cases this will be replacing the use of the K8sServiceValues used previously.

The values can only be used in the context of a JUNIT test.

Before using the skaffold-test-lib:

    final class K8s implements ITConfig {

...

        @Override
        public String getServiceUrl() {
            return K8sServiceValues.K8S_SERVICE_URL.getValue();
        }

        @Override
        public String getActuatorUrl() {
            return "http://"
                    + K8sServiceValues.K8S_VISTA_SITE_INFO_SERVICE_V1_HOST.getValue()
                    + ':'
                    + K8sServiceValues.K8S_VISTA_SITE_INFO_SERVICE_V1_ACTUATOR_PORT.getValue();

        @Override
        public String getWireMockHost() {
            return K8sServiceValues.K8S_WIREMOCK_HOST.getValue();
        }

        @Override
        public int getWireMockPort() {
            return Integer.parseInt(K8sServiceValues.K8S_WIREMOCK_WIREMOCK_PORT.getValue());
...

After using the skaffold-test-lib:

        @Override
        public String getServiceUrl() {
            return SkaffoldTestSupport.getServiceUrl("vista-site-info-service-v1", 8080, "/vsis/v1");
        }

        @Override
        public String getActuatorUrl() {
            return SkaffoldTestSupport.getServiceUrl("vista-site-info-service-v1", 8081);
        }

        @Override
        public String getWireMockHost() {
            return SkaffoldTestSupport.getHost("wiremock");
        }

        @Override
        public int getWireMockPort() {
            return SkaffoldTestSupport.getPort("wiremock", 8080);

The three main methods that the test-lib introduces are the getServiceUrl(), getHost(), and getPort() as seen in the examples above. Assuming that the correct resource name, path, and port are used for the service or any dependent services that have been loaded, the test-lib will connect appropriately during testing.

Building and Testing

Build and Run Integration Tests (IT)

skaffold dev

followed by:

mvn verify -Pskaffold-integration

Integration tests will run during this process. Additionally, you could execute tests from the IDE as skaffold dev will keep the project running.

Build and Run IT, Shutdown after completion

mvn clean install -Pwith-skaffold : runs IT and cleans up.

Note that any previous Skaffold runs should be deleted before running to avoid issues. This can be done using the skaffold delete command.

Build and run, No IT

mvn clean pre-integration-test -Pwith-skaffold