Skip to content

Commit ca32af7

Browse files
Added logic to mute noisy env vars. (#11115)
Added logic to mute noisy env vars. Fixed review notes. Co-authored-by: alexey.kuznetsov <alexey.kuznetsov@datadoghq.com>
1 parent 5ac3677 commit ca32af7

File tree

1 file changed

+14
-2
lines changed

1 file changed

+14
-2
lines changed

dd-smoke-tests/src/main/groovy/datadog/smoketest/ProcessManager.groovy

Lines changed: 14 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
package datadog.smoketest
22

3+
import com.google.common.collect.ImmutableSet
34
import datadog.trace.agent.test.utils.PortUtils
45
import java.nio.file.Files
56
import java.nio.file.Paths
@@ -15,6 +16,7 @@ abstract class ProcessManager extends Specification {
1516
public static final String SERVICE_NAME = "smoke-test-java-app"
1617
public static final String ENV = "smoketest"
1718
public static final String VERSION = "99"
19+
public static final Set<String> NOISY_ENVIRONMENT_VARIABLES = ImmutableSet.of('CI_COMMIT_MESSAGE')
1820

1921
@Shared
2022
protected String buildDirectory = System.getProperty("datadog.smoketest.builddir")
@@ -77,8 +79,10 @@ abstract class ProcessManager extends Specification {
7779
(0..<numberOfProcesses).each { idx ->
7880
ProcessBuilder processBuilder = createProcessBuilder(idx)
7981

80-
processBuilder.environment().put("JAVA_HOME", System.getProperty("java.home"))
81-
processBuilder.environment().put("DD_API_KEY", apiKey())
82+
Map<String, String> env = processBuilder.environment()
83+
env.put("JAVA_HOME", System.getProperty("java.home"))
84+
env.put("DD_API_KEY", apiKey())
85+
muteNoisyEnvironmentVariables(env)
8286

8387
processBuilder.redirectErrorStream(true)
8488

@@ -191,6 +195,14 @@ abstract class ProcessManager extends Specification {
191195
|| line.contains("Failed to handle exception in instrumentation")
192196
}
193197

198+
/**
199+
* Some variable can be printed in smoke application logs and result into false-positive test result.
200+
* @param env environment variables to process.
201+
*/
202+
void muteNoisyEnvironmentVariables(Map<String, String> env) {
203+
env.keySet().removeAll(NOISY_ENVIRONMENT_VARIABLES)
204+
}
205+
194206
/**
195207
* Asserts that there are no errors printed by the application to the log.
196208
* This should usually be called after the process exits, otherwise it's not guaranteed that reading the log file will

0 commit comments

Comments
 (0)