Skip to content

Commit b25f52a

Browse files
authored
Fixing Flakey FunctionDispatcherTest (#4497)
1 parent f0f13a1 commit b25f52a

File tree

1 file changed

+16
-16
lines changed

1 file changed

+16
-16
lines changed

test/WebJobs.Script.Tests/Rpc/FunctionDispatcherTests.cs

Lines changed: 16 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,7 @@ public async void Starting_MultipleJobhostChannels_Succeeds()
5656
await functionDispatcher.InitializeAsync(GetTestFunctionsList(LanguageWorkerConstants.NodeLanguageWorkerName));
5757

5858
var finalChannelCount = await WaitForJobhostWorkerChannelsToStartup(functionDispatcher, expectedProcessCount);
59-
Assert.Equal(finalChannelCount, expectedProcessCount);
59+
Assert.Equal(expectedProcessCount, finalChannelCount);
6060

6161
// Verify LanguageWorkerChannelState when channel after it is initialized
6262
Assert.True(functionDispatcher.WorkerState.GetChannels().All(ch => ch.State == LanguageWorkerChannelState.Initialized));
@@ -70,46 +70,46 @@ public async void Starting_MultipleWebhostChannels_Succeeds()
7070
await functionDispatcher.InitializeAsync(GetTestFunctionsList(LanguageWorkerConstants.JavaLanguageWorkerName));
7171

7272
var finalWebhostChannelCount = await WaitForWebhostWorkerChannelsToStartup(functionDispatcher.ChannelManager, expectedProcessCount, "java");
73-
Assert.Equal(finalWebhostChannelCount, expectedProcessCount);
73+
Assert.Equal(expectedProcessCount, finalWebhostChannelCount);
7474

7575
var finalJobhostChannelCount = functionDispatcher.WorkerState.GetChannels().Count();
76-
Assert.Equal(finalJobhostChannelCount, 0);
76+
Assert.Equal(0, finalJobhostChannelCount);
7777
}
7878

7979
[Fact]
8080
public void MaxProcessCount_Returns_Default()
8181
{
8282
FunctionDispatcher functionDispatcher = (FunctionDispatcher)GetTestFunctionDispatcher();
83-
Assert.Equal(functionDispatcher.MaxProcessCount, 1);
83+
Assert.Equal(1, functionDispatcher.MaxProcessCount);
8484

8585
functionDispatcher = (FunctionDispatcher)GetTestFunctionDispatcher("0");
86-
Assert.Equal(functionDispatcher.MaxProcessCount, 1);
86+
Assert.Equal(1, functionDispatcher.MaxProcessCount);
8787

8888
functionDispatcher = (FunctionDispatcher)GetTestFunctionDispatcher("-1");
89-
Assert.Equal(functionDispatcher.MaxProcessCount, 1);
89+
Assert.Equal(1, functionDispatcher.MaxProcessCount);
9090
}
9191

9292
[Fact]
9393
public void MaxProcessCount_ProcessCount_Set_Returns_ExpectedCount()
9494
{
9595
int expectedProcessCount = 3;
9696
FunctionDispatcher functionDispatcher = (FunctionDispatcher)GetTestFunctionDispatcher(expectedProcessCount.ToString());
97-
Assert.Equal(functionDispatcher.MaxProcessCount, expectedProcessCount);
97+
Assert.Equal(expectedProcessCount, functionDispatcher.MaxProcessCount);
9898
}
9999

100100
[Fact]
101101
public void MaxProcessCount_ProcessCount_Set_ExceedsMax_Returns_ExpectedCount()
102102
{
103103
int expectedProcessCount = 30;
104104
FunctionDispatcher functionDispatcher = (FunctionDispatcher)GetTestFunctionDispatcher(expectedProcessCount.ToString());
105-
Assert.Equal(functionDispatcher.MaxProcessCount, 10);
105+
Assert.Equal(10, functionDispatcher.MaxProcessCount);
106106
}
107107

