Skip to content

Commit c296903

Browse files
Copilotdevstress
andcommitted
Optimize workflow tests: Add configurable delays like JobGateway pattern
Co-authored-by: devstress <30769729+devstress@users.noreply.github.com>
1 parent fe2db39 commit c296903

3 files changed

Lines changed: 43 additions & 2 deletions

File tree

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
// Licensed to the Apache Software Foundation (ASF) under one
2+
// or more contributor license agreements. See the NOTICE file
3+
// distributed with this work for additional information
4+
// regarding copyright ownership. The ASF licenses this file
5+
// to you under the Apache License, Version 2.0 (the
6+
// "License"); you may not use this file except in compliance
7+
// with the License. You may obtain a copy of the License at
8+
//
9+
// http://www.apache.org/licenses/LICENSE-2.0
10+
//
11+
// Unless required by applicable law or agreed to in writing, software
12+
// distributed under the License is distributed on an "AS IS" BASIS,
13+
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14+
// See the License for the specific language governing permissions and
15+
// limitations under the License.
16+
17+
using FlinkDotNet.JobManager.Workflows;
18+
19+
namespace FlinkDotNet.JobManager.Tests.Workflows;
20+
21+
/// <summary>
22+
/// Base class for FlinkJobWorkflow tests providing common setup for fast test execution.
23+
/// Optimizes workflow delays to 1ms for rapid test execution (following JobGateway pattern).
24+
/// </summary>
25+
public abstract class FlinkJobWorkflowTestBase
26+
{
27+
public FlinkJobWorkflowTestBase()
28+
{
29+
// Set workflow delays to 1ms for fast test execution
30+
// This reduces test execution time from 5+ seconds per test to ~100ms
31+
// Following the same optimization pattern as JobGateway tests
32+
FlinkJobWorkflow.TaskMonitoringDelay = TimeSpan.FromMilliseconds(1);
33+
}
34+
}

‎FlinkDotNet/FlinkDotNet.JobManager.Tests/Workflows/FlinkJobWorkflowTests.cs‎

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,8 +25,9 @@ namespace FlinkDotNet.JobManager.Tests.Workflows;
2525
/// <summary>
2626
/// Tests for FlinkJobWorkflow - Temporal workflow orchestration
2727
/// Phase 4: Temporal Integration - TDD Tests
28+
/// Optimized for fast execution (1ms delays instead of 5s)
2829
/// </summary>
29-
public class FlinkJobWorkflowTests
30+
public class FlinkJobWorkflowTests : FlinkJobWorkflowTestBase
3031
{
3132
[Fact]
3233
public async Task ExecuteJobAsync_SimpleJobGraph_CompletesSuccessfully()

‎FlinkDotNet/FlinkDotNet.JobManager/Workflows/FlinkJobWorkflow.cs‎

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,11 @@ namespace FlinkDotNet.JobManager.Workflows;
2828
[Workflow]
2929
public class FlinkJobWorkflow
3030
{
31+
/// <summary>
32+
/// Configurable delay for task execution monitoring (can be overridden in tests for fast execution)
33+
/// </summary>
34+
public static TimeSpan TaskMonitoringDelay { get; set; } = TimeSpan.FromSeconds(5);
35+
3136
private JobExecutionState _currentState = JobExecutionState.Created;
3237
private List<string> _deployedTasks = new();
3338
private Dictionary<string, ExecutionState> _taskStates = new();
@@ -216,7 +221,8 @@ private async Task MonitorTaskExecutionAsync(string jobId)
216221

217222
// Wait for all tasks to complete or fail
218223
// In production, this would be event-driven based on activity completion
219-
await Workflow.DelayAsync(TimeSpan.FromSeconds(5));
224+
// Use configurable delay to allow fast test execution (1ms in tests, 5s in production)
225+
await Workflow.DelayAsync(TaskMonitoringDelay);
220226

221227
// Update task states based on job state
222228
foreach (string taskId in this._deployedTasks)

0 commit comments

Comments
 (0)