diff --git a/.github/workflows/_test-hcd.yml b/.github/workflows/_test-hcd.yml index 970bab30..f25586ac 100644 --- a/.github/workflows/_test-hcd.yml +++ b/.github/workflows/_test-hcd.yml @@ -13,7 +13,7 @@ env: AWS_ECR_ROLE_NAME: ${{ secrets.AWS_ECR_ROLE_NAME }} AWS_ECR_REPOSITORY: ${{ secrets.AWS_ECR_REPOSITORY }} AWS_ECR_REGISTRY: ${{ secrets.AWS_ECR_REGISTRY }} - AWS_ECR_HCD_IMAGE_TAG: "1.2.3" + AWS_ECR_HCD_IMAGE_TAG: "2.0.6" jobs: test: diff --git a/docker-compose/docker-compose.yml b/docker-compose/docker-compose.yml index 0749180e..370cb3cb 100644 --- a/docker-compose/docker-compose.yml +++ b/docker-compose/docker-compose.yml @@ -1,12 +1,12 @@ services: hcd: - image: 559669398656.dkr.ecr.us-west-2.amazonaws.com/engops-shared/hcd/prod/hcd:1.2.3 + image: 559669398656.dkr.ecr.us-west-2.amazonaws.com/engops-shared/hcd/prod/hcd:2.0.6 networks: - stargate mem_limit: 2G environment: - MAX_HEAP_SIZE=1536M - - CLUSTER_NAME=hcd-1.2.3-cluster + - CLUSTER_NAME=hcd-2.0.6-cluster - DS_LICENSE=accept - HCD_AUTO_CONF_OFF=xcassandra.yaml - JVM_EXTRA_OPTS=-Dcassandra.sai.latest.version=ec @@ -21,7 +21,7 @@ services: retries: 20 data-api: - image: stargateio/data-api:v1.0.32 + image: stargateio/data-api:v1.0.46 depends_on: hcd: condition: service_healthy diff --git a/test/DataStax.AstraDB.DataApi.IntegrationTests/EmbeddingProviderSwitcher.cs b/test/DataStax.AstraDB.DataApi.IntegrationTests/EmbeddingProviderSwitcher.cs new file mode 100644 index 00000000..6a6451f0 --- /dev/null +++ b/test/DataStax.AstraDB.DataApi.IntegrationTests/EmbeddingProviderSwitcher.cs @@ -0,0 +1,46 @@ +/* + * Copyright DataStax, Inc. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +namespace DataStax.AstraDB.DataApi.IntegrationTests; + +/// +/// Static configuration on the embedding provider for all vectorize-related integration testing. +/// +public static class EmbeddingProviderSwitcher { + + /// + /// Embedding provider to use. + /// + public const string Provider = "voyageAI"; + /// + /// Embedding model to use. + /// + public const string ModelName = "voyage-2"; + + /// + /// A dimension value compatible with the provider/model choice. + /// + public const int Dimension = 1024; + + /// + /// Name of the secret in Astra scoped to the DB being used to test. + /// + public const string KMSSecretName = "SHARED_SECRET_EMBEDDING_API_KEY_VOYAGEAI"; + /// + /// Name of the environment variable containing the embedding API key. + /// + public const string SecretEnvironmentVariableName = "HEADER_EMBEDDING_API_KEY_VOYAGEAI"; +} diff --git a/test/DataStax.AstraDB.DataApi.IntegrationTests/TestObjects.cs b/test/DataStax.AstraDB.DataApi.IntegrationTests/TestObjects.cs index 869b68fb..5ffdd50f 100644 --- a/test/DataStax.AstraDB.DataApi.IntegrationTests/TestObjects.cs +++ b/test/DataStax.AstraDB.DataApi.IntegrationTests/TestObjects.cs @@ -91,8 +91,8 @@ public class SimpleObjectWithVectorizeAttribute [CollectionName("coll_SimpleObjectWithVectorizeShSecret")] [CollectionVectorize( - Provider = "openai", ModelName = "text-embedding-3-small", - AuthenticationPairs = new string[] {"providerKey", "SHARED_SECRET_EMBEDDING_API_KEY_OPENAI"} + Provider = EmbeddingProviderSwitcher.Provider, ModelName = EmbeddingProviderSwitcher.ModelName, + AuthenticationPairs = new string[] {"providerKey", EmbeddingProviderSwitcher.KMSSecretName} )] public class SimpleObjectWithVectorizeAttributeShSecret { @@ -106,12 +106,12 @@ public class SimpleObjectWithVectorizeAttributeShSecret [CollectionName("coll_SimpleObjectWithVectorizeShSecret2A")] [CollectionVector( SimilarityMetric.Euclidean, - 123, + EmbeddingProviderSwitcher.Dimension, SourceModel="bert" )] [CollectionVectorize( - Provider = "openai", ModelName = "text-embedding-3-small", - AuthenticationPairs = new string[] {"providerKey", "SHARED_SECRET_EMBEDDING_API_KEY_OPENAI"} + Provider = EmbeddingProviderSwitcher.Provider, ModelName = EmbeddingProviderSwitcher.ModelName, + AuthenticationPairs = new string[] {"providerKey", EmbeddingProviderSwitcher.KMSSecretName} )] public class SimpleObjectWithVectorizeAttributeShSecret2A { @@ -123,7 +123,7 @@ public class SimpleObjectWithVectorizeAttributeShSecret2A } [CollectionName("coll_SimpleObjectWithVectorizeHeader")] -[CollectionVectorize(Provider = "openai", ModelName = "text-embedding-3-small")] +[CollectionVectorize(Provider = EmbeddingProviderSwitcher.Provider, ModelName = EmbeddingProviderSwitcher.ModelName)] public class SimpleObjectWithVectorizeAttributeHeader { [DocumentId] @@ -279,7 +279,7 @@ public class RowBookVectorizeHeaderBased { [ColumnPrimaryKey(1)] public string Title { get; set; } - [ColumnVectorize("openai", "text-embedding-3-small", dimension: 1536)] + [ColumnVectorize(EmbeddingProviderSwitcher.Provider, EmbeddingProviderSwitcher.ModelName, dimension: EmbeddingProviderSwitcher.Dimension)] public object Author { get; set; } [ColumnPrimaryKey(2)] public int NumberOfPages { get; set; } @@ -294,8 +294,8 @@ public class RowBookVectorizeSharedSecret [ColumnPrimaryKey(1)] public string Title { get; set; } [ColumnVectorize( - "openai", "text-embedding-3-small", dimension: 1536, - authenticationPairs: new string[] {"providerKey", "SHARED_SECRET_EMBEDDING_API_KEY_OPENAI"} + EmbeddingProviderSwitcher.Provider, EmbeddingProviderSwitcher.ModelName, dimension: EmbeddingProviderSwitcher.Dimension, + authenticationPairs: new string[] {"providerKey", EmbeddingProviderSwitcher.KMSSecretName} )] public object Author { get; set; } [ColumnPrimaryKey(2)] @@ -311,8 +311,8 @@ public class RowBookVectorizeSharedSecretWithParameters [ColumnPrimaryKey(1)] public string Title { get; set; } [ColumnVectorize( - "voyageAI", "voyage-2", - authenticationPairs: new string[] { "providerKey", "SHARED_SECRET_EMBEDDING_API_KEY_VOYAGEAI" }, + EmbeddingProviderSwitcher.Provider, EmbeddingProviderSwitcher.ModelName, + authenticationPairs: new string[] { "providerKey", EmbeddingProviderSwitcher.KMSSecretName }, parameterPairs: new object[] { "autoTruncate", false } )] public object Author { get; set; } @@ -842,8 +842,8 @@ public class FakeDocument [CollectionName("coll_one_embedding_header_test")] [CollectionVectorize( - "voyageAI", - "voyage-2", + EmbeddingProviderSwitcher.Provider, + EmbeddingProviderSwitcher.ModelName, parameterPairs: new object[] { "autoTruncate", false } )] public class DocumentForEmbeddingHeaderTest @@ -876,7 +876,7 @@ public class RowForEmbeddingHeaderTest [ColumnPrimaryKey(1)] public string Id { get; set; } [ColumnVectorize( - "voyageAI", "voyage-2", dimension: 1024, + EmbeddingProviderSwitcher.Provider, EmbeddingProviderSwitcher.ModelName, dimension: EmbeddingProviderSwitcher.Dimension, parameterPairs: new object[] { "autoTruncate", false } )] public object Name { get; set; } diff --git a/test/DataStax.AstraDB.DataApi.IntegrationTests/Tests/AdditionalCollectionTests.cs b/test/DataStax.AstraDB.DataApi.IntegrationTests/Tests/AdditionalCollectionTests.cs index 08be05ee..e1d9f85f 100644 --- a/test/DataStax.AstraDB.DataApi.IntegrationTests/Tests/AdditionalCollectionTests.cs +++ b/test/DataStax.AstraDB.DataApi.IntegrationTests/Tests/AdditionalCollectionTests.cs @@ -552,11 +552,11 @@ await collection.InsertManyAsync(new List { } } - // Requires VOYAGE embedding provider - [Fact(Skip="Should be run after exporting the environment variable quoted below")] + // Requires a certain embedding provider (see EmbeddingProviderSwitcher) + [Fact(Skip="Should be run after exporting the environment variable quoted in EmbeddingProviderSwitcher")] public async Task Test_CollectionEmbeddingHeaders() { - var embeddingAPIKey = Environment.GetEnvironmentVariable("HEADER_EMBEDDING_API_KEY_VOYAGEAI") ?? "kaboom"; + var embeddingAPIKey = Environment.GetEnvironmentVariable(EmbeddingProviderSwitcher.SecretEnvironmentVariableName) ?? "kaboom"; try { var collectionCr = await fixture.Database.CreateCollectionAsync( diff --git a/test/DataStax.AstraDB.DataApi.IntegrationTests/Tests/AdditionalTableTests.cs b/test/DataStax.AstraDB.DataApi.IntegrationTests/Tests/AdditionalTableTests.cs index c80c9cc6..bf7f4b22 100644 --- a/test/DataStax.AstraDB.DataApi.IntegrationTests/Tests/AdditionalTableTests.cs +++ b/test/DataStax.AstraDB.DataApi.IntegrationTests/Tests/AdditionalTableTests.cs @@ -1252,11 +1252,11 @@ await table.InsertManyAsync(new List { } } - // Requires VOYAGE embedding provider - [Fact(Skip="Should be run after exporting the environment variable quoted below")] + // Requires a certain embedding provider (see EmbeddingProviderSwitcher) + [Fact(Skip="Should be run after exporting the environment variable quoted in EmbeddingProviderSwitcher")] public async Task Test_TableEmbeddingHeaders() { - var embeddingAPIKey = Environment.GetEnvironmentVariable("HEADER_EMBEDDING_API_KEY_VOYAGEAI") ?? "kaboom"; + var embeddingAPIKey = Environment.GetEnvironmentVariable(EmbeddingProviderSwitcher.SecretEnvironmentVariableName) ?? "kaboom"; try { var tableCr = await fixture.Database.CreateTableAsync( diff --git a/test/DataStax.AstraDB.DataApi.IntegrationTests/Tests/CollectionFARRCursorTests.cs b/test/DataStax.AstraDB.DataApi.IntegrationTests/Tests/CollectionFARRCursorTests.cs index 42b31c7e..1f1afed8 100644 --- a/test/DataStax.AstraDB.DataApi.IntegrationTests/Tests/CollectionFARRCursorTests.cs +++ b/test/DataStax.AstraDB.DataApi.IntegrationTests/Tests/CollectionFARRCursorTests.cs @@ -308,7 +308,8 @@ public async Task Test_CollectionVectorFARRCursor_RerankingHeader() await Assert.ThrowsAsync(async () => await cur.ToListAsync()); } - [Fact] + // TODO: re-enable this test when rerank-override is available in the target Data API version + [Fact(Skip="This test is disabled until Rerak-Override is released.")] public async Task Test_CollectionVectorFARRRerankOverride() { var filledCollection = _fixture.FilledVectorCollection; @@ -358,7 +359,8 @@ await Assert.ThrowsAsync(async () => ); } - [Fact] + // TODO: re-enable this test when rerank-override is available in the target Data API version + [Fact(Skip="This test is disabled until Rerak-Override is released.")] public async Task Test_CollectionVectorizeFARRRerankOverride() { var filledCollection = _fixture.FilledVectorizeCollection; diff --git a/test/DataStax.AstraDB.DataApi.IntegrationTests/Tests/DatabaseTests.cs b/test/DataStax.AstraDB.DataApi.IntegrationTests/Tests/DatabaseTests.cs index 45ae0971..96f538d4 100644 --- a/test/DataStax.AstraDB.DataApi.IntegrationTests/Tests/DatabaseTests.cs +++ b/test/DataStax.AstraDB.DataApi.IntegrationTests/Tests/DatabaseTests.cs @@ -476,7 +476,7 @@ await collection.InsertOneAsync(new SimpleObjectWithVectorizeAttribute } [SkipWhenNotAstra] - [Fact(Skip="Should be run manually after scoping a certain OpenAI key to the database with the name quoted below")] + [Fact(Skip="Should be run manually after scoping a certain embedding key to the database, see EmbeddingProviderSwitcher")] public async Task CreateCollection_WithVectorizeSharedSecret_Typed() { var collectionName = "coll_SimpleObjectWithVectorizeShSecret"; @@ -494,7 +494,7 @@ await collection.InsertOneAsync(new SimpleObjectWithVectorizeAttributeShSecret } [SkipWhenNotAstra] - [Fact(Skip="Should be run manually after scoping a certain OpenAI key to the database with the name quoted below")] + [Fact(Skip="Should be run manually after scoping a certain embedding key to the database, see EmbeddingProviderSwitcher")] public async Task CreateCollection_WithVectorizeSharedSecretDoubleAttribute_Typed() { var collectionName = "coll_SimpleObjectWithVectorizeShSecret2A"; @@ -511,10 +511,10 @@ await collection.InsertOneAsync(new SimpleObjectWithVectorizeAttributeShSecret2A await fixture.Database.DropCollectionAsync(collectionName); } - [Fact(Skip="Should be run after exporting the environment variable quoted below")] + [Fact(Skip="Should be run after exporting the environment variable quoted in EmbeddingProviderSwitcher")] public async Task CreateGetCollection_WithVectorizeHeader_Typed() { - var embeddingAPIKey = Environment.GetEnvironmentVariable("HEADER_EMBEDDING_API_KEY_OPENAI") ?? "kaboom"; + var embeddingAPIKey = Environment.GetEnvironmentVariable(EmbeddingProviderSwitcher.SecretEnvironmentVariableName) ?? "kaboom"; var headerOptions = new CreateCollectionOptions() { EmbeddingAPIKey = embeddingAPIKey }; var collectionName = "coll_SimpleObjectWithVectorizeHeader"; // Signature of overloads mandates that we supply the collection name here. Eeh, I think we can live with that. @@ -571,7 +571,7 @@ await collection.InsertOneAsync(new Document } [SkipWhenNotAstra] - [Fact(Skip="Should be run manually after scoping a certain OpenAI key to the database with the name quoted below")] + [Fact(Skip="Should be run manually after scoping a certain embedding key to the database, see EmbeddingProviderSwitcher")] public async Task CreateCollection_WithVectorizeSharedSecret_Untyped() { var collectionName = "collectionVectorizesharedSecret_Untyped"; @@ -579,15 +579,15 @@ public async Task CreateCollection_WithVectorizeSharedSecret_Untyped() { Vector = new VectorOptions { - Dimension = 1536, + Dimension = EmbeddingProviderSwitcher.Dimension, Metric = SimilarityMetric.DotProduct, Service = new VectorServiceOptions() { - Provider = "openai", - ModelName = "text-embedding-3-small", + Provider = EmbeddingProviderSwitcher.Provider, + ModelName = EmbeddingProviderSwitcher.ModelName, Authentication = new Dictionary { - { "providerKey", "SHARED_SECRET_EMBEDDING_API_KEY_OPENAI" } + { "providerKey", EmbeddingProviderSwitcher.KMSSecretName } } } } @@ -604,22 +604,22 @@ await collection.InsertOneAsync(new Document await fixture.Database.DropCollectionAsync(collectionName); } - [Fact(Skip="Should be run after exporting the environment variable quoted below")] + [Fact(Skip="Should be run after exporting the environment variable quoted in EmbeddingProviderSwitcher")] public async Task CreateGetCollection_WithVectorizeHeader_Untyped() { - var embeddingAPIKey = Environment.GetEnvironmentVariable("HEADER_EMBEDDING_API_KEY_OPENAI") ?? "kaboom"; + var embeddingAPIKey = Environment.GetEnvironmentVariable(EmbeddingProviderSwitcher.SecretEnvironmentVariableName) ?? "kaboom"; var headerOptions = new CreateCollectionOptions() { EmbeddingAPIKey = embeddingAPIKey }; var collectionName = "collection_WithVectorizeHeader_Untyped"; var options = new CollectionDefinition { Vector = new VectorOptions { - Dimension = 1536, + Dimension = EmbeddingProviderSwitcher.Dimension, Metric = SimilarityMetric.DotProduct, Service = new VectorServiceOptions() { - Provider = "openai", - ModelName = "text-embedding-3-small", + Provider = EmbeddingProviderSwitcher.Provider, + ModelName = EmbeddingProviderSwitcher.ModelName, } } }; @@ -808,7 +808,7 @@ public async Task CreateTable_WithVectorizeNone_Typed() } [SkipWhenNotAstra] - [Fact(Skip="Should be run manually after scoping a certain OpenAI key to the database with the name quoted in RowBookVectorizeSharedSecret")] + [Fact(Skip="Should be run manually after scoping a certain embedding key to the database, see EmbeddingProviderSwitcher")] public async Task CreateTable_WithVectorizeSharedSecret_Typed() { try @@ -825,7 +825,7 @@ public async Task CreateTable_WithVectorizeSharedSecret_Typed() } [SkipWhenNotAstra] - [Fact(Skip="Should be run manually after scoping a certain OpenAI key to the database with the name quoted in RowBookVectorizeSharedSecretWithParameters")] + [Fact(Skip="Should be run manually after scoping a certain embedding key to the database, see EmbeddingProviderSwitcher")] public async Task CreateTable_WithVectorizeSharedSecretWithParameters_Typed() { try @@ -841,10 +841,10 @@ public async Task CreateTable_WithVectorizeSharedSecretWithParameters_Typed() } } - [Fact(Skip="Should be run after exporting the environment variable quoted below")] + [Fact(Skip="Should be run after exporting the environment variable quoted in EmbeddingProviderSwitcher")] public async Task CreateGetTable_WithVectorizeHeader_Typed() { - var embeddingAPIKey = Environment.GetEnvironmentVariable("HEADER_EMBEDDING_API_KEY_OPENAI") ?? "kaboom"; + var embeddingAPIKey = Environment.GetEnvironmentVariable(EmbeddingProviderSwitcher.SecretEnvironmentVariableName) ?? "kaboom"; var gtHeaderOptions = new GetTableOptions() { EmbeddingAPIKey = embeddingAPIKey }; var ctHeaderOptions = new CreateTableOptions() { EmbeddingAPIKey = embeddingAPIKey }; try @@ -895,7 +895,7 @@ await table.InsertOneAsync(new Row() { } [SkipWhenNotAstra] - [Fact(Skip="Should be run manually after scoping a certain OpenAI key to the database with the name quoted below")] + [Fact(Skip="Should be run manually after scoping a certain embedding key to the database, see EmbeddingProviderSwitcher")] public async Task CreateTable_WithVectorizeSharedSecret_Untyped() { var tableName = "bookTestTableVectorizeSharedSecret_Untyped"; @@ -904,13 +904,13 @@ public async Task CreateTable_WithVectorizeSharedSecret_Untyped() var createDefinition = new TableDefinition() .AddColumn("Title", DataAPIType.Text()) .AddColumn("NumberOfPages", DataAPIType.Int()) - .AddColumn("Author", DataAPIType.Vectorize(1536, new VectorServiceOptions + .AddColumn("Author", DataAPIType.Vectorize(EmbeddingProviderSwitcher.Dimension, new VectorServiceOptions { - Provider = "openai", - ModelName = "text-embedding-3-small", + Provider = EmbeddingProviderSwitcher.Provider, + ModelName = EmbeddingProviderSwitcher.ModelName, Authentication = new Dictionary { - { "providerKey", "SHARED_SECRET_EMBEDDING_API_KEY_OPENAI" } + { "providerKey", EmbeddingProviderSwitcher.KMSSecretName } } })) .AddCompositePrimaryKey(new [] {"Title", "NumberOfPages"}); @@ -932,7 +932,7 @@ await table.InsertOneAsync(new Row() { [SkipWhenNotAstra] - [Fact(Skip="Should be run manually after scoping a certain OpenAI key to the database with the name quoted below")] + [Fact(Skip="Should be run manually after scoping a certain embedding key to the database, see EmbeddingProviderSwitcher")] public async Task CreateTable_WithVectorizeSharedSecretWithParameters_Untyped() { var tableName = "bookTestTableVeczeShdSecretWParams_Untyped"; @@ -941,13 +941,13 @@ public async Task CreateTable_WithVectorizeSharedSecretWithParameters_Untyped() var createDefinition = new TableDefinition() .AddColumn("Title", DataAPIType.Text()) .AddColumn("NumberOfPages", DataAPIType.Int()) - .AddColumn("Author", DataAPIType.Vectorize(1024, new VectorServiceOptions + .AddColumn("Author", DataAPIType.Vectorize(EmbeddingProviderSwitcher.Dimension, new VectorServiceOptions { - Provider = "voyageAI", - ModelName = "voyage-2", + Provider = EmbeddingProviderSwitcher.Provider, + ModelName = EmbeddingProviderSwitcher.ModelName, Authentication = new Dictionary { - { "providerKey", "SHARED_SECRET_EMBEDDING_API_KEY_VOYAGEAI" } + { "providerKey", EmbeddingProviderSwitcher.KMSSecretName } }, Parameters = new Dictionary { @@ -971,11 +971,11 @@ await table.InsertOneAsync(new Row() { } } - [Fact(Skip="Should be run after exporting the environment variable quoted below")] + [Fact(Skip="Should be run after exporting the environment variable quoted in EmbeddingProviderSwitcher")] public async Task CreateGetTable_WithVectorizeHeader_Untyped() { var tableName = "bookTestTableVectorizeHeader_Untyped"; - var embeddingAPIKey = Environment.GetEnvironmentVariable("HEADER_EMBEDDING_API_KEY_OPENAI") ?? "kaboom"; + var embeddingAPIKey = Environment.GetEnvironmentVariable(EmbeddingProviderSwitcher.SecretEnvironmentVariableName) ?? "kaboom"; var gtHeaderOptions = new GetTableOptions() { EmbeddingAPIKey = embeddingAPIKey }; var ctHeaderOptions = new CreateTableOptions() { EmbeddingAPIKey = embeddingAPIKey }; try @@ -983,10 +983,10 @@ public async Task CreateGetTable_WithVectorizeHeader_Untyped() var createDefinition = new TableDefinition() .AddColumn("Title", DataAPIType.Text()) .AddColumn("NumberOfPages", DataAPIType.Int()) - .AddColumn("Author", DataAPIType.Vectorize(1536, new VectorServiceOptions + .AddColumn("Author", DataAPIType.Vectorize(EmbeddingProviderSwitcher.Dimension, new VectorServiceOptions { - Provider = "openai", - ModelName = "text-embedding-3-small", + Provider = EmbeddingProviderSwitcher.Provider, + ModelName = EmbeddingProviderSwitcher.ModelName, })) .AddCompositePrimaryKey(new [] {"Title", "NumberOfPages"}); @@ -1007,7 +1007,7 @@ await gottenTable.InsertOneAsync(new Row() { } finally { - await fixture.Database.DropTableAsync(); + await fixture.Database.DropTableAsync(tableName); } }