VirusTotalNet icon indicating copy to clipboard operation
VirusTotalNet copied to clipboard

Improve test execution and reporting for Java8 template

Open psoares opened this issue 5 years ago • 0 comments

The current multi-stage build Dockerfile executes a simple gradle build without ways of injecting variables to the test task. Tests that depend on environment variables will fail. A particular use case is an integration test that retrieves credentials from the outside.

Expected Behaviour

I should be able to pass system properties and gradle properties to the build command, so I can add them to build.gradle. See https://docs.gradle.org/current/userguide/build_environment.html

Current Behaviour

Assuming the following test:

public class IntegrationTests {

    private Logger log = LoggerFactory.getLogger(IntegrationTests.class);

    @Test
    public void testTheRealDB() {
       
        assertNotNull("Missing DB_USER environment variable", System.getenv("DB_USER"));
        assertNotNull("Missing DB_PSWD environment variable", System.getenv("DB_PSWD"));

        String username = System.getenv("DB_USER");
        String password = System.getenv("DB_PSWD");
        // [...] 
    }
}

Possible Solution

Allow for extra arguments in the gradle build command. e.g. on the Dockerfile, replace line 23:

RUN gradle build

by

ENV GRADLE_BUILD_ARGS=""
RUN gradle build $GRADLE_BUILD_ARGS

Context

Can't run a test similar to the above from a Jenkins CI build.

Your Environment

  • Docker version docker version (e.g. Docker 17.0.05 ): Docker 18.09.2
  • Are you using Docker Swarm or Kubernetes (FaaS-netes)? Kubernetes
  • Operating System and version (e.g. Linux, Windows, MacOS): MacOS

psoares avatar Jun 20 '19 21:06 psoares