This repository was archived by the owner on Jul 27, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 118
This repository was archived by the owner on Jul 27, 2023. It is now read-only.
Appsody test is not working on spring boot 2 #821
Copy link
Copy link
Open
Labels
stack/java-spring-boot2Issues related to java-spring-boot2 stackIssues related to java-spring-boot2 stack
Description
Describe the bug
Unable to run unit tests on the default MainTest class that gets generated when using
appsody test.
To Reproduce
Steps to reproduce the behavior:
brew install appsody
mkdir plain-java-appsody
cd plain-java-appsody
appsody init kabanero/java-spring-boot2
appsody testStep 3 generates the MainTests class
@RunWith(SpringRunner.class)
@SpringBootTest(webEnvironment = WebEnvironment.RANDOM_PORT)
public class MainTests {
@Autowired
private TestRestTemplate restTemplate;
@Test
public void testHealthEndpoint() {
ResponseEntity<String> entity = this.restTemplate.getForEntity("/actuator/health", String.class);
assertThat(entity.getStatusCode()).isEqualTo(HttpStatus.OK);
assertThat(entity.getBody()).contains("\"status\":\"UP\"");
}
@Test
public void testLivenessEndpoint() {
ResponseEntity<String> entity = this.restTemplate.getForEntity("/actuator/liveness", String.class);
assertThat(entity.getStatusCode()).isEqualTo(HttpStatus.OK);
assertThat(entity.getBody()).contains("\"status\":\"UP\"");
}
@Test
@SuppressWarnings("unchecked")
public void testMetricsEndpoint() {
testLivenessEndpoint(); // access a page
@SuppressWarnings("rawtypes")
ResponseEntity<Map> entity = this.restTemplate.getForEntity("/actuator/metrics", Map.class);
assertThat(entity.getStatusCode()).isEqualTo(HttpStatus.OK);
Map<String, Object> body = entity.getBody();
assertThat(body).containsKey("names");
assertThat((List<String>) body.get("names")).contains("jvm.buffer.count");
}
@Test
public void testPrometheusEndpoint() {
testLivenessEndpoint(); // access a page
ResponseEntity<String> entity = this.restTemplate.getForEntity("/actuator/prometheus", String.class);
assertThat(entity.getStatusCode()).isEqualTo(HttpStatus.OK);
assertThat(entity.getBody()).contains("# TYPE jvm_buffer_count_buffers gauge");
}
}
Expected behavior
I need to understand when using appsody test the test classes do not run. What it should do, it should run the test class that got generated by appsody.
Actual behaviour
The build is successful but I do not get any indication that the test cases passed/failed.
Running test environment
Pulling docker image docker.io/kabanero/java-spring-boot2:0.3
Running command: docker pull docker.io/kabanero/java-spring-boot2:0.3
0.3: Pulling from kabanero/java-spring-boot2
Digest: sha256:5c7154e6758d60c3a2aa855ada917aa7da02ca40740f41637166d30aed3b4733
Status: Image is up to date for kabanero/java-spring-boot2:0.3
docker.io/kabanero/java-spring-boot2:0.3
[Warning] The stack image does not contain APPSODY_DEPS
Running command: docker run --rm -p 35729:35729 -p 5005:5005 -p 8080:8080 -p 8443:8443 --name plain-java-appsody -u 501:20 -e "APPSODY_USER=501" -e "APPSODY_GROUP=20" -v "/Users/Oscar.Ricaud@ibm.com/Documents/gse-devops/github.com/plain-java-appsody/:/project/user-app" -v "/Users/Oscar.Ricaud@ibm.com/.m2/repository:/mvn/repository" -v appsody-controller-0.3.5:/.appsody -t --entrypoint /.appsody/appsody-controller docker.io/kabanero/java-spring-boot2:0.3 "--mode=test"
[Container] Running command: /project/java-spring-boot2-build.sh test
[Container] Installing parent dev.appsody:spring-boot2-stack:0.3.29 and required dependencies...
[Container] > mvn install -q -f /project/appsody-boot2-snowdrop-pom.xml
[Container] Test project in the foreground
[Container] > mvn package test
[Container] [INFO] Scanning for projects...
[Container] [INFO]
[Container] [INFO] ----------------------< dev.appsody:application >-----------------------
[Container] [INFO] Building application 0.0.1-SNAPSHOT
[Container] [INFO] --------------------------------[ jar ]---------------------------------
[Container] [INFO]
[Container] [INFO] --- maven-resources-plugin:2.6:resources (default-resources) @ application ---
[Container] [INFO] Using 'UTF-8' encoding to copy filtered resources.
[Container] [INFO] Copying 2 resources
[Container] [INFO]
[Container] [INFO] --- maven-compiler-plugin:3.1:compile (default-compile) @ application ---
[Container] [INFO] Nothing to compile - all classes are up to date
[Container] [INFO]
[Container] [INFO] --- maven-antrun-plugin:1.1:run (trigger-spring-restart) @ application ---
[Container] [INFO] Executing tasks
[Container] [echo] Triggering Spring app restart.
[Container] [INFO] Executed tasks
[Container] [INFO]
[Container] [INFO] --- maven-resources-plugin:2.6:testResources (default-testResources) @ application ---
[Container] [INFO] Using 'UTF-8' encoding to copy filtered resources.
[Container] [INFO] skip non existing resourceDirectory /project/user-app/src/test/resources
[Container] [INFO]
[Container] [INFO] --- maven-compiler-plugin:3.1:testCompile (default-testCompile) @ application ---
[Container] [INFO] Nothing to compile - all classes are up to date
[Container] [INFO]
[Container] [INFO] --- maven-surefire-plugin:2.12.4:test (default-test) @ application ---
[Container] [INFO]
[Container] [INFO] --- maven-jar-plugin:2.4:jar (default-jar) @ application ---
[Container] [INFO]
[Container] [INFO] --- spring-boot-maven-plugin:2.1.12.RELEASE:repackage (default) @ application ---
[Container] [INFO] Replacing main artifact with repackaged archive
[Container] [INFO]
[Container] [INFO] --- maven-resources-plugin:2.6:resources (default-resources) @ application ---
[Container] [INFO] Using 'UTF-8' encoding to copy filtered resources.
[Container] [INFO] Copying 2 resources
[Container] [INFO]
[Container] [INFO] --- maven-compiler-plugin:3.1:compile (default-compile) @ application ---
[Container] [INFO] Nothing to compile - all classes are up to date
[Container] [INFO]
[Container] [INFO] --- maven-antrun-plugin:1.1:run (trigger-spring-restart) @ application ---
[Container] [INFO] Executing tasks
[Container] [echo] Triggering Spring app restart.
[Container] [INFO] Executed tasks
[Container] [INFO]
[Container] [INFO] --- maven-resources-plugin:2.6:testResources (default-testResources) @ application ---
[Container] [INFO] Using 'UTF-8' encoding to copy filtered resources.
[Container] [INFO] skip non existing resourceDirectory /project/user-app/src/test/resources
[Container] [INFO]
[Container] [INFO] --- maven-compiler-plugin:3.1:testCompile (default-testCompile) @ application ---
[Container] [INFO] Nothing to compile - all classes are up to date
[Container] [INFO]
[Container] [INFO] --- maven-surefire-plugin:2.12.4:test (default-test) @ application ---
[Container] [INFO] Skipping execution of surefire because it has already been run for this configuration
[Container] [INFO] ------------------------------------------------------------------------
[Container] [INFO] BUILD SUCCESS
[Container] [INFO] ------------------------------------------------------------------------
[Container] [INFO] Total time: 13.411 s
[Container] [INFO] Finished at: 2020-05-28T16:24:06Z
[Container] [INFO] ------------------------------------------------------------------------
[Container] The file watcher is not running because no APPSODY_RUN/TEST/DEBUG_ON_CHANGE action was specified or it has been disabled using the --no-watcher flag.
Closing down development environment.Environment Details (please complete the following information):
- OS: Mac
- Browser Chrome
If applicable please specify:
- CLI version: 0.6.2
- Stack you are using (including the version): kabanero/java-spring-boot2
Metadata
Metadata
Assignees
Labels
stack/java-spring-boot2Issues related to java-spring-boot2 stackIssues related to java-spring-boot2 stack