Skip to content

Commit

Permalink
Disabled stickyness by default until needed service change is released (
Browse files Browse the repository at this point in the history
#221)

* Fixed deduping of metric and logging test
  • Loading branch information
mfateev authored Oct 23, 2018
1 parent 50700e7 commit 44296d2
Show file tree
Hide file tree
Showing 5 changed files with 14 additions and 37 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,6 @@
import com.uber.cadence.workflow.WorkflowInfo;
import com.uber.cadence.workflow.WorkflowInterceptor;
import com.uber.cadence.workflow.WorkflowMethod;
import com.uber.m3.tally.Scope;
import java.lang.reflect.InvocationTargetException;
import java.lang.reflect.Method;
import java.util.Collections;
Expand Down Expand Up @@ -67,19 +66,16 @@ final class POJOWorkflowImplementationFactory implements ReplayWorkflowFactory {
Collections.synchronizedMap(new HashMap<>());

private final ExecutorService threadPool;
private final Scope metricsScope;
private DeciderCache cache;

POJOWorkflowImplementationFactory(
DataConverter dataConverter,
ExecutorService threadPool,
Function<WorkflowInterceptor, WorkflowInterceptor> interceptorFactory,
Scope metricsScope,
DeciderCache cache) {
this.dataConverter = Objects.requireNonNull(dataConverter);
this.threadPool = Objects.requireNonNull(threadPool);
this.interceptorFactory = Objects.requireNonNull(interceptorFactory);
this.metricsScope = metricsScope;
this.cache = cache;
}

Expand Down Expand Up @@ -320,7 +316,7 @@ void logSerializationException(
+ eventId
+ ". Dropping it.",
exception);
metricsScope.counter(MetricsType.CORRUPTED_SIGNALS_COUNTER).inc(1);
Workflow.getMetricsScope().counter(MetricsType.CORRUPTED_SIGNALS_COUNTER).inc(1);
}

static WorkflowExecutionException mapToWorkflowExecutionException(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -58,11 +58,7 @@ public SyncWorkflowWorker(

factory =
new POJOWorkflowImplementationFactory(
options.getDataConverter(),
workflowThreadPool,
interceptorFactory,
this.options.getMetricsScope(),
cache);
options.getDataConverter(), workflowThreadPool, interceptorFactory, cache);

DecisionTaskHandler taskHandler =
new ReplayDecisionTaskHandler(
Expand Down
3 changes: 2 additions & 1 deletion src/main/java/com/uber/cadence/worker/Worker.java
Original file line number Diff line number Diff line change
Expand Up @@ -595,7 +595,8 @@ enum State {

public static class FactoryOptions {
public static class Builder {
private boolean disableStickyExecution;
// TODO: Enable by default as soon the service is released
private boolean disableStickyExecution = true;
private int stickyDecisionScheduleToStartTimeoutInSeconds = 5;
private int cacheMaximumSize = 600;
private int maxWorkflowThreadCount = 600;
Expand Down
5 changes: 3 additions & 2 deletions src/test/java/com/uber/cadence/worker/StickyWorkerTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -57,15 +57,16 @@
import java.util.Queue;
import java.util.Random;
import org.junit.Assert;
import org.junit.Ignore;
import org.junit.Rule;
import org.junit.Test;
import org.junit.rules.TestName;
import org.junit.runner.RunWith;
import org.junit.runners.Parameterized;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

@RunWith(Parameterized.class)
// @RunWith(Parameterized.class)
@Ignore
public class StickyWorkerTest {
public static final String DOMAIN = "UnitTest";

Expand Down
31 changes: 7 additions & 24 deletions src/test/java/com/uber/cadence/workflow/LoggerTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -30,17 +30,11 @@
import com.uber.cadence.testing.TestWorkflowEnvironment;
import com.uber.cadence.worker.Worker;
import java.time.Duration;
import java.util.Arrays;
import java.util.Collection;
import java.util.UUID;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.junit.runners.Parameterized;
import org.junit.runners.Parameterized.Parameter;
import org.junit.runners.Parameterized.Parameters;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

@RunWith(Parameterized.class)
public class LoggerTest {

private static final ListAppender<ILoggingEvent> listAppender = new ListAppender<>();
Expand All @@ -54,29 +48,15 @@ public class LoggerTest {
}

private static final String taskList = "logger-test";
private static final Logger workflowLogger = Workflow.getLogger(TestLoggingInWorkflow.class);
private static final Logger childWorkflowLogger =
Workflow.getLogger(TestLoggerInChildWorkflow.class);

@Parameters
public static Collection<Object[]> data() {
return Arrays.asList(new Object[][] {{false, "wf-1", 1}, {true, "wf-2", 3}});
}

@Parameter public boolean loggingEnabledInReplay;

@Parameter(1)
public String wfID;

@Parameter(2)
public int startLinesExpected;

public interface TestWorkflow {
@WorkflowMethod
void execute(String id);
}

public static class TestLoggingInWorkflow implements LoggerTest.TestWorkflow {
private final Logger workflowLogger = Workflow.getLogger(TestLoggingInWorkflow.class);

@Override
public void execute(String id) {
workflowLogger.info("Start executing workflow {}.", id);
Expand All @@ -95,6 +75,8 @@ public interface TestChildWorkflow {
}

public static class TestLoggerInChildWorkflow implements LoggerTest.TestChildWorkflow {
private static final Logger childWorkflowLogger =
Workflow.getLogger(TestLoggerInChildWorkflow.class);

@Override
public void executeChild(String id) {
Expand All @@ -107,7 +89,7 @@ public void testWorkflowLogger() {
TestEnvironmentOptions testOptions =
new TestEnvironmentOptions.Builder()
.setDomain(WorkflowTest.DOMAIN)
.setEnableLoggingInReplay(loggingEnabledInReplay)
.setEnableLoggingInReplay(false)
.build();
TestWorkflowEnvironment env = TestWorkflowEnvironment.newInstance(testOptions);
Worker worker = env.newWorker(taskList);
Expand All @@ -123,6 +105,7 @@ public void testWorkflowLogger() {
.build();
LoggerTest.TestWorkflow workflow =
workflowClient.newWorkflowStub(LoggerTest.TestWorkflow.class, options);
String wfID = UUID.randomUUID().toString();
workflow.execute(wfID);

assertEquals(1, matchingLines(String.format("Start executing workflow %s.", wfID)));
Expand Down

0 comments on commit 44296d2

Please sign in to comment.