Skip to content

Commit

Permalink
Update models and fix live tests
Browse files Browse the repository at this point in the history
Required change after Azure/azure-rest-api-specs#9968. The live test was failing because we *sometimes* exhausted our free allocation of text translations.
  • Loading branch information
heaths committed Jun 26, 2020
1 parent 58f0d39 commit f592b30
Show file tree
Hide file tree
Showing 231 changed files with 5,379 additions and 8,173 deletions.
4 changes: 4 additions & 0 deletions sdk/search/Azure.Search.Documents/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,10 @@
- Removed preview version `SearchClientOptions.ServiceVersion.V2019_05_06_Preview`
and added version `SearchClientOptions.ServiceVersion.V2020_06_30`.

### Removed

- Removed `SearchServiceCounters.SkillsetCounter`.

## 1.0.0-preview.4 (2020-06-09)

### Added
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1306,7 +1306,6 @@ internal SearchServiceCounters() { }
public Azure.Search.Documents.Indexes.Models.SearchResourceCounter DocumentCounter { get { throw null; } }
public Azure.Search.Documents.Indexes.Models.SearchResourceCounter IndexCounter { get { throw null; } }
public Azure.Search.Documents.Indexes.Models.SearchResourceCounter IndexerCounter { get { throw null; } }
public Azure.Search.Documents.Indexes.Models.SearchResourceCounter SkillsetCounter { get { throw null; } }
public Azure.Search.Documents.Indexes.Models.SearchResourceCounter StorageSizeCounter { get { throw null; } }
public Azure.Search.Documents.Indexes.Models.SearchResourceCounter SynonymMapCounter { get { throw null; } }
}
Expand Down Expand Up @@ -1999,7 +1998,7 @@ public static partial class SearchModelFactory
public static Azure.Search.Documents.Models.SearchResultsPage<T> SearchResultsPage<T>(Azure.Search.Documents.Models.SearchResults<T> results) { throw null; }
public static Azure.Search.Documents.Models.SearchResults<T> SearchResults<T>(System.Collections.Generic.IEnumerable<Azure.Search.Documents.Models.SearchResult<T>> values, long? totalCount, System.Collections.Generic.IDictionary<string, System.Collections.Generic.IList<Azure.Search.Documents.Models.FacetResult>> facets, double? coverage, Azure.Response rawResponse) { throw null; }
public static Azure.Search.Documents.Models.SearchResult<T> SearchResult<T>(T document, double? score, System.Collections.Generic.IDictionary<string, System.Collections.Generic.IList<string>> highlights) { throw null; }
public static Azure.Search.Documents.Indexes.Models.SearchServiceCounters SearchServiceCounters(Azure.Search.Documents.Indexes.Models.SearchResourceCounter documentCounter, Azure.Search.Documents.Indexes.Models.SearchResourceCounter indexCounter, Azure.Search.Documents.Indexes.Models.SearchResourceCounter indexerCounter, Azure.Search.Documents.Indexes.Models.SearchResourceCounter dataSourceCounter, Azure.Search.Documents.Indexes.Models.SearchResourceCounter storageSizeCounter, Azure.Search.Documents.Indexes.Models.SearchResourceCounter synonymMapCounter, Azure.Search.Documents.Indexes.Models.SearchResourceCounter skillsetCounter) { throw null; }
public static Azure.Search.Documents.Indexes.Models.SearchServiceCounters SearchServiceCounters(Azure.Search.Documents.Indexes.Models.SearchResourceCounter documentCounter, Azure.Search.Documents.Indexes.Models.SearchResourceCounter indexCounter, Azure.Search.Documents.Indexes.Models.SearchResourceCounter indexerCounter, Azure.Search.Documents.Indexes.Models.SearchResourceCounter dataSourceCounter, Azure.Search.Documents.Indexes.Models.SearchResourceCounter storageSizeCounter, Azure.Search.Documents.Indexes.Models.SearchResourceCounter synonymMapCounter) { throw null; }
public static Azure.Search.Documents.Indexes.Models.SearchServiceLimits SearchServiceLimits(int? maxFieldsPerIndex, int? maxFieldNestingDepthPerIndex, int? maxComplexCollectionFieldsPerIndex, int? maxComplexObjectsInCollectionsPerDocument) { throw null; }
public static Azure.Search.Documents.Indexes.Models.SearchServiceStatistics SearchServiceStatistics(Azure.Search.Documents.Indexes.Models.SearchServiceCounters counters, Azure.Search.Documents.Indexes.Models.SearchServiceLimits limits) { throw null; }
public static Azure.Search.Documents.Models.SearchSuggestion<T> SearchSuggestion<T>(T document, string text) { throw null; }
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -182,7 +182,8 @@ SearchIndexerSkillset skillset = new SearchIndexerSkillset(
skillsetName,
new SearchIndexerSkill[] { translationSkill, conditionalSkill })
{
CognitiveServicesAccount = new CognitiveServicesAccountKey(Environment.GetEnvironmentVariable("COGNITIVE_KEY"))
CognitiveServicesAccount = new CognitiveServicesAccountKey(
Environment.GetEnvironmentVariable("COGNITIVE_SERVICES_KEY"))
};

