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 @@ -71,8 +71,13 @@ public Object postProcessAfterInitialization(@Nonnull Object bean, @Nonnull Stri
// optional dependencies.
metricsScope = findBean("temporalMetricsScope", Scope.class);
tracer = findBean(Tracer.class);
testWorkflowEnvironment =
findBean("temporalTestWorkflowEnvironment", TestWorkflowEnvironmentAdapter.class);
// Prefer resolving by type; fall back to the correctly named adapter bean
testWorkflowEnvironment = findBean(TestWorkflowEnvironmentAdapter.class);
if (testWorkflowEnvironment == null) {
testWorkflowEnvironment =
findBean(
"temporalTestWorkflowEnvironmentAdapter", TestWorkflowEnvironmentAdapter.class);
}
namespaceProperties.forEach(this::injectBeanByNonRootNamespace);
}
}
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,63 @@
package io.temporal.spring.boot.autoconfigure;

import static org.junit.jupiter.api.Assertions.assertEquals;

import io.grpc.health.v1.HealthCheckResponse;
import io.temporal.serviceclient.WorkflowServiceStubs;
import io.temporal.testing.TestWorkflowEnvironment;
import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Test;
import org.junit.jupiter.api.TestInstance;
import org.junit.jupiter.api.Timeout;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Qualifier;
import org.springframework.boot.test.context.SpringBootTest;
import org.springframework.context.ConfigurableApplicationContext;
import org.springframework.context.annotation.ComponentScan;
import org.springframework.context.annotation.FilterType;

@SpringBootTest(
classes = NonRootNamespacesUseTestServerTest.Configuration.class,
properties = {
"spring.temporal.test-server.enabled=true",
"spring.temporal.connection.target=127.0.0.1:7233",
"spring.temporal.start-workers=false",
"spring.temporal.namespaces[0].namespace=pomegranate",
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why "pomegranate"?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Lol, the min reproducible sample used it and I thought it was good ¯_(ツ)_/¯ happy to change it to something else

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah other tests used more boring names like namespace0. Not something we need to be consistent with.

"spring.temporal.namespaces[0].alias=pomegranate"
})
@TestInstance(TestInstance.Lifecycle.PER_CLASS)
public class NonRootNamespacesUseTestServerTest {

@Autowired ConfigurableApplicationContext applicationContext;

@Autowired
@Qualifier("temporalTestWorkflowEnvironment")
TestWorkflowEnvironment testWorkflowEnvironment;

@Autowired
@Qualifier("pomegranateWorkflowServiceStubs")
WorkflowServiceStubs pomegranateWorkflowServiceStubs;

@BeforeEach
void setUp() {
applicationContext.start();
}

@Test
@Timeout(10)
public void nonRootNamespaceUsesInMemoryTestServer() {
HealthCheckResponse envHealth =
testWorkflowEnvironment.getWorkflowClient().getWorkflowServiceStubs().healthCheck();
HealthCheckResponse pomegranateHealth = pomegranateWorkflowServiceStubs.healthCheck();
assertEquals(HealthCheckResponse.ServingStatus.SERVING, envHealth.getStatus());
assertEquals(HealthCheckResponse.ServingStatus.SERVING, pomegranateHealth.getStatus());
}

@ComponentScan(
excludeFilters =
@ComponentScan.Filter(
pattern =
"io\\.temporal\\.spring\\.boot\\.autoconfigure\\.(byworkername|bytaskqueue)\\..*",
type = FilterType.REGEX))
public static class Configuration {}
}
Loading