Skip to content

Commit 93c9b6a

Browse files
committed
Revert "Debug migration acceptance test"
This reverts commit 3fd8f2b.
1 parent c67d2fc commit 93c9b6a

File tree

3 files changed

+31
-10
lines changed

3 files changed

+31
-10
lines changed

airbyte-migration/src/main/java/io/airbyte/migrate/Migrate.java

+11-3
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,7 @@
3636
import io.airbyte.commons.version.AirbyteVersion;
3737
import io.airbyte.commons.yaml.Yamls;
3838
import io.airbyte.validation.json.JsonSchemaValidator;
39+
import io.airbyte.validation.json.JsonValidationException;
3940
import java.io.BufferedWriter;
4041
import java.io.File;
4142
import java.io.FileWriter;
@@ -108,9 +109,8 @@ public void run(MigrateConfig migrateConfig) throws IOException {
108109
// run migration
109110
// write output of each migration to disk.
110111
final Migration migration = migrations.get(i);
111-
LOGGER.info("Migrating from {} to {}", migrations.get(i - 1).getVersion(), migration.getVersion());
112+
LOGGER.info("Migrating from version: {} to version {}.", migrations.get(i - 1).getVersion(), migration.getVersion());
112113
final Path outputPath = runMigration(migration, inputPath);
113-
LOGGER.info("Migration completed from {} to {}", migrations.get(i - 1).getVersion(), migration.getVersion());
114114
IOs.writeFile(outputPath.resolve(VERSION_FILE_NAME), migration.getVersion());
115115
inputPath = outputPath;
116116
}
@@ -131,7 +131,15 @@ private Path runMigration(Migration migration, Path migrationInputRoot) throws I
131131
final Map<ResourceId, Stream<JsonNode>> inputDataStreams = inputData.entrySet().stream()
132132
.collect(Collectors.toMap(
133133
Map.Entry::getKey,
134-
entry -> MoreStreams.toStream(entry.getValue())));
134+
entry -> MoreStreams.toStream(entry.getValue())
135+
.peek(r -> {
136+
try {
137+
jsonSchemaValidator.ensure(migration.getInputSchema().get(entry.getKey()), r);
138+
} catch (JsonValidationException e) {
139+
throw new IllegalArgumentException(
140+
String.format("Input data schema does not match declared input schema %s.", entry.getKey().getName()), e);
141+
}
142+
})));
135143

136144
final Map<ResourceId, RecordConsumer> outputStreams = createOutputStreams(migration, tmpOutputDir);
137145
// make the java compiler happy (it can't resolve that RecordConsumer is, in fact, a

airbyte-scheduler/persistence/src/main/java/io/airbyte/scheduler/persistence/DefaultJobPersistence.java

-2
Original file line numberDiff line numberDiff line change
@@ -636,8 +636,6 @@ private Stream<JsonNode> exportTable(final String schema, final String tableName
636636
.map(Field::getName)
637637
.collect(Collectors.toSet());
638638
final JsonNode row = Jsons.deserialize(record.formatJSON(DB_JSON_FORMAT));
639-
System.out.println("Json row: " + row);
640-
LOGGER.info("Json row: {}", row);
641639
// for json fields, deserialize them so they are treated as objects instead of strings. this is to
642640
// get around that formatJson doesn't handle deserializing them for us.
643641
jsonFieldNames.forEach(jsonFieldName -> ((ObjectNode) row).replace(jsonFieldName, Jsons.deserialize(row.get(jsonFieldName).asText())));

airbyte-tests/src/automaticMigrationAcceptanceTest/java/io/airbyte/test/automaticMigrationAcceptance/MigrationAcceptanceTest.java

+20-5
Original file line numberDiff line numberDiff line change
@@ -51,12 +51,14 @@
5151
import io.airbyte.commons.version.AirbyteVersion;
5252
import io.airbyte.test.airbyte_test_container.AirbyteTestContainer;
5353
import java.io.File;
54+
import java.io.FileInputStream;
5455
import java.net.URISyntaxException;
5556
import java.nio.file.Path;
5657
import java.util.HashMap;
5758
import java.util.HashSet;
5859
import java.util.List;
5960
import java.util.Map;
61+
import java.util.Properties;
6062
import java.util.Set;
6163
import java.util.function.Consumer;
6264
import org.junit.jupiter.api.Test;
@@ -77,15 +79,29 @@ public class MigrationAcceptanceTest {
7779

7880
@Test
7981
public void testAutomaticMigration() throws Exception {
80-
final String targetVersion = "0.29.16-alpha";
82+
// default to version in env file but can override it.
83+
final String targetVersion;
84+
if (System.getenv("MIGRATION_TEST_VERSION") != null) {
85+
targetVersion = System.getenv("MIGRATION_TEST_VERSION");
86+
} else {
87+
final Properties prop = new Properties();
88+
prop.load(new FileInputStream(ENV_FILE));
89+
targetVersion = prop.getProperty("VERSION");
90+
}
8191
LOGGER.info("Using version: {} as target version", targetVersion);
8292

8393
firstRun();
8494
secondRun(targetVersion);
8595
}
8696

8797
private Consumer<String> logConsumerForServer(Set<String> expectedLogs) {
88-
return logLine -> expectedLogs.removeIf(logLine::contains);
98+
return logLine -> expectedLogs.removeIf(entry -> {
99+
if (logLine.contains("Migrating from version")) {
100+
System.out.println("logLine = " + logLine);
101+
System.out.println("logLine = " + logLine);
102+
}
103+
return logLine.contains(entry);
104+
});
89105
}
90106

91107
@SuppressWarnings("UnstableApiUsage")
@@ -117,6 +133,7 @@ private String targetVersionWithoutPatch(String targetVersion) {
117133
return AirbyteVersion.versionWithoutPatch(targetVersion).getVersion();
118134
}
119135

136+
@SuppressWarnings("UnstableApiUsage")
120137
private void secondRun(String targetVersion) throws Exception {
121138
final Set<String> logsToExpect = new HashSet<>();
122139
logsToExpect.add("Version: " + targetVersion);
@@ -128,16 +145,14 @@ private void secondRun(String targetVersion) throws Exception {
128145
logsToExpect.add("Migrating from version: 0.22.0-alpha to version 0.23.0-alpha.");
129146
logsToExpect.add("Migrations complete. Now on version: " + targetVersionWithoutPatch(targetVersion));
130147

131-
final File dockerComposeFile = Path.of(System.getProperty("user.dir")).getParent().resolve("docker-compose.yaml").toFile();
132-
final AirbyteTestContainer airbyteTestContainer = new AirbyteTestContainer.Builder(dockerComposeFile)
148+
final AirbyteTestContainer airbyteTestContainer = new AirbyteTestContainer.Builder(new File(Resources.getResource("docker-compose.yaml").toURI()))
133149
.setEnv(ENV_FILE)
134150
// override to use test mounts.
135151
.setEnvVariable("DATA_DOCKER_MOUNT", "airbyte_data_migration_test")
136152
.setEnvVariable("DB_DOCKER_MOUNT", "airbyte_db_migration_test")
137153
.setEnvVariable("WORKSPACE_DOCKER_MOUNT", "airbyte_workspace_migration_test")
138154
.setEnvVariable("LOCAL_ROOT", "/tmp/airbyte_local_migration_test")
139155
.setEnvVariable("LOCAL_DOCKER_MOUNT", "/tmp/airbyte_local_migration_test")
140-
.setEnvVariable("VERSION", targetVersion)
141156
.setLogListener("server", logConsumerForServer(logsToExpect))
142157
.build();
143158

0 commit comments

Comments
 (0)