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

14899 Update tests instance type to ATLAS #15436

Merged
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 @@ -4,7 +4,6 @@

package io.airbyte.integrations.source.mongodb;

import static io.airbyte.db.mongodb.MongoUtils.MongoInstanceType.STANDALONE;
import static org.junit.jupiter.api.Assertions.assertEquals;

import com.fasterxml.jackson.databind.JsonNode;
Expand All @@ -15,6 +14,7 @@
import io.airbyte.commons.resources.MoreResources;
import io.airbyte.db.jdbc.JdbcUtils;
import io.airbyte.db.mongodb.MongoDatabase;
import io.airbyte.db.mongodb.MongoUtils.MongoInstanceType;
import io.airbyte.integrations.standardtest.source.SourceAcceptanceTest;
import io.airbyte.integrations.standardtest.source.TestDestinationEnv;
import io.airbyte.protocol.models.CatalogHelpers;
Expand All @@ -36,10 +36,10 @@

public class MongodbSourceStrictEncryptAcceptanceTest extends SourceAcceptanceTest {

private static final String DATABASE_NAME = "test";
private static final String COLLECTION_NAME = "acceptance_test";
private static final Path CREDENTIALS_PATH = Path.of("secrets/credentials.json");

protected static final String DATABASE_NAME = "test";
protected static final String COLLECTION_NAME = "acceptance_test";
private static final String INSTANCE_TYPE = "instance_type";

protected JsonNode config;
protected MongoDatabase database;
Expand All @@ -66,24 +66,23 @@ protected void setupEnvironment(final TestDestinationEnv environment) throws Exc
final JsonNode credentialsJson = Jsons.deserialize(credentialsJsonString);

final JsonNode instanceConfig = Jsons.jsonNode(ImmutableMap.builder()
.put("instance", STANDALONE.getType())
.put(JdbcUtils.HOST_KEY, credentialsJson.get(JdbcUtils.HOST_KEY).asText())
.put(JdbcUtils.PORT_KEY, credentialsJson.get(JdbcUtils.PORT_KEY).asInt())
.put("instance", MongoInstanceType.ATLAS.getType())
.put("cluster_url", credentialsJson.get("cluster_url").asText())
.build());

config = Jsons.jsonNode(ImmutableMap.builder()
.put("user", credentialsJson.get("user").asText())
.put(JdbcUtils.PASSWORD_KEY, credentialsJson.get(JdbcUtils.PASSWORD_KEY).asText())
.put("instance_type", instanceConfig)
.put(INSTANCE_TYPE, instanceConfig)
.put(JdbcUtils.DATABASE_KEY, DATABASE_NAME)
.put("auth_source", "admin")
.build());

final String connectionString = String.format("mongodb://%s:%s@%s:%s/%s?authSource=admin&directConnection=false&ssl=true",
config.get("user").asText(),
config.get(JdbcUtils.PASSWORD_KEY).asText(),
config.get("instance_type").get(JdbcUtils.HOST_KEY).asText(),
config.get("instance_type").get(JdbcUtils.PORT_KEY).asText(),
var credentials = String.format("%s:%s@", config.get("user").asText(),
config.get(JdbcUtils.PASSWORD_KEY).asText());
final String connectionString = String.format("mongodb+srv://%s%s/%s?retryWrites=true&w=majority&tls=true",
credentials,
config.get(INSTANCE_TYPE).get("cluster_url").asText(),
config.get(JdbcUtils.DATABASE_KEY).asText());

database = new MongoDatabase(connectionString, DATABASE_NAME);
Expand All @@ -101,7 +100,9 @@ protected void setupEnvironment(final TestDestinationEnv environment) throws Exc

@Override
protected void tearDown(final TestDestinationEnv testEnv) throws Exception {
database.getDatabase().getCollection(COLLECTION_NAME).drop();
for (final String collectionName : database.getCollectionNames()) {
database.getDatabase().getCollection(collectionName).drop();
}
database.close();
}

Expand Down