Skip to content

Commit

Permalink
Fix thee retryAnalyzer Annotations
Browse files Browse the repository at this point in the history
RetryAnalyzer is set to Class.class which masks the actual
Test failure errror.
Mask optional exit code from the LocalCliProcess. Presto when
query fails exits with 1, but there are tests to verify failure.
  • Loading branch information
Arunachalam Thirupathi committed Jul 1, 2022
1 parent 086f8fc commit 6dafab8
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -25,8 +25,10 @@
import net.bytebuddy.dynamic.loading.ClassLoadingStrategy;
import net.bytebuddy.implementation.MethodCall;
import org.slf4j.Logger;
import org.testng.IRetryAnalyzer;
import org.testng.annotations.CustomAttribute;
import org.testng.annotations.Test;
import org.testng.internal.annotations.DisabledRetryAnalyzer;

import java.lang.annotation.Annotation;
import java.lang.reflect.InvocationTargetException;
Expand Down Expand Up @@ -267,9 +269,9 @@ public boolean singleThreaded()
}

@Override
public Class retryAnalyzer()
public Class<? extends IRetryAnalyzer> retryAnalyzer()
{
return Class.class;
return DisabledRetryAnalyzer.class;
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,9 @@
import io.prestodb.tempto.internal.process.CliProcessBase;

import java.time.Duration;
import java.util.OptionalInt;

import static java.util.Objects.requireNonNull;
import static java.util.concurrent.TimeUnit.MILLISECONDS;

/**
Expand All @@ -26,11 +28,18 @@ public class LocalCliProcess
extends CliProcessBase
{
private final Process process;
private final OptionalInt expectedExitValue;

public LocalCliProcess(Process process)
public LocalCliProcess(Process process, OptionalInt expectedExitValue)
{
super(process.getInputStream(), process.getErrorStream(), process.getOutputStream());
this.process = process;
this.expectedExitValue = requireNonNull(expectedExitValue, "expectedExitValue is null");
}

public LocalCliProcess(Process process)
{
this(process, OptionalInt.empty());
}

@Override
Expand All @@ -43,7 +52,7 @@ public void waitForWithTimeoutAndKill(Duration timeout)
}

int exitValue = process.exitValue();
if (exitValue != 0) {
if (exitValue != 0 && exitValue != expectedExitValue.orElse(0)) {
throw new RuntimeException("Child process exited with non-zero code: " + exitValue);
}
}
Expand Down

0 comments on commit 6dafab8

Please sign in to comment.