Skip to content

Commit

Permalink
new workflows
Browse files Browse the repository at this point in the history
  • Loading branch information
clun committed Jul 17, 2024
1 parent 917d05e commit 0ffc7fa
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 79 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/ci-astra-dev-vectorize-hf-dedicated.yml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
name: AstraDev | HF Dedicated
name: AstraDev | Vectorize HF Dedicated

on:
#push:
Expand Down
Original file line number Diff line number Diff line change
@@ -1,10 +1,8 @@
package com.datastax.astra.test.integration;

import com.datastax.astra.client.Collection;
import com.datastax.astra.client.DataAPIClients;
import com.datastax.astra.client.Database;
import com.datastax.astra.client.admin.AstraDBAdmin;
import com.datastax.astra.client.admin.DatabaseAdmin;
import com.datastax.astra.client.auth.EmbeddingAPIKeyHeaderProvider;
import com.datastax.astra.client.auth.EmbeddingHeadersProvider;
import com.datastax.astra.client.model.CollectionOptions;
import com.datastax.astra.client.model.CommandOptions;
import com.datastax.astra.client.model.DataAPIKeywords;
Expand All @@ -17,11 +15,6 @@
import com.datastax.astra.client.model.InsertManyResult;
import com.datastax.astra.client.model.Projections;
import com.datastax.astra.client.model.SimilarityMetric;
import com.datastax.astra.client.auth.EmbeddingAPIKeyHeaderProvider;
import com.datastax.astra.client.auth.EmbeddingHeadersProvider;
import com.dtsx.astra.sdk.db.domain.CloudProviderType;
import com.dtsx.astra.sdk.utils.AstraEnvironment;
import com.dtsx.astra.sdk.utils.Utils;
import lombok.extern.slf4j.Slf4j;
import org.junit.jupiter.api.MethodOrderer;
import org.junit.jupiter.api.TestMethodOrder;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,96 +1,31 @@
package com.datastax.astra.test.integration.prod;

import com.datastax.astra.client.DataAPIClient;
import com.datastax.astra.client.Database;
import com.datastax.astra.client.admin.AstraDBDatabaseAdmin;
import com.datastax.astra.client.admin.DatabaseAdmin;
import com.datastax.astra.client.model.DatabaseInfo;
import com.datastax.astra.test.integration.AbstractAstraDBAdminTest;
import com.dtsx.astra.sdk.db.domain.CloudProviderType;
import com.dtsx.astra.sdk.utils.AstraEnvironment;
import com.dtsx.astra.sdk.utils.Utils;
import org.junit.jupiter.api.Assertions;
import org.junit.jupiter.api.MethodOrderer;
import org.junit.jupiter.api.Order;
import org.junit.jupiter.api.Test;
import org.junit.jupiter.api.TestMethodOrder;
import org.junit.jupiter.api.condition.EnabledIfEnvironmentVariable;

import java.util.Optional;
import java.util.UUID;

import static org.assertj.core.api.Assertions.assertThat;

@EnabledIfEnvironmentVariable(named = "ASTRA_DB_APPLICATION_TOKEN", matches = "Astra.*")
@EnabledIfEnvironmentVariable(named = "ASTRA_CLOUD_PROVIDER", matches = ".*")
@EnabledIfEnvironmentVariable(named = "ASTRA_CLOUD_REGION", matches = ".*")
@TestMethodOrder(MethodOrderer.OrderAnnotation.class)
class AstraProdDevopsITTest extends AbstractAstraDBAdminTest {

private static final String TMP_VECTOR_DB = "astra_db_admin_test";
private static final String TMP_VECTOR_DB2 = "astra_db_admin_test2";

@Override
protected AstraEnvironment getAstraEnvironment() {
return AstraEnvironment.PROD;
}

@Override
protected CloudProviderType getCloudProvider() {
return null;
return CloudProviderType.valueOf(System.getenv("ASTRA_CLOUD_PROVIDER"));
}

@Override
protected String getRegion() {
return "";
}

@Test
@Order(1)
void shouldConnectToDatabase() {
// Given
Assertions.assertNotNull(getAstraDbAdmin());

// Create a DB
Assertions.assertFalse(getAstraDbAdmin().databaseExists(TMP_VECTOR_DB));
DatabaseAdmin dbAdmin = getAstraDbAdmin()
.createDatabase(TMP_VECTOR_DB, CloudProviderType.GCP, "us-east1");

// List DBs
assertThat(getAstraDbAdmin().listDatabaseNames()).contains(TMP_VECTOR_DB);
assertThat(getAstraDbAdmin().databaseExists(TMP_VECTOR_DB)).isTrue();

Optional<DatabaseInfo> info = getAstraDbAdmin().listDatabases()
.stream().filter(db -> db.getName().equals(TMP_VECTOR_DB)).findFirst();

// Access DB
assertThat(info).isPresent();
assertThat(info.get().getName()).isEqualTo(TMP_VECTOR_DB);
UUID databaseId = info.get().getId();
Database db = getAstraDbAdmin().getDatabase(databaseId);
Assertions.assertNotNull(db);
assertThat(getAstraDbAdmin().databaseExists(databaseId)).isTrue();

// Delete DB
getAstraDbAdmin().dropDatabase(databaseId);
}

@Test
@Order(2)
void shouldCreateOtherDatabase() {
Assertions.assertFalse(getAstraDbAdmin().databaseExists(TMP_VECTOR_DB2));
DatabaseAdmin dbAdmin = getAstraDbAdmin().createDatabase(TMP_VECTOR_DB2);
AstraDBDatabaseAdmin dbAmin2 = (AstraDBDatabaseAdmin) dbAdmin;
UUID databaseId = UUID.fromString(dbAmin2.getDatabaseInformations().getId());

Optional<String> oToken = Utils.readEnvVariable("ASTRA_DB_APPLICATION_TOKEN");
assertThat(oToken).isPresent();
DataAPIClient client = new DataAPIClient(oToken.get());
assertThat(client.getDatabase(databaseId)).isNotNull();
assertThat(client.getDatabase(databaseId, "default_keyspace")).isNotNull();

Assertions.assertTrue(getAstraDbAdmin().databaseExists(TMP_VECTOR_DB2));
getAstraDbAdmin().dropDatabase(TMP_VECTOR_DB2);
return System.getenv("ASTRA_CLOUD_REGION");
}



}

0 comments on commit 0ffc7fa

Please sign in to comment.