await indexerClient.CreateSkillsetAsync(skillset);
Expand Down

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Original file line number Diff line number Diff line change
Expand Up @@ -131,17 +131,15 @@ public static SearchResourceCounter SearchResourceCounter(
/// <param name="dataSourceCounter"> Total number of data sources. </param>
/// <param name="storageSizeCounter"> Total size of used storage in bytes. </param>
/// <param name="synonymMapCounter"> Total number of synonym maps. </param>
/// <param name="skillsetCounter"> Total number of skillsets. </param>
/// <returns> A new SearchServiceCounters instance for mocking. </returns>
public static SearchServiceCounters SearchServiceCounters(
SearchResourceCounter documentCounter,
SearchResourceCounter indexCounter,
SearchResourceCounter indexerCounter,
SearchResourceCounter dataSourceCounter,
SearchResourceCounter storageSizeCounter,
SearchResourceCounter synonymMapCounter,
SearchResourceCounter skillsetCounter) =>
new SearchServiceCounters(documentCounter, indexCounter, indexerCounter, dataSourceCounter, storageSizeCounter, synonymMapCounter, skillsetCounter);
SearchResourceCounter synonymMapCounter) =>
new SearchServiceCounters(documentCounter, indexCounter, indexerCounter, dataSourceCounter, storageSizeCounter, synonymMapCounter);

/// <summary> Initializes a new instance of SearchServiceLimits. </summary>
/// <param name="maxFieldsPerIndex"> The maximum allowed fields per index. </param>
Expand Down
4 changes: 2 additions & 2 deletions sdk/search/Azure.Search.Documents/src/autorest.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,8 @@ we should merge the Service and Index swagger files together but for now we
copy them locally in `/sdk/search/generate.ps1` and reference them here.
```yaml
input-file:
- https://raw.githubusercontent.com/Azure/azure-rest-api-specs/f487ebc93065fd42540aa422c04edd6a768a03e6/specification/search/data-plane/Azure.Search/preview/2020-06-30/searchindex.json
- https://raw.githubusercontent.com/Azure/azure-rest-api-specs/f487ebc93065fd42540aa422c04edd6a768a03e6/specification/search/data-plane/Azure.Search/preview/2020-06-30/searchservice.json
- https://raw.githubusercontent.com/Azure/azure-rest-api-specs/0bc7853cb4d824bb6c310344dcc1b5f77cbe6bdd/specification/search/data-plane/Azure.Search/preview/2020-06-30/searchindex.json
- https://raw.githubusercontent.com/Azure/azure-rest-api-specs/0bc7853cb4d824bb6c310344dcc1b5f77cbe6bdd/specification/search/data-plane/Azure.Search/preview/2020-06-30/searchservice.json
```
## Release hacks
Expand Down
9 changes: 5 additions & 4 deletions sdk/search/Azure.Search.Documents/tests/Samples/HelloWorld.cs
Original file line number Diff line number Diff line change
Expand Up @@ -161,6 +161,7 @@ public async Task CreateIndexerAsync()
Environment.SetEnvironmentVariable("SEARCH_API_KEY", resources.PrimaryApiKey);
Environment.SetEnvironmentVariable("STORAGE_CONNECTION_STRING", resources.StorageAccountConnectionString);
Environment.SetEnvironmentVariable("STORAGE_CONTAINER", resources.BlobContainerName);
Environment.SetEnvironmentVariable("COGNITIVE_SERVICES_KEY", resources.CognitiveServicesKey);