108108
[Fact]
109109
public async void FunctionDispatcherState_Default_DotNetFunctions()
110110
{
111111
FunctionDispatcher functionDispatcher = (FunctionDispatcher)GetTestFunctionDispatcher();
112-
Assert.Equal(functionDispatcher.State, FunctionDispatcherState.Default);
112+
Assert.Equal(FunctionDispatcherState.Default, functionDispatcher.State);
113113
FunctionMetadata func1 = new FunctionMetadata()
114114
{
115115
Name = "func1",
@@ -120,20 +120,20 @@ public async void FunctionDispatcherState_Default_DotNetFunctions()
120120
func1
121121
};
122122
await functionDispatcher.InitializeAsync(functions);
123-
Assert.Equal(functionDispatcher.State, FunctionDispatcherState.Default);
123+
Assert.Equal(FunctionDispatcherState.Default, functionDispatcher.State);
124124

125125
await functionDispatcher.InitializeAsync(functions);
126-
Assert.Equal(functionDispatcher.State, FunctionDispatcherState.Default);
126+
Assert.Equal(FunctionDispatcherState.Default, functionDispatcher.State);
127127

128128
await functionDispatcher.InitializeAsync(functions);
129-
Assert.Equal(functionDispatcher.State, FunctionDispatcherState.Default);
129+
Assert.Equal(FunctionDispatcherState.Default, functionDispatcher.State);
130130
}
131131

132132
[Fact]
133133
public async void FunctionDispatcherState_Default_NoFunctions()
134134
{
135135
FunctionDispatcher functionDispatcher = (FunctionDispatcher)GetTestFunctionDispatcher();
136-
Assert.Equal(functionDispatcher.State, FunctionDispatcherState.Default);
136+
Assert.Equal(FunctionDispatcherState.Default, functionDispatcher.State);
137137
await functionDispatcher.InitializeAsync(new List<FunctionMetadata>());
138138
}
139139

@@ -142,7 +142,7 @@ public async void ShutdownChannels_NoFunctions()
142142
{
143143
var mockLanguageWorkerChannelManager = new Mock<ILanguageWorkerChannelManager>();
144144
FunctionDispatcher functionDispatcher = (FunctionDispatcher)GetTestFunctionDispatcher(mockLanguageWorkerChannelManager: mockLanguageWorkerChannelManager);
145-
Assert.Equal(functionDispatcher.State, FunctionDispatcherState.Default);
145+
Assert.Equal(FunctionDispatcherState.Default, functionDispatcher.State);
146146
await functionDispatcher.InitializeAsync(new List<FunctionMetadata>());
147147
// Wait longer than debouce action.
148148
await Task.Delay(6000);
@@ -163,7 +163,7 @@ public async void ShutdownChannels_DotNetFunctions()
163163
};
164164
var mockLanguageWorkerChannelManager = new Mock<ILanguageWorkerChannelManager>();
165165
FunctionDispatcher functionDispatcher = (FunctionDispatcher)GetTestFunctionDispatcher(mockLanguageWorkerChannelManager: mockLanguageWorkerChannelManager);
166-
Assert.Equal(functionDispatcher.State, FunctionDispatcherState.Default);
166+
Assert.Equal(FunctionDispatcherState.Default, functionDispatcher.State);
167167
await functionDispatcher.InitializeAsync(functions);
168168
// Wait longer than debouce action.
169169
await Task.Delay(6000);
@@ -184,7 +184,7 @@ public async void FunctionDispatcherState_Transitions_From_Starting_To_Initializ
184184
func1
185185
};
186186
await functionDispatcher.InitializeAsync(functions);
187-
Assert.Equal(functionDispatcher.State, FunctionDispatcherState.Initializing);
187+
Assert.True(functionDispatcher.State == FunctionDispatcherState.Initializing || functionDispatcher.State == FunctionDispatcherState.Initialized);
188188
await WaitForFunctionDispactherStateInitialized(functionDispatcher);
189189
}
190190

0 commit comments

Comments
 (0)