public async Task SyncSignal_StringResultError() { // Verify that async signals must return a Task. [ISyncSignalNotTask] // defines its signal as returning a string. Registration should fail. var worker = await client.NewWorkerAsync(); await Assert.ThrowsAsync <WorkflowTypeException>(async() => await worker.RegisterWorkflowAsync <SyncSignalString>()); // Verify that we're not allowd to create a workflow stub either. Assert.Throws <WorkflowTypeException>(() => client.NewWorkflowStub <SyncSignalString>()); }
public Test_Replay(TemporalFixture fixture) { TestHelper.ResetDocker(this.GetType()); var settings = new TemporalSettings() { Namespace = TemporalFixture.Namespace, ProxyLogLevel = TemporalTestHelper.ProxyLogLevel, CreateNamespace = true, Debug = TemporalTestHelper.Debug, DebugPrelaunched = TemporalTestHelper.DebugPrelaunched, DebugDisableHeartbeats = TemporalTestHelper.DebugDisableHeartbeats, ClientIdentity = TemporalTestHelper.ClientIdentity, TaskQueue = TemporalTestHelper.TaskQueue }; if (fixture.Start(settings, composeFile: TemporalTestHelper.TemporalStackDefinition, reconnect: true, keepRunning: TemporalTestHelper.KeepTemporalServerOpen) == TestFixtureStatus.Started) { this.fixture = fixture; this.client = fixture.Client; // Create a worker and register the workflow and activity // implementations to let Temporal know we're open for business. var worker = client.NewWorkerAsync().Result; worker.RegisterAssemblyAsync(Assembly.GetExecutingAssembly()).WaitWithoutAggregate(); worker.StartAsync().WaitWithoutAggregate(); } else { this.fixture = fixture; this.client = fixture.Client; } }
public Test_EndToEnd(TemporalFixture fixture, ITestOutputHelper outputHelper) { TestHelper.ResetDocker(this.GetType()); testWriter = new TestOutputWriter(outputHelper); // Configure a service for activity dependency injection testing if it doesn't // already exist. if (NeonHelper.ServiceContainer.GetService <ActivityDependency>() == null) { NeonHelper.ServiceContainer.AddSingleton(typeof(ActivityDependency), new ActivityDependency() { Hello = "World!" }); } // Initialize the Cadence fixture. var settings = new TemporalSettings() { Namespace = TemporalFixture.Namespace, ProxyLogLevel = TemporalTestHelper.ProxyLogLevel, CreateNamespace = true, Debug = TemporalTestHelper.Debug, DebugPrelaunched = TemporalTestHelper.DebugPrelaunched, DebugDisableHeartbeats = TemporalTestHelper.DebugDisableHeartbeats, ClientIdentity = TemporalTestHelper.ClientIdentity, TaskQueue = TemporalTestHelper.TaskQueue }; if (fixture.Start(settings, composeFile: TemporalTestHelper.TemporalStackDefinition, reconnect: true, keepRunning: TemporalTestHelper.KeepTemporalServerOpen) == TestFixtureStatus.Started) { this.fixture = fixture; this.client = fixture.Client; // Create a worker and register the workflow and activity // implementations to let Temporal know we're open for business. var worker = client.NewWorkerAsync().Result; worker.RegisterAssemblyAsync(Assembly.GetExecutingAssembly()).WaitWithoutAggregate(); worker.StartAsync().WaitWithoutAggregate(); } else { this.fixture = fixture; this.client = fixture.Client; } }
public TemporalTests(TemporalFixture fixture) { TestHelper.ResetDocker(this.GetType()); var settings = new TemporalSettings() { Namespace = "test-domain", TaskQueue = "test-tasks", ProxyLogLevel = LogLevel.Info, CreateNamespace = true // <-- this ensures that the default namespace exists }; // This starts/restarts the [nforgeio/temporal-dev] container for the first test // run in this class. Subsequent tests run from the class will use the existing // container instance, saving time by not having to wait for Temporal and Cassandra // to spin up and be ready for business. // // The [keepOpen=true] parameter tells the fixture to let the container continue running // after all of the tests have completed. This is useful for examining workflow histories // via the Temporal UX after the tests have completed. You can view the Temporal portal at // // http://localhost:8088 // // You can pass [keepOpen=false] to have the fixture remove the container after the // test run if you wish. if (fixture.Start(settings, reconnect: true, keepRunning: true) == TestFixtureStatus.Started) { this.fixture = fixture; this.client = fixture.Client; // Create a worker and register the workflow and activity // implementations to let Temporal know we're open for business. var worker = client.NewWorkerAsync().Result; worker.RegisterAssemblyAsync(Assembly.GetExecutingAssembly()).WaitWithoutAggregate(); worker.StartAsync().WaitWithoutAggregate(); } else { this.fixture = fixture; this.client = fixture.Client; } }
public async Task Multiple_TaskQueues() { await SyncContext.Clear; // Test the scenario where there multiple clients without // workers that will be used to simulate apps that make calls // on workflows and then create multiple clients that register // different workflows and activities and then verify that // each of the workerless clients are able to execute workflows // and activities and that these end up being executed on the // correct clients. var clients = new List <TemporalClient>(); try { // Initialize the non-worker clients. TemporalClient client1; TemporalClient client2; TemporalClient client3; TemporalSettings settings1 = fixture.Settings.Clone(); TemporalSettings settings2 = fixture.Settings.Clone(); TemporalSettings settings3 = fixture.Settings.Clone(); settings1.TaskQueue = "taskqueue-1"; settings2.TaskQueue = "taskqueue-2"; settings3.TaskQueue = "taskqueue-3"; clients.Add(client1 = await TemporalClient.ConnectAsync(fixture.Settings)); clients.Add(client2 = await TemporalClient.ConnectAsync(fixture.Settings)); clients.Add(client3 = await TemporalClient.ConnectAsync(fixture.Settings)); // Initialize the worker clients. clients.Add(workerClient1 = await TemporalClient.ConnectAsync(settings1)); clients.Add(workerClient2 = await TemporalClient.ConnectAsync(settings2)); clients.Add(workerClient3 = await TemporalClient.ConnectAsync(settings3)); // Initialize and start the workers. var worker1 = await workerClient1.NewWorkerAsync(); await worker1.RegisterActivityAsync <ActivityWorker1>(); await worker1.RegisterWorkflowAsync <WorkflowWorker1>(); await worker1.StartAsync(); var worker2 = await workerClient2.NewWorkerAsync(); await worker2.RegisterActivityAsync <ActivityWorker2>(); await worker2.RegisterWorkflowAsync <WorkflowWorker2>(); await worker2.StartAsync(); var worker3 = await workerClient3.NewWorkerAsync(); await worker3.RegisterActivityAsync <ActivityWorker3>(); await worker3.RegisterWorkflowAsync <WorkflowWorker3>(); await worker3.StartAsync(); // Execute each of the worker workflows WITHOUT the associated activities // from each client (both the worker and non-worker clients). foreach (var client in clients) { var stub = client.NewWorkflowStub <IWorkflowWorker1>(); Assert.True(await stub.RunAsync(testActivity: false)); } foreach (var client in clients) { var stub = client.NewWorkflowStub <IWorkflowWorker2>(); Assert.True(await stub.RunAsync(testActivity: false)); } foreach (var client in clients) { var stub = client.NewWorkflowStub <IWorkflowWorker3>(); Assert.True(await stub.RunAsync(testActivity: false)); } // Re-run the workflows calling the activities this time. foreach (var client in clients) { var stub = client.NewWorkflowStub <IWorkflowWorker1>(); Assert.True(await stub.RunAsync(testActivity: true)); } foreach (var client in clients) { var stub = client.NewWorkflowStub <IWorkflowWorker2>(); Assert.True(await stub.RunAsync(testActivity: true)); } foreach (var client in clients) { var stub = client.NewWorkflowStub <IWorkflowWorker3>(); Assert.True(await stub.RunAsync(testActivity: true)); } } finally { foreach (var client in clients) { client.Dispose(); } workerClient1 = null; workerClient2 = null; workerClient3 = null; } }