// Define clean up tasks to be invoked in reverse order added.
Stack<Func<Task>> cleanUpTasks = new Stack<Func<Task>>();
Expand Down Expand Up @@ -294,8 +295,8 @@ public async Task CreateIndexerAsync()
skillsetName,
new SearchIndexerSkill[] { translationSkill, conditionalSkill })
{
//@@CognitiveServicesAccount = new CognitiveServicesAccountKey(Environment.GetEnvironmentVariable("COGNITIVE_KEY"))
/*@@*/ CognitiveServicesAccount = new DefaultCognitiveServicesAccount() // This works for our very small hotel data set.
CognitiveServicesAccount = new CognitiveServicesAccountKey(
Environment.GetEnvironmentVariable("COGNITIVE_SERVICES_KEY"))
};

await indexerClient.CreateSkillsetAsync(skillset);
Expand Down Expand Up @@ -346,8 +347,8 @@ public async Task CreateIndexerAsync()
// index is deleted when our SearchResources goes out of scope.
cleanUpTasks.Push(() => indexerClient.DeleteIndexerAsync(indexerName));

// Wait a bit to make sure documents are indexed.
await DelayAsync(TimeSpan.FromSeconds(5));
// Wait till the indexer is done.
await WaitForIndexingAsync(indexerClient, indexerName);

#region Snippet:Azure_Search_Tests_Samples_CreateIndexerAsync_Query
// Get a SearchClient from the SearchIndexClient to share its pipeline.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -523,53 +523,5 @@ public async Task CrudSkillset()
throw;
}
}

/// <summary>
/// Waits for an indexer to complete up to the given <paramref name="timeout"/>.
/// </summary>
/// <param name="client">The <see cref="SearchIndexerClient"/> to use for requests.</param>
/// <param name="indexerName">The name of the <see cref="SearchIndexer"/> to check.</param>
/// <param name="timeout">The amount of time before being canceled. The default is 1 minute.</param>
/// <returns>A <see cref="Task"/> to await.</returns>
private async Task WaitForIndexingAsync(
SearchIndexerClient client,
string indexerName,
TimeSpan? timeout = null)
{
TimeSpan delay = TimeSpan.FromSeconds(10);
timeout ??= TimeSpan.FromMinutes(5);

using CancellationTokenSource cts = new CancellationTokenSource(timeout.Value);

while (true)
{
await DelayAsync(delay, cancellationToken: cts.Token);

SearchIndexerStatus status = await client.GetIndexerStatusAsync(
indexerName,
cancellationToken: cts.Token);

if (status.Status == IndexerStatus.Running &&
status.LastResult?.Status == IndexerExecutionStatus.Success)
{
return;
}
else if (status.Status == IndexerStatus.Error && status.LastResult is IndexerExecutionResult lastResult)
{
StringBuilder sb = new StringBuilder();
sb.AppendLine($"Error: {lastResult.ErrorMessage}");

if (lastResult.Errors?.Count > 0)
{
foreach (SearchIndexerError error in lastResult.Errors)
{
sb.AppendLine($" ---> {error.ErrorMessage}");
}
}

Assert.Fail(sb.ToString());
}
}
}
}
}

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading

0 comments on commit f592b30

Please sign in to comment.