Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Concurrency supported in Smoke Tests #7169

Merged
merged 27 commits into from
Aug 8, 2019
Merged
Show file tree
Hide file tree
Changes from 26 commits
Commits
Show all changes
27 commits
Select commit Hold shift + click to select a range
ba7d3af
.NET smoke Test Sample
JonathanCrd Jun 20, 2019
6dbfcbc
Env Variables names changed
JonathanCrd Jun 21, 2019
4ca3f03
Update .gitignore
JonathanCrd Jun 21, 2019
386a550
gitignore updated
JonathanCrd Jun 21, 2019
a6950ac
Exit Codes, PascalCase and refactoring of the static methods.
JonathanCrd Jun 24, 2019
87fdf60
Class names changed
JonathanCrd Jun 24, 2019
4717b64
Comments
JonathanCrd Jun 25, 2019
48a656b
Higher order functions
JonathanCrd Jun 25, 2019
b871ca1
Test classes refactured
JonathanCrd Jun 26, 2019
7139e22
Create CosmosDBTest.cs
JonathanCrd Jun 26, 2019
3fff119
Cosmos DB implementation
JonathanCrd Jun 26, 2019
fd1df4d
Update CosmosDBTest.cs
JonathanCrd Jun 26, 2019
57903ca
Update CosmosDBTest.cs
JonathanCrd Jun 26, 2019
ada1799
Unnecessary blank lines removed
JonathanCrd Jul 2, 2019
d3c294f
ExecuteTest typo
JonathanCrd Jul 2, 2019
620a7dc
Base class deleted
JonathanCrd Jul 9, 2019
30e472c
BlobTestSource.tst deleted
JonathanCrd Jul 10, 2019
6d90610
Static Classes
JonathanCrd Jul 10, 2019
c044000
Pair programming comments
JonathanCrd Jul 12, 2019
9906058
Merge branch 'master' into SmokeTest
JonathanCrd Aug 6, 2019
f465ee6
Concurrency support
JonathanCrd Aug 6, 2019
25c53e1
License headers added
JonathanCrd Aug 6, 2019
a3ff033
License header added
JonathanCrd Aug 6, 2019
31a2381
Adapted for concurrency
JonathanCrd Aug 6, 2019
930e5c7
Use of string interpolation
JonathanCrd Aug 8, 2019
a392636
Use of string interpolation
JonathanCrd Aug 8, 2019
3ea5be0
Update EventHubsTest.cs
JonathanCrd Aug 8, 2019
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
8 changes: 6 additions & 2 deletions samples/SmokeTest/SmokeTest/BlobStorageTest.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,8 @@
using Azure.Storage.Blobs;
// ------------------------------------
// Copyright(c) Microsoft Corporation.
// Licensed under the MIT License.
// ------------------------------------
using Azure.Storage.Blobs;
using System;
using System.IO;
using System.Runtime.CompilerServices;
Expand Down Expand Up @@ -27,7 +31,7 @@ public static async Task RunTests()

string connectionString = Environment.GetEnvironmentVariable("BLOB_CONNECTION_STRING");
string containerName = "mycontainer"; //The container must exists, this sample is not creating it.
string blobName = "netSmokeTestBlob";
string blobName = $"netSmokeTestBlob-{Guid.NewGuid()}.txt";
serviceClient = new BlobServiceClient(connectionString);
blobClient = serviceClient.GetBlobContainerClient(containerName).GetBlockBlobClient(blobName);

Expand Down
8 changes: 6 additions & 2 deletions samples/SmokeTest/SmokeTest/CosmosDBTest.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,8 @@
using Azure.Storage.Blobs.Models;
// ------------------------------------
// Copyright(c) Microsoft Corporation.
// Licensed under the MIT License.
// ------------------------------------
using Azure.Storage.Blobs.Models;
using Microsoft.Azure.Documents;
using Microsoft.Azure.Documents.Client;
using Newtonsoft.Json;
Expand Down Expand Up @@ -34,7 +38,7 @@ public class Moon
class CosmosDBTest
{
private static DocumentClient client;
private const string DataBaseName = "netSolarSystemDB";
private static string DataBaseName = $"netSolarSystemDB-{Guid.NewGuid()}";
private const string CollectionName = "PlanetsCollection";
private static List<Planet> planets = new List<Planet>();

Expand Down
29 changes: 7 additions & 22 deletions samples/SmokeTest/SmokeTest/EventHubsTest.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,8 @@
using Azure;
// ------------------------------------
// Copyright(c) Microsoft Corporation.
// Licensed under the MIT License.
// ------------------------------------
using Azure;
using Azure.Messaging.EventHubs;
using Microsoft.Azure.Amqp.Framing;
using System;
Expand Down Expand Up @@ -79,35 +83,16 @@ private static async Task SendAndReceiveEvents()
{
receivedEvents.AddRange(await receiver.ReceiveAsync(eventBatch.Length + 10, TimeSpan.FromMilliseconds(25)));
}
index = 0;

//Check if at least one event was received in order to start validation
if (receivedEvents.Count == 0)
{
throw new Exception(String.Format("Error, No events received."));
}
Console.Write(receivedEvents.Count() + " events received.\n");

Console.WriteLine("Beginning validation...");
foreach (var receivedEvent in receivedEvents)
if (receivedEvents.Count() < eventBatch.Count())
{
var receivedEventMessage = Encoding.UTF8.GetString(receivedEvent.Body.ToArray());
var sentEventMessage = Encoding.UTF8.GetString(eventBatch[index].Body.ToArray());

if (receivedEventMessage == sentEventMessage)
{
Console.WriteLine("\tEvent '" + receivedEventMessage + "' correctly validated.");
}
else
{
throw new Exception(String.Format("Error, Event: '" + receivedEventMessage + "' was not expected."));
}
index++;
}

if (index < eventBatch.Count())
{
throw new Exception(String.Format("Error, expecting " + eventBatch.Count().ToString() + " events, but only got " + index.ToString() + "."));
throw new Exception(String.Format($"Error, expecting {eventBatch.Count().ToString()} events, but only got {receivedEvents.Count().ToString()}."));
JonathanCrd marked this conversation as resolved.
Show resolved Hide resolved
}

Console.WriteLine("done");
Expand Down
8 changes: 6 additions & 2 deletions samples/SmokeTest/SmokeTest/KeyVaultTest.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,8 @@
using Azure.Identity;
// ------------------------------------
// Copyright(c) Microsoft Corporation.
// Licensed under the MIT License.
// ------------------------------------
using Azure.Identity;
using Azure.Security.KeyVault.Secrets;
using System;
using System.Threading.Tasks;
Expand All @@ -7,7 +11,7 @@ namespace SmokeTest
{
class KeyVaultTest
{
private const string SecretName = "SmokeTestSecret";
private static string SecretName = $"SmokeTestSecret-{Guid.NewGuid()}";
private const string SecretValue = "smokeTestValue";
private static SecretClient client;

Expand Down
7 changes: 6 additions & 1 deletion samples/SmokeTest/SmokeTest/Program.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,9 @@
using Azure.Messaging.EventHubs;
// ------------------------------------
// Copyright(c) Microsoft Corporation.
// Licensed under the MIT License.
// ------------------------------------
// ------------------------------------
using Azure.Messaging.EventHubs;
using System;
using System.Reflection.Metadata;
using System.Threading.Tasks;
Expand Down