Add it for gcp with service context (#154)
This commit is contained in:
parent
0ff96ad9ce
commit
909fd62283
3 changed files with 36 additions and 0 deletions
3
src/it/log-gcp-with-service/invoker.properties
Normal file
3
src/it/log-gcp-with-service/invoker.properties
Normal file
|
@ -0,0 +1,3 @@
|
|||
invoker.environmentVariables.LOGBACK_APPENDER=GCP
|
||||
invoker.environmentVariables.SERVICE_NAME=test-service
|
||||
invoker.environmentVariables.SERVICE_VERSION=0.1.2
|
12
src/it/log-gcp-with-service/pom.xml
Normal file
12
src/it/log-gcp-with-service/pom.xml
Normal file
|
@ -0,0 +1,12 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 https://maven.apache.org/xsd/maven-4.0.0.xsd">
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
|
||||
<parent>
|
||||
<groupId>@project.groupId@</groupId>
|
||||
<artifactId>@project.artifactId@-it</artifactId>
|
||||
<version>LOCAL-SNAPSHOT</version>
|
||||
</parent>
|
||||
|
||||
<artifactId>@project.artifactId@-it-log-gcp-with-service</artifactId>
|
||||
</project>
|
21
src/it/log-gcp-with-service/postbuild.bsh
Normal file
21
src/it/log-gcp-with-service/postbuild.bsh
Normal file
|
@ -0,0 +1,21 @@
|
|||
// verify log
|
||||
|
||||
String expected = "^\\{\"time\":\"202[3-9]-[0-9]{2}-[0-9]{2}T[0-9]{2}:[0-9]{2}:[0-9]{2}.[0-9]{0,3}Z\",\"severity\":\"INFO\",\"thread\":\"main\",\"logger\":\"io.kokuwa.micronaut.logging.LoggingTest\",\"message\":\"test-output-marker\",\"raw-message\":\"test-output-marker\",\"serviceContext\":\\{\"version\":\"0.1.2\",\"service\":\"test-service\"}}$";
|
||||
String[] logs = org.codehaus.plexus.util.FileUtils.fileRead(basedir + "/build.log").split("\n");
|
||||
|
||||
for (String log : logs) {
|
||||
if (!log.contains("test-output-marker")) {
|
||||
continue;
|
||||
}
|
||||
if (java.util.regex.Pattern.matches(expected, log)) {
|
||||
return true;
|
||||
} else {
|
||||
System.out.println("marker found, but formatting invalid:");
|
||||
System.out.println("[EXPECTED] " + expected);
|
||||
System.out.println("[ACTUAL] " + log);
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
System.out.println("marker not found");
|
||||
return false;
|
Loading…
Add table
Add a link
Reference in a new issue