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

[FormRecognizer] Removed IgnoreServiceError attributes and overrode IsEnvironmentReady #37858

Merged
merged 1 commit into from
Jul 27, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,6 @@ namespace Azure.AI.FormRecognizer.DocumentAnalysis.Tests
/// These tests have a dependency on live Azure services and may incur costs for the associated
/// Azure subscription.
/// </remarks>
[IgnoreServiceError(400, "InvalidRequest", Message = "Content is not accessible: Invalid data URL", Reason = "https://github.com/Azure/azure-sdk-for-net/issues/28923")]
public class DocumentAnalysisClientLiveTests : DocumentAnalysisLiveTestBase
{
/// <summary>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@ namespace Azure.AI.FormRecognizer.DocumentAnalysis.Tests
/// These tests have a dependency on live Azure services and may incur costs for the associated
/// Azure subscription.
/// </remarks>
[IgnoreServiceError(400, "InvalidRequest", Message = "Content is not accessible: Invalid data URL", Reason = "https://github.com/Azure/azure-sdk-for-net/issues/28923")]
public class OperationsLiveTests : DocumentAnalysisLiveTestBase
{
/// <summary>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@ namespace Azure.AI.FormRecognizer.DocumentAnalysis.Tests
/// These tests have a dependency on live Azure services and may incur costs for the associated
/// Azure subscription.
/// </remarks>
[IgnoreServiceError(400, "InvalidRequest", Message = "Content is not accessible: Invalid data URL", Reason = "https://github.com/Azure/azure-sdk-for-net/issues/28923")]
public class DocumentModelAdministrationLiveTests : DocumentAnalysisLiveTestBase
{
private static readonly DocumentBuildMode[] s_buildDocumentModelTestCases = new[]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@ namespace Azure.AI.FormRecognizer.DocumentAnalysis.Tests
/// These tests have a dependency on live Azure services and may incur costs for the associated
/// Azure subscription.
/// </remarks>
[IgnoreServiceError(400, "InvalidRequest", Message = "Content is not accessible: Invalid data URL", Reason = "https://github.com/Azure/azure-sdk-for-net/issues/28923")]
public class MiscellaneousOperationsLiveTests : DocumentAnalysisLiveTestBase
{
private readonly IReadOnlyDictionary<string, string> _testingTags = new Dictionary<string, string>()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,6 @@ namespace Azure.AI.FormRecognizer.Tests
[ClientTestFixture(
FormRecognizerClientOptions.ServiceVersion.V2_0,
FormRecognizerClientOptions.ServiceVersion.V2_1)]
[IgnoreServiceError(200, "3014", Message = "Generic error during training.", Reason = "https://github.com/Azure/azure-sdk-for-net/issues/28913")]
public class RecognizeCustomFormsLiveTests : FormRecognizerLiveTestBase
{
public RecognizeCustomFormsLiveTests(bool isAsync, FormRecognizerClientOptions.ServiceVersion serviceVersion)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,6 @@ namespace Azure.AI.FormRecognizer.Tests
/// These tests have a dependency on live Azure services and may incur costs for the associated
/// Azure subscription.
/// </remarks>
[IgnoreServiceError(200, "3014", Message = "Generic error during training.", Reason = "https://github.com/Azure/azure-sdk-for-net/issues/28913")]
public class FormTrainingClientLiveTests : FormRecognizerLiveTestBase
{
/// <summary>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
using System;
using System.IO;
using System.Reflection;
using System.Threading.Tasks;
using Azure.Core.TestFramework;

namespace Azure.AI.FormRecognizer.DocumentAnalysis.Tests
Expand Down Expand Up @@ -73,6 +74,26 @@ public class DocumentAnalysisTestEnvironment : TestEnvironment
/// </summary>
public string ClassifierTrainingSasUrl => GetRecordedVariable("CLASSIFIER_BLOB_CONTAINER_SAS_URL", options => options.IsSecret(SanitizedSasUrl));

protected override async ValueTask<bool> IsEnvironmentReadyAsync()
{
var endpoint = new Uri(Endpoint);
var keyCredential = new AzureKeyCredential(ApiKey);
var keyCredentialClient = new DocumentModelAdministrationClient(endpoint, keyCredential);
var tokenCredentialClient = new DocumentModelAdministrationClient(endpoint, Credential);

try
{
await keyCredentialClient.GetResourceDetailsAsync();
await tokenCredentialClient.GetResourceDetailsAsync();
}
catch (RequestFailedException e) when (e.Status == 401)
{
return false;
}

return true;
}

/// <summary>
/// Creates an absolute path to a file contained in the local test assets folder.
/// </summary>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@ namespace Azure.AI.FormRecognizer.DocumentAnalysis.Samples
{
[LiveOnly]
[AsyncOnly] // Ensure that each sample will only run once.
[IgnoreServiceError(400, "InvalidRequest", Message = "Content is not accessible: Invalid data URL", Reason = "https://github.com/Azure/azure-sdk-for-net/issues/28923")]
public partial class DocumentAnalysisSamples : RecordedTestBase<DocumentAnalysisTestEnvironment>
{
public DocumentAnalysisSamples(bool isAsync) : base(isAsync, RecordedTestMode.Live)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@ namespace Azure.AI.FormRecognizer.Samples
{
[LiveOnly]
[AsyncOnly] // Ensure that each sample will only run once.
[IgnoreServiceError(200, "3014", Message = "Generic error during training.", Reason = "https://github.com/Azure/azure-sdk-for-net/issues/28913")]
public partial class FormRecognizerSamples : RecordedTestBase<FormRecognizerTestEnvironment>
{
public FormRecognizerSamples(bool isAsync) : base(isAsync, RecordedTestMode.Live)
Expand Down