1
0

new-sql-dumps-after-prod-release (#181)

Co-authored-by: Michael Hoennig <michael@hoennig.de>
Reviewed-on: https://dev.hostsharing.net/hostsharing/hs.hsadmin.ng/pulls/181
Reviewed-by: Marc Sandlus <marc.sandlus@hostsharing.net>
This commit is contained in:
Michael Hoennig
2025-06-06 12:02:11 +02:00
parent d4e78f8a50
commit d351c9a2c1
4 changed files with 1352 additions and 953 deletions

View File

@@ -40,6 +40,7 @@ import org.springframework.test.annotation.Commit;
import org.springframework.test.annotation.DirtiesContext; import org.springframework.test.annotation.DirtiesContext;
import org.springframework.test.context.ActiveProfiles; import org.springframework.test.context.ActiveProfiles;
import java.io.File;
import java.io.IOException; import java.io.IOException;
import java.io.InputStream; import java.io.InputStream;
import java.io.Reader; import java.io.Reader;
@@ -138,7 +139,7 @@ public class ImportHostingAssets extends CsvDataImport {
@Autowired @Autowired
LiquibaseMigration liquibase; LiquibaseMigration liquibase;
@Value("${HSADMINNG_OFFICE_DATA_SQL_FILE:/db/released-only-prod-schema-with-import-test-data.sql}") @Value("${HSADMINNG_OFFICE_DATA_SQL_FILE:/db/released-prod-schema-with-import-test-data.sql}")
String officeSchemaAndDataSqlFile; String officeSchemaAndDataSqlFile;
@Test @Test
@@ -148,6 +149,7 @@ public class ImportHostingAssets extends CsvDataImport {
executeSqlScript(officeSchemaAndDataSqlFile); executeSqlScript(officeSchemaAndDataSqlFile);
liquibase.assertReferenceStatusAfterRestore(286, "hs-booking-SCHEMA"); liquibase.assertReferenceStatusAfterRestore(286, "hs-booking-SCHEMA");
makeSureThatTheImportAdminUserExists(); makeSureThatTheImportAdminUserExists();
PostgresTestcontainer.dump(jdbcUrl, new File("build/db/released-prod-schema-with-import-test-data.sql"));
liquibase.runWithContexts("migration", "without-test-data"); liquibase.runWithContexts("migration", "without-test-data");
liquibase.assertThatCurrentMigrationsGotApplied(331, "hs-booking-SCHEMA"); liquibase.assertThatCurrentMigrationsGotApplied(331, "hs-booking-SCHEMA");
} }

View File

@@ -43,11 +43,11 @@ import static org.springframework.test.context.jdbc.Sql.ExecutionPhase.BEFORE_TE
@DirtiesContext @DirtiesContext
@ActiveProfiles("liquibase-migration-test") @ActiveProfiles("liquibase-migration-test")
@Import(LiquibaseConfig.class) @Import(LiquibaseConfig.class)
@Sql(value = "/db/released-only-prod-schema-with-test-data.sql", executionPhase = BEFORE_TEST_CLASS) // release-schema @Sql(value = "/db/released-prod-schema-with-test-data.sql", executionPhase = BEFORE_TEST_CLASS) // release-schema
public class LiquibaseCompatibilityIntegrationTest { public class LiquibaseCompatibilityIntegrationTest {
private static final String EXPECTED_CHANGESET_ONLY_AFTER_NEW_MIGRATION = "hs-global-liquibase-migration-test"; private static final String EXPECTED_CHANGESET_ONLY_AFTER_NEW_MIGRATION = "hs-global-liquibase-migration-test";
private static final int EXPECTED_LIQUIBASE_CHANGELOGS_IN_PROD_SCHEMA_DUMP = 287; private static final int EXPECTED_LIQUIBASE_CHANGELOGS_IN_PROD_SCHEMA_DUMP = 299;
@Value("${spring.datasource.url}") @Value("${spring.datasource.url}")
private String jdbcUrl; private String jdbcUrl;
@@ -63,7 +63,7 @@ public class LiquibaseCompatibilityIntegrationTest {
// run the current migrations and dump the result to the build-directory // run the current migrations and dump the result to the build-directory
liquibase.runWithContexts("only-prod-schema", "with-test-data"); liquibase.runWithContexts("only-prod-schema", "with-test-data");
PostgresTestcontainer.dump(jdbcUrl, new File("build/db/released-only-prod-schema-with-test-data.sql")); PostgresTestcontainer.dump(jdbcUrl, new File("build/db/released-prod-schema-with-test-data.sql"));
// then add another migration and assert if it was applied // then add another migration and assert if it was applied
liquibase.runWithContexts("liquibase-migration-test"); liquibase.runWithContexts("liquibase-migration-test");