Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
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
Prev Previous commit
Next Next commit
Update tests
  • Loading branch information
ShivangiReja committed Oct 3, 2023
commit 42d8a1156003b083847a74b372d51a101474eae2
2 changes: 1 addition & 1 deletion sdk/search/Azure.Search.Documents/assets.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,5 +2,5 @@
"AssetsRepo": "Azure/azure-sdk-assets",
"AssetsRepoPrefixPath": "net",
"TagPrefix": "net/search/Azure.Search.Documents",
"Tag": "net/search/Azure.Search.Documents_35af1638e9"
"Tag": "net/search/Azure.Search.Documents_ec63bf22f3"
}
Original file line number Diff line number Diff line change
Expand Up @@ -55,8 +55,8 @@ SearchIndex searchIndex = new(indexName)
{
AzureOpenAIParameters = new AzureOpenAIParameters()
{
ResourceUri = new Uri(Environment.GetEnvironmentVariable("OpenAIEndpoint")),
ApiKey = Environment.GetEnvironmentVariable("OpenAIKey"),
ResourceUri = new Uri(Environment.GetEnvironmentVariable("OPENAI_ENDPOINT")),
ApiKey = Environment.GetEnvironmentVariable("OPENAI_KEY"),
DeploymentId = modelName,
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
using Azure.Search.Documents.Indexes;
using Azure.Search.Documents.Models;
using NUnit.Framework;
using Azure.Core.TestFramework;

namespace Azure.Search.Documents.Tests.samples.VectorSearch
{
Expand All @@ -18,6 +19,7 @@ public VectorSearchUsingTextVectors(bool async, SearchClientOptions.ServiceVersi
}

[Test]
[PlaybackOnly("Running it in the playback mode, so that pipelines won't need to create OpenAI resources.")]
public async Task SingleVectorSearch()
{
await using SearchResources resources = SearchResources.CreateWithNoIndexes(this);
Expand Down Expand Up @@ -61,6 +63,7 @@ public async Task SingleVectorSearch()
}

[Test]
[PlaybackOnly("Running it in the playback mode, so that pipelines won't need to create OpenAI resources.")]
public async Task SingleVectorSearchWithFilter()
{
await using SearchResources resources = SearchResources.CreateWithNoIndexes(this);
Expand Down Expand Up @@ -105,6 +108,7 @@ public async Task SingleVectorSearchWithFilter()
}

[Test]
[PlaybackOnly("Running it in the playback mode, so that pipelines won't need to create OpenAI resources.")]
public async Task SimpleHybridSearch()
{
await using SearchResources resources = SearchResources.CreateWithNoIndexes(this);
Expand Down Expand Up @@ -149,6 +153,7 @@ public async Task SimpleHybridSearch()
}

[Test]
[PlaybackOnly("Running it in the playback mode, so that pipelines won't need to create OpenAI resources.")]
public async Task MultiVectorQuerySearch()
{
await using SearchResources resources = SearchResources.CreateWithNoIndexes(this);
Expand Down Expand Up @@ -196,6 +201,7 @@ public async Task MultiVectorQuerySearch()
}

[Test]
[PlaybackOnly("Running it in the playback mode, so that pipelines won't need to create OpenAI resources.")]
public async Task MultiFieldVectorQuerySearch()
{
await using SearchResources resources = SearchResources.CreateWithNoIndexes(this);
Expand Down Expand Up @@ -240,6 +246,16 @@ public async Task MultiFieldVectorQuerySearch()

private async Task<SearchIndexClient> CreateIndex(SearchResources resources, string name)
{
string openAIEndpoint = TestEnvironment.OpenAIEndpoint;
string openAIKey = TestEnvironment.OpenAIKey;
if (string.IsNullOrEmpty(openAIEndpoint) || string.IsNullOrEmpty(openAIKey))
{
Assert.Ignore("OpenAI was not deployed");
}

Environment.SetEnvironmentVariable("OPENAI_ENDPOINT", openAIEndpoint);
Environment.SetEnvironmentVariable("OPENAI_KEY", openAIKey);

#region Snippet:Azure_Search_Documents_Tests_Samples_Sample07_Vector_Search_Index_UsingTextVectors
string vectorSearchProfile = "my-vector-profile";
string vectorSearchHnswConfig = "my-hsnw-vector-config";
Expand Down Expand Up @@ -290,8 +306,8 @@ private async Task<SearchIndexClient> CreateIndex(SearchResources resources, str
{
AzureOpenAIParameters = new AzureOpenAIParameters()
{
ResourceUri = new Uri(Environment.GetEnvironmentVariable("OpenAIEndpoint")),
ApiKey = Environment.GetEnvironmentVariable("OpenAIKey"),
ResourceUri = new Uri(Environment.GetEnvironmentVariable("OPENAI_ENDPOINT")),
ApiKey = Environment.GetEnvironmentVariable("OPENAI_KEY"),
DeploymentId = modelName,
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,11 @@ public class SearchTestEnvironment: TestEnvironment
/// </summary>
public const string CognitiveKeyVariableName = "SEARCH_COGNITIVE_KEY";

/// <summary>
/// The name of the variable for <see cref="OpenAIKeyVariableName"/>.
/// </summary>
public const string OpenAIKeyVariableName = "OPENAI_KEY";

/// <summary>
/// Gets the service name.
/// </summary>
Expand Down Expand Up @@ -89,5 +94,15 @@ public class SearchTestEnvironment: TestEnvironment
/// Gets the recorded value for the CLIENT_ID, which gets sanitized as part of the payload.
/// </summary>
public string RecordedClientSecret => GetRecordedVariable(ClientSecretVariableName, options => options.IsSecret());

/// <summary>
/// Gets the optional OpenAI key
/// </summary>
public string OpenAIKey => GetRecordedOptionalVariable(OpenAIKeyVariableName, options => options.IsSecret());

/// <summary>
/// Gets the optional OpenAI URL used used for Vector Search.
/// </summary>
public string OpenAIEndpoint => GetRecordedOptionalVariable("OPENAI_ENDPOINT");
}
}