Skip to content

Commit e67771a

Browse files
committed
flaky fix, cleanup
1 parent 5b4601f commit e67771a

File tree

6 files changed

+20
-33
lines changed

6 files changed

+20
-33
lines changed

test/Resources/TestScripts/Node/CosmosDBInMultiple/function.json

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -15,11 +15,12 @@
1515
"sqlQuery": "SELECT * from c where c.text = {id}"
1616
},
1717
{
18-
"type": "blob",
19-
"name": "blob",
20-
"connection": "AzureWebJobsStorage",
18+
"type": "cosmosDB",
19+
"name": "itemOut",
2120
"direction": "out",
22-
"path": "test-output-node/cosmosdbin-multiple-e2e-completed"
21+
"databaseName": "ItemDb",
22+
"containerName": "ItemCollection",
23+
"createIfNotExists": true
2324
}
2425
]
2526
}

test/Resources/TestScripts/Node/CosmosDBInMultiple/index.js

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,10 @@ module.exports = function (context, input) {
66
throw Error("Expected 2 documents. Found " + context.bindings.items.length);
77
}
88

9-
context.bindings.blob = input.id;
9+
context.bindings.itemOut = {
10+
id: input.id,
11+
text: "Hello from Node with multiple input bindings!"
12+
};
1013

1114
context.done();
1215
}

test/WebJobs.Script.Tests.Integration/CosmosDB/CosmosDBEndToEndTestsBase.cs

Lines changed: 7 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -36,8 +36,11 @@ await Fixture.CosmosClient.GetContainer("ItemDb", "ItemCollection")
3636
string result = await TestHelpers.WaitForBlobAndGetStringAsync(resultBlob,
3737
() => string.Join(Environment.NewLine, Fixture.Host.GetScriptHostLogMessages()));
3838

39-
// cleanup collections
40-
await Fixture.DeleteContainers();
39+
if (collectionsCreated)
40+
{
41+
// cleanup collections
42+
await Fixture.DeleteContainers();
43+
}
4144

4245
Assert.False(string.IsNullOrEmpty(result));
4346
}
@@ -62,9 +65,6 @@ protected async Task CosmosDBTest()
6265

6366
Assert.Equal(updatedDoc.id, doc.id);
6467
Assert.NotEqual(doc._etag, updatedDoc._etag);
65-
66-
// cleanup collections
67-
await Fixture.DeleteContainers();
6868
}
6969

7070
protected async Task CosmosDBMultipleItemsTest()
@@ -84,14 +84,8 @@ protected async Task CosmosDBMultipleItemsTest()
8484
string messageContent = string.Format("{{ \"id\": \"{0}\" }}", id);
8585
await queue.AddMessageAsync(new CloudQueueMessage(messageContent));
8686

87-
// now wait for function to be invoked
88-
string result = await TestHelpers.WaitForBlobAndGetStringAsync(resultBlob,
89-
() => string.Join(Environment.NewLine, Fixture.Host.GetScriptHostLogMessages()));
90-
91-
// cleanup collections
92-
await Fixture.DeleteContainers();
93-
94-
Assert.False(string.IsNullOrEmpty(result));
87+
// And wait for the text to be updated
88+
dynamic updatedDoc = await WaitForItemAsync(id, "Hello from Node with multiple input bindings!");
9589
}
9690

9791
protected async Task TestConnectToEmulator()

test/WebJobs.Script.Tests.Integration/CosmosDB/CosmosDBEndtoEndTestFixture.cs

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,12 @@
11
// Copyright (c) .NET Foundation. All rights reserved.
22
// Licensed under the MIT License. See License.txt in the project root for license information.
33

4+
using System.Diagnostics.CodeAnalysis;
5+
using System.Threading.Tasks;
46
using Microsoft.Azure.Cosmos;
57
using Microsoft.Azure.WebJobs.Script.Models;
68
using Microsoft.Extensions.Configuration;
79
using Microsoft.Extensions.DependencyInjection;
8-
using System.Collections.Generic;
9-
using System.Diagnostics.CodeAnalysis;
10-
using System.Threading.Tasks;
1110

1211
namespace Microsoft.Azure.WebJobs.Script.Tests.CosmosDB
1312
{

test/WebJobs.Script.Tests.Integration/CosmosDB/CosmosDBNodeEndToEndTests.cs

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,12 @@
11
// Copyright (c) .NET Foundation. All rights reserved.
22
// Licensed under the MIT License. See License.txt in the project root for license information.
33

4-
using Microsoft.Azure.WebJobs.Script.Workers.Rpc;
54
using System.Threading.Tasks;
5+
using Microsoft.Azure.WebJobs.Script.Workers.Rpc;
66
using Xunit;
77

8-
// Add this outside the namespace or at the top of the file
9-
[CollectionDefinition("CosmosDBNodeEndToEndTests", DisableParallelization = true)]
10-
public class CosmosDBNodeEndToEndTestsCollection { }
11-
128
namespace Microsoft.Azure.WebJobs.Script.Tests.CosmosDB
139
{
14-
[Collection("CosmosDBNodeEndToEndTests")]
1510
public class CosmosDBNodeEndToEndTests :
1611
CosmosDBEndToEndTestsBase<CosmosDBNodeEndToEndTests.TestFixture>
1712
{

test/WebJobs.Script.Tests.Integration/WebHostEndToEnd/EndToEndTestFixture.cs

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -44,9 +44,6 @@ public abstract class EndToEndTestFixture : IAsyncLifetime
4444
private string _functionsWorkerRuntimeVersion;
4545
private bool _addTestSettings;
4646

47-
[SuppressMessage("Microsoft.Security", "CS002:SecretInNextLine", Justification = "Well known account key for emulator. Used for testing.")]
48-
private string CosmosDBConnectionString = "AccountEndpoint=https://localhost:8081/;AccountKey=C2y6yDjf5/R+ob0N8A7Cgv30VRDJIWEHLM+4QDU5DE2nQ9nDuVTqobD4b8mGGyPMbIZnqyMsEcaGQy67XIw/Jw==";
49-
5047
protected EndToEndTestFixture(
5148
string rootPath,
5249
string testId,
@@ -170,8 +167,7 @@ string GetDestPath(int counter)
170167
configBuilder.AddInMemoryCollection(new Dictionary<string, string>
171168
{
172169
{ "AzureWebJobsStorage", azuriteConnectionString },
173-
{ "ConnectionStrings:AzureWebJobsStorage", azuriteConnectionString },
174-
{ "ConnectionStrings:CosmosDB", CosmosDBConnectionString}
170+
{ "ConnectionStrings:AzureWebJobsStorage", azuriteConnectionString }
175171
});
176172

177173
ConfigureScriptHost(configBuilder);
@@ -182,7 +178,6 @@ string GetDestPath(int counter)
182178

183179
// Flow this env variable to out of proc workers.
184180
s.Configure<FunctionsHostingConfigOptions>(o => o.Features["AzureWebJobsStorage"] = azuriteConnectionString);
185-
s.Configure<FunctionsHostingConfigOptions>(o => o.Features["ConnectionStrings:CosmosDB"] = CosmosDBConnectionString);
186181
ConfigureWebHost(s);
187182
},
188183
configureWebHostAppConfiguration: configBuilder =>

0 commit comments

Comments
 (0)