forked from Azure/azure-sdk-for-net
-
Notifications
You must be signed in to change notification settings - Fork 17
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Adding CallRecording live tests. (Azure#30435)
* Initial commit * new tests, same failures * First Live Test * Adding live tests * Cleaning * Adding PlayAudio live tests * Updating Swagger * AutoResting new swagger * Adding Events for CallRecording and Play * Fixing build * Fixing new option bag * Export API * Fixing naming * Fixing merge * Fixing changes * Fixing merge * Applying PR comments
- Loading branch information
Showing
23 changed files
with
1,948 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -1917,4 +1917,4 @@ | |
} | ||
] | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
50 changes: 50 additions & 0 deletions
50
sdk/communication/Azure.Communication.CallingServer/tests/CallMedia/CallMediaLiveTests.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,50 @@ | ||
// Copyright (c) Microsoft Corporation. All rights reserved. | ||
// Licensed under the MIT License. | ||
|
||
using System; | ||
using System.Threading.Tasks; | ||
using NUnit.Framework; | ||
|
||
namespace Azure.Communication.CallingServer | ||
{ | ||
internal class CallMediaLiveTests : CallAutomationClientLiveTestsBase | ||
{ | ||
public CallMediaLiveTests(bool isAsync) : base(isAsync) | ||
{ } | ||
|
||
[Test] | ||
public async Task PlayAudio() | ||
{ | ||
CallAutomationClient client = CreateInstrumentedCallAutomationClientWithConnectionString(); | ||
string callConnectionId = ""; | ||
try | ||
{ | ||
var user = await CreateIdentityUserAsync().ConfigureAwait(false); | ||
var targetUserId = TestEnvironment.TargetUserId; | ||
var targetUser = new CommunicationUserIdentifier(targetUserId); | ||
string ngrok = "https://localhost"; | ||
string playAudioUri = "https://localhost/bot-hold-music-2.wav"; | ||
var targets = new CommunicationIdentifier[] { targetUser }; | ||
var callResponse = await client.CreateCallAsync(new CallSource(user), targets, new Uri(ngrok)).ConfigureAwait(false); | ||
Assert.NotNull(callResponse); | ||
Assert.NotNull(callResponse.Value); | ||
var callConnection = callResponse.Value.CallConnection; | ||
callConnectionId = callConnection.CallConnectionId; | ||
var playResponse = await callConnection.GetCallMedia().PlayAsync( | ||
new FileSource(new Uri(playAudioUri)) { PlaySourceId = "playSourceId"}, | ||
new CommunicationUserIdentifier[] { targetUser }); | ||
Assert.NotNull(playResponse); | ||
Assert.AreEqual(202, playResponse.Status); | ||
} | ||
catch (RequestFailedException ex) | ||
{ | ||
Assert.Fail($"Unexpected error: {ex}"); | ||
} | ||
finally | ||
{ | ||
var callConnection = client.GetCallConnection(callConnectionId); | ||
await callConnection.HangUpAsync(true).ConfigureAwait(false); | ||
} | ||
} | ||
} | ||
} |
89 changes: 89 additions & 0 deletions
89
...unication/Azure.Communication.CallingServer/tests/CallRecording/CallRecordingLiveTests.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,89 @@ | ||
// Copyright (c) Microsoft Corporation. All rights reserved. | ||
// Licensed under the MIT License. | ||
|
||
using System; | ||
using System.Threading.Tasks; | ||
using NUnit.Framework; | ||
|
||
namespace Azure.Communication.CallingServer | ||
{ | ||
internal class CallRecordingLiveTests : CallAutomationClientLiveTestsBase | ||
{ | ||
public CallRecordingLiveTests(bool isAsync) : base(isAsync) | ||
{ } | ||
|
||
[Test] | ||
public async Task RecordingOperations() | ||
{ | ||
if (SkipCallingServerInteractionLiveTests) | ||
{ | ||
Assert.Ignore("Skip callingserver interaction live tests flag is on"); | ||
} | ||
|
||
CallAutomationClient client = CreateInstrumentedCallAutomationClientWithConnectionString(); | ||
string callConnectionId = ""; | ||
bool stopRecording = false; | ||
try | ||
{ | ||
var user = await CreateIdentityUserAsync().ConfigureAwait(false); | ||
var targetUser = TestEnvironment.TargetUserId; | ||
string ngrok = "https://localhost"; | ||
var targets = new CommunicationIdentifier[] { new CommunicationUserIdentifier(targetUser) }; | ||
var callResponse = await client.CreateCallAsync(new CallSource(user), targets, new Uri(ngrok)).ConfigureAwait(false); | ||
Assert.NotNull(callResponse); | ||
Assert.NotNull(callResponse.Value); | ||
string callId = "serverCallId"; | ||
callConnectionId = callResponse.Value.CallConnection.CallConnectionId; | ||
CallRecording callRecording = client.GetCallRecording(); | ||
StartRecordingOptions recordingOptions = new StartRecordingOptions(new ServerCallLocator(callId)) | ||
{ | ||
RecordingStateCallbackEndpoint = new Uri(ngrok) | ||
}; | ||
var recordingResponse = await callRecording.StartRecordingAsync(recordingOptions).ConfigureAwait(false); | ||
Assert.NotNull(recordingResponse.Value); | ||
|
||
var recordingId = recordingResponse.Value.RecordingId; | ||
Assert.NotNull(recordingId); | ||
await WaitForOperationCompletion().ConfigureAwait(false); | ||
|
||
recordingResponse = await callRecording.GetRecordingStateAsync(recordingId).ConfigureAwait(false); | ||
Assert.NotNull(recordingResponse.Value); | ||
Assert.NotNull(recordingResponse.Value.RecordingState); | ||
Assert.AreEqual(recordingResponse.Value.RecordingState, RecordingState.Active); | ||
|
||
await callRecording.PauseRecordingAsync(recordingId); | ||
await WaitForOperationCompletion().ConfigureAwait(false); | ||
recordingResponse = await callRecording.GetRecordingStateAsync(recordingId).ConfigureAwait(false); | ||
Assert.NotNull(recordingResponse.Value); | ||
Assert.NotNull(recordingResponse.Value.RecordingState); | ||
Assert.AreEqual(recordingResponse.Value.RecordingState, RecordingState.Inactive); | ||
|
||
await callRecording.ResumeRecordingAsync(recordingId); | ||
await WaitForOperationCompletion().ConfigureAwait(false); | ||
recordingResponse = await callRecording.GetRecordingStateAsync(recordingId).ConfigureAwait(false); | ||
Assert.NotNull(recordingResponse.Value); | ||
Assert.NotNull(recordingResponse.Value.RecordingState); | ||
Assert.AreEqual(recordingResponse.Value.RecordingState, RecordingState.Active); | ||
|
||
await callRecording.StopRecordingAsync(recordingId); | ||
await WaitForOperationCompletion().ConfigureAwait(false); | ||
stopRecording = true; | ||
recordingResponse = await callRecording.GetRecordingStateAsync(recordingId).ConfigureAwait(false); | ||
} | ||
catch (RequestFailedException ex) | ||
{ | ||
if (ex.Status == 404 && stopRecording) | ||
{ | ||
// recording stopped successfully | ||
Assert.Pass(); | ||
} | ||
Assert.Fail($"Unexpected error: {ex}"); | ||
} | ||
finally | ||
{ | ||
var callConnection = client.GetCallConnection(callConnectionId); | ||
await callConnection.HangUpAsync(true).ConfigureAwait(false); | ||
} | ||
} | ||
} | ||
} |
106 changes: 106 additions & 0 deletions
106
...ication/Azure.Communication.CallingServer/tests/CallRecording/ContentDownloadLiveTests.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,106 @@ | ||
// Copyright (c) Microsoft Corporation. All rights reserved. | ||
// Licensed under the MIT License. | ||
|
||
using System; | ||
using System.IO; | ||
using System.Text.Json; | ||
using System.Threading.Tasks; | ||
using NUnit.Framework; | ||
|
||
namespace Azure.Communication.CallingServer | ||
{ | ||
internal class ContentDownloadLiveTests : CallAutomationClientLiveTestsBase | ||
{ | ||
public ContentDownloadLiveTests(bool isAsync) : base(isAsync) | ||
{ } | ||
|
||
[Test] | ||
public async Task DownloadMetadata() | ||
{ | ||
if (SkipCallingServerInteractionLiveTests) | ||
{ | ||
Assert.Ignore("Skip callingserver interaction live tests flag is on"); | ||
} | ||
|
||
CallAutomationClient client = CreateInstrumentedCallAutomationClientWithConnectionString(); | ||
string documentId = "0-wus-d4-d4c223871b58d3664401b66d35fca784"; | ||
Uri metadataEndpoint = new Uri($"https://us-storage.asm.skype.com/v1/objects/{documentId}/content/acsmetadata"); | ||
CallRecording callRecordingClient = client.GetCallRecording(); | ||
Stream metadata = await callRecordingClient.DownloadStreamingAsync(metadataEndpoint); | ||
Assert.IsNotNull(metadata); | ||
JsonElement actual = JsonDocument.Parse(metadata).RootElement; | ||
Assert.AreEqual(documentId, actual.GetProperty("chunkDocumentId").ToString()); | ||
} | ||
|
||
[Test] | ||
public async Task DownloadMetadata_404() | ||
{ | ||
if (SkipCallingServerInteractionLiveTests) | ||
{ | ||
Assert.Ignore("Skip callingserver interaction live tests flag is on"); | ||
} | ||
|
||
CallAutomationClient client = CreateInstrumentedCallAutomationClientWithConnectionString(); | ||
string nonExistentDocumentId = "0-wus-d4-d4c223871b58d3664401b66d35fca785"; | ||
Uri metadataEndpoint = new Uri($"https://us-storage.asm.skype.com/v1/objects/{nonExistentDocumentId}/content/acsmetadata"); | ||
CallRecording callRecordingClient = client.GetCallRecording(); | ||
try | ||
{ | ||
Stream metadata = await callRecordingClient.DownloadStreamingAsync(metadataEndpoint); | ||
Assert.IsNotNull(metadata); | ||
JsonElement actual = JsonDocument.Parse(metadata).RootElement; | ||
Assert.AreEqual(nonExistentDocumentId, actual.GetProperty("chunkDocumentId").ToString()); | ||
} | ||
catch (RequestFailedException ex) | ||
{ | ||
if (ex.Status == 404) | ||
{ | ||
Assert.Pass("Recording was not found"); | ||
} | ||
else | ||
{ | ||
Assert.Fail($"Unexpected error: {ex}"); | ||
} | ||
} | ||
} | ||
|
||
[Test] | ||
public async Task DownloadMetadataRange() | ||
{ | ||
if (SkipCallingServerInteractionLiveTests) | ||
{ | ||
Assert.Ignore("Skip callingserver interaction live tests flag is on"); | ||
} | ||
|
||
CallAutomationClient client = CreateInstrumentedCallAutomationClientWithConnectionString(); | ||
int length = 5; | ||
string documentId = "0-wus-d4-d4c223871b58d3664401b66d35fca784"; | ||
Uri metadataEndpoint = new Uri($"https://us-storage.asm.skype.com/v1/objects/{documentId}/content/acsmetadata"); | ||
CallRecording callRecordingClient = client.GetCallRecording(); | ||
Response<Stream> response = await callRecordingClient.DownloadStreamingAsync(metadataEndpoint, new HttpRange(0, length)); | ||
Assert.IsNotNull(response); | ||
Assert.AreEqual(length, response.GetRawResponse().Headers.ContentLength); | ||
} | ||
|
||
[Test] | ||
/// This test tries to get a US stored document id from EU endpoint. | ||
/// The backend server will redirect (respond with a 301) the request to a US endpoint | ||
/// and the SDK should be able to make the new request with no error. | ||
public async Task DownloadMetadataWithRedirection() | ||
{ | ||
if (SkipCallingServerInteractionLiveTests) | ||
{ | ||
Assert.Ignore("Skip callingserver interaction live tests flag is on"); | ||
} | ||
|
||
CallAutomationClient client = CreateInstrumentedCallAutomationClientWithConnectionString(); | ||
string documentId = "0-wus-d4-d4c223871b58d3664401b66d35fca784"; | ||
Uri metadataEndpoint = new Uri($"https://eu-storage.asm.skype.com/v1/objects/{documentId}/content/acsmetadata"); | ||
CallRecording callRecordingClient = client.GetCallRecording(); | ||
Stream metadata = await callRecordingClient.DownloadStreamingAsync(metadataEndpoint); | ||
Assert.IsNotNull(metadata); | ||
JsonElement actual = JsonDocument.Parse(metadata).RootElement; | ||
Assert.AreEqual(documentId, actual.GetProperty("chunkDocumentId").ToString()); | ||
} | ||
} | ||
} |
61 changes: 61 additions & 0 deletions
61
...ication/Azure.Communication.CallingServer/tests/CallRecording/DeleteRecordingLiveTests.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,61 @@ | ||
// Copyright (c) Microsoft Corporation. All rights reserved. | ||
// Licensed under the MIT License. | ||
|
||
using System; | ||
using System.Threading.Tasks; | ||
using NUnit.Framework; | ||
|
||
namespace Azure.Communication.CallingServer | ||
{ | ||
internal class DeleteRecordingLiveTests : CallAutomationClientLiveTestsBase | ||
{ | ||
public DeleteRecordingLiveTests(bool isAsync) : base(isAsync) | ||
{ } | ||
|
||
[Test] | ||
public async Task DeleteRecording() | ||
{ | ||
if (SkipCallingServerInteractionLiveTests) | ||
{ | ||
Assert.Ignore("Skip callingserver interaction live tests flag is on"); | ||
} | ||
|
||
CallAutomationClient client = CreateInstrumentedCallAutomationClientWithConnectionString(); | ||
string documentId = "0-wus-d4-d4c223871b58d3664401b66d35fca784"; | ||
Uri contentEndpoint = new Uri($"https://us-storage.asm.skype.com/v1/objects/{documentId}"); | ||
CallRecording callRecordingClient = client.GetCallRecording(); | ||
Response response = await callRecordingClient.DeleteRecordingAsync(contentEndpoint); | ||
Assert.IsNotNull(response); | ||
Assert.AreEqual(200, response.Status); | ||
} | ||
|
||
[Test] | ||
public async Task DeleteRecording404() | ||
{ | ||
if (SkipCallingServerInteractionLiveTests) | ||
{ | ||
Assert.Ignore("Skip callingserver interaction live tests flag is on"); | ||
} | ||
|
||
CallAutomationClient client = CreateInstrumentedCallAutomationClientWithConnectionString(); | ||
string nonExistentDocumentId = "0-wus-d4-d4c223871b58d3664401b66d35fca785"; | ||
Uri contentEndpoint = new Uri($"https://us-storage.asm.skype.com/v1/objects/{nonExistentDocumentId}"); | ||
CallRecording callRecordingClient = client.GetCallRecording(); | ||
try | ||
{ | ||
await callRecordingClient.DeleteRecordingAsync(contentEndpoint); | ||
} | ||
catch (RequestFailedException ex) | ||
{ | ||
if (ex.Status == 404) | ||
{ | ||
Assert.Pass("Recording was not found"); | ||
} | ||
else | ||
{ | ||
Assert.Fail($"Unexpected error: {ex}"); | ||
} | ||
} | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.