Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,6 @@ public void setColorTerminal(Boolean colorTerminal) {
private Set<String> tracePatterns;

private int timeout = 10;
private boolean streamLogging;
private Globals globals;
private String consoleFormatPattern;

Expand All @@ -95,7 +94,6 @@ protected RunConfig(
Set<String> tracePatterns,
List<Stage> skipStages,
Globals globals,
boolean streamLogging,
String consoleFormatPattern){
this.name = name;
this.errors = errors;
Expand All @@ -112,12 +110,11 @@ protected RunConfig(
this.tracePatterns = new HashSet<>(tracePatterns);
this.skipStages = skipStages;
this.globals = globals;
this.streamLogging = streamLogging;
this.consoleFormatPattern = consoleFormatPattern;
}

public String getConsoleFormatPattern(){return consoleFormatPattern;}
public boolean isStreamLogging(){return streamLogging;}
public boolean isStreamLogging(){return globals.getSetting(Globals.STREAM_LOGGING,false);}
public boolean hasSkipStages(){return !skipStages.isEmpty();}
public List<Stage> getSkipStages(){return skipStages;}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,6 @@ public class RunConfigBuilder {
private Globals globals;
private List<String> errors;
private List<Stage> skipStages;
private boolean streamLogging = false;
private String consoleFormatPattern;
private boolean isValid = false;

Expand Down Expand Up @@ -133,10 +132,12 @@ public void addSkipStage(Stage stage){
}
}
public void setStreamLogging(Boolean streamLogging){
this.streamLogging = streamLogging;
if(streamLogging) {
this.globals.addSetting(Globals.STREAM_LOGGING, streamLogging);
}
}
public boolean isStreamLogging(){
return streamLogging;
return globals.getSetting(Globals.STREAM_LOGGING,false);
}
public int errorCount() {
return errors.size();
Expand Down Expand Up @@ -655,7 +656,6 @@ public RunConfig buildConfig(Parser yamlParser) {
getTracePatterns(),
skipStages,
globals,
streamLogging,
consoleFormatPattern
);
if(yamlParser.isAbortOnExitCode()){
Expand Down
28 changes: 28 additions & 0 deletions qDup/src/test/java/io/hyperfoil/tools/qdup/cli/QDupTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -198,6 +198,34 @@ public void main_exit_sh_ignore(QuarkusMainLauncher launcher) throws IOException
LaunchResult result = launcher.launch("--ignore-exit-code", "--fullPath","/tmp","--identity",getIdentity(),configPath.toString());
assertEquals(0,result.exitCode());
}
@Test
public void stream_logging(QuarkusMainLauncher launcher) throws IOException {
Path configPath = Files.writeString(File.createTempFile("qdup",".yaml").toPath(),
"""
scripts:
doit:
- sh: echo -e "one\\ntwo\\nthree"
hosts:
target: HOST_TARGET
roles:
test:
hosts:
- target
run-scripts:
- doit
""".replaceAll("HOST_TARGET",getHost().toString()));
configPath.toFile().deleteOnExit();
LaunchResult result = launcher.launch("--stream-logging", "--fullPath","/tmp","--identity",getIdentity(),configPath.toString());
assertEquals(0,result.exitCode());
File runLog = new File("/tmp/run.log");
assertTrue(runLog.exists());
String content = Files.readString(runLog.toPath());

assertTrue(content.contains("] one"),"expending one with log prefix:\n"+content);
assertTrue(content.contains("] two"),"expending two with log prefix:\n"+content);
assertTrue(content.contains("] three"),"expending three with log prefix:\n"+content);

}

@Test
public void main_exit_invalid_yaml(QuarkusMainLauncher launcher) throws IOException {
Expand Down
Loading