@@ -59,13 +59,18 @@ class BootloaderAppTest {
5959 private PostgreSQLContainer container ;
6060 private DataSource configsDataSource ;
6161 private DataSource jobsDataSource ;
62+ private static final String DOCKER = "docker" ;
63+ private static final String VERSION_0330_ALPHA = "0.33.0-alpha" ;
64+ private static final String VERSION_0320_ALPHA = "0.32.0-alpha" ;
65+ private static final String VERSION_0321_ALPHA = "0.32.1-alpha" ;
66+ private static final String VERSION_0170_ALPHA = "0.17.0-alpha" ;
6267
6368 @ BeforeEach
6469 void setup () {
6570 container = new PostgreSQLContainer <>("postgres:13-alpine" )
6671 .withDatabaseName ("public" )
67- .withUsername ("docker" )
68- .withPassword ("docker" );
72+ .withUsername (DOCKER )
73+ .withPassword (DOCKER );
6974 container .start ();
7075
7176 configsDataSource =
@@ -86,16 +91,14 @@ void cleanup() throws Exception {
8691
8792 @ Test
8893 void testBootloaderAppBlankDb () throws Exception {
89- val version = "0.33.0-alpha" ;
90-
9194 val mockedConfigs = mock (Configs .class );
9295 when (mockedConfigs .getConfigDatabaseUrl ()).thenReturn (container .getJdbcUrl ());
9396 when (mockedConfigs .getConfigDatabaseUser ()).thenReturn (container .getUsername ());
9497 when (mockedConfigs .getConfigDatabasePassword ()).thenReturn (container .getPassword ());
9598 when (mockedConfigs .getDatabaseUrl ()).thenReturn (container .getJdbcUrl ());
9699 when (mockedConfigs .getDatabaseUser ()).thenReturn (container .getUsername ());
97100 when (mockedConfigs .getDatabasePassword ()).thenReturn (container .getPassword ());
98- when (mockedConfigs .getAirbyteVersion ()).thenReturn (new AirbyteVersion (version ));
101+ when (mockedConfigs .getAirbyteVersion ()).thenReturn (new AirbyteVersion (VERSION_0330_ALPHA ));
99102 when (mockedConfigs .runDatabaseMigrationOnStartup ()).thenReturn (true );
100103 when (mockedConfigs .getConfigsDatabaseInitializationTimeoutMs ()).thenReturn (60000L );
101104 when (mockedConfigs .getJobsDatabaseInitializationTimeoutMs ()).thenReturn (60000L );
@@ -107,8 +110,8 @@ void testBootloaderAppBlankDb() throws Exception {
107110 // Although we are able to inject mocked configs into the Bootloader, a particular migration in the
108111 // configs database
109112 // requires the env var to be set. Flyway prevents injection, so we dynamically set this instead.
110- environmentVariables .set ("DATABASE_USER" , "docker" );
111- environmentVariables .set ("DATABASE_PASSWORD" , "docker" );
113+ environmentVariables .set ("DATABASE_USER" , DOCKER );
114+ environmentVariables .set ("DATABASE_PASSWORD" , DOCKER );
112115 environmentVariables .set ("DATABASE_URL" , container .getJdbcUrl ());
113116
114117 try (val configsDslContext = DSLContextFactory .create (configsDataSource , SQLDialect .POSTGRES );
@@ -133,24 +136,22 @@ void testBootloaderAppBlankDb() throws Exception {
133136 assertEquals ("0.39.17.001" , configsMigrator .getLatestMigration ().getVersion ().getVersion ());
134137
135138 val jobsPersistence = new DefaultJobPersistence (jobDatabase );
136- assertEquals (version , jobsPersistence .getVersion ().get ());
139+ assertEquals (VERSION_0330_ALPHA , jobsPersistence .getVersion ().get ());
137140
138141 assertNotEquals (Optional .empty (), jobsPersistence .getDeployment ().get ());
139142 }
140143 }
141144
142145 @ Test
143146 void testBootloaderAppRunSecretMigration () throws Exception {
144- val version = "0.33.0-alpha" ;
145-
146147 val mockedConfigs = mock (Configs .class );
147148 when (mockedConfigs .getConfigDatabaseUrl ()).thenReturn (container .getJdbcUrl ());
148149 when (mockedConfigs .getConfigDatabaseUser ()).thenReturn (container .getUsername ());
149150 when (mockedConfigs .getConfigDatabasePassword ()).thenReturn (container .getPassword ());
150151 when (mockedConfigs .getDatabaseUrl ()).thenReturn (container .getJdbcUrl ());
151152 when (mockedConfigs .getDatabaseUser ()).thenReturn (container .getUsername ());
152153 when (mockedConfigs .getDatabasePassword ()).thenReturn (container .getPassword ());
153- when (mockedConfigs .getAirbyteVersion ()).thenReturn (new AirbyteVersion (version ));
154+ when (mockedConfigs .getAirbyteVersion ()).thenReturn (new AirbyteVersion (VERSION_0330_ALPHA ));
154155 when (mockedConfigs .runDatabaseMigrationOnStartup ()).thenReturn (true );
155156 when (mockedConfigs .getSecretPersistenceType ()).thenReturn (TESTING_CONFIG_DB_TABLE );
156157 when (mockedConfigs .getConfigsDatabaseInitializationTimeoutMs ()).thenReturn (60000L );
@@ -181,8 +182,8 @@ void testBootloaderAppRunSecretMigration() throws Exception {
181182 // Although we are able to inject mocked configs into the Bootloader, a particular migration in the
182183 // configs database requires the env var to be set. Flyway prevents injection, so we dynamically set
183184 // this instead.
184- environmentVariables .set ("DATABASE_USER" , "docker" );
185- environmentVariables .set ("DATABASE_PASSWORD" , "docker" );
185+ environmentVariables .set ("DATABASE_USER" , DOCKER );
186+ environmentVariables .set ("DATABASE_PASSWORD" , DOCKER );
186187 environmentVariables .set ("DATABASE_URL" , container .getJdbcUrl ());
187188
188189 // Bootstrap the database for the test
@@ -265,37 +266,35 @@ void testBootloaderAppRunSecretMigration() throws Exception {
265266 void testIsLegalUpgradePredicate () {
266267 // starting from no previous version is always legal.
267268 assertTrue (BootloaderApp .isLegalUpgrade (null , new AirbyteVersion ("0.17.1-alpha" )));
268- assertTrue (BootloaderApp .isLegalUpgrade (null , new AirbyteVersion ("0.32.0-alpha" )));
269- assertTrue (BootloaderApp .isLegalUpgrade (null , new AirbyteVersion ("0.32.1-alpha" )));
269+ assertTrue (BootloaderApp .isLegalUpgrade (null , new AirbyteVersion (VERSION_0320_ALPHA )));
270+ assertTrue (BootloaderApp .isLegalUpgrade (null , new AirbyteVersion (VERSION_0321_ALPHA )));
270271 assertTrue (BootloaderApp .isLegalUpgrade (null , new AirbyteVersion ("0.33.1-alpha" )));
271272 // starting from a version that is pre-breaking migration cannot go past the breaking migration.
272- assertTrue (BootloaderApp .isLegalUpgrade (new AirbyteVersion ("0.17.0-alpha" ), new AirbyteVersion ("0.17.1-alpha" )));
273- assertTrue (BootloaderApp .isLegalUpgrade (new AirbyteVersion ("0.17.0-alpha" ), new AirbyteVersion ("0.18.0-alpha" )));
274- assertTrue (BootloaderApp .isLegalUpgrade (new AirbyteVersion ("0.17.0-alpha" ), new AirbyteVersion ("0.32.0-alpha" )));
275- assertFalse (BootloaderApp .isLegalUpgrade (new AirbyteVersion ("0.17.0-alpha" ), new AirbyteVersion ("0.32.1-alpha" )));
276- assertFalse (BootloaderApp .isLegalUpgrade (new AirbyteVersion ("0.17.0-alpha" ), new AirbyteVersion ("0.33.0-alpha" )));
273+ assertTrue (BootloaderApp .isLegalUpgrade (new AirbyteVersion (VERSION_0170_ALPHA ), new AirbyteVersion ("0.17.1-alpha" )));
274+ assertTrue (BootloaderApp .isLegalUpgrade (new AirbyteVersion (VERSION_0170_ALPHA ), new AirbyteVersion ("0.18.0-alpha" )));
275+ assertTrue (BootloaderApp .isLegalUpgrade (new AirbyteVersion (VERSION_0170_ALPHA ), new AirbyteVersion (VERSION_0320_ALPHA )));
276+ assertFalse (BootloaderApp .isLegalUpgrade (new AirbyteVersion (VERSION_0170_ALPHA ), new AirbyteVersion (VERSION_0321_ALPHA )));
277+ assertFalse (BootloaderApp .isLegalUpgrade (new AirbyteVersion (VERSION_0170_ALPHA ), new AirbyteVersion (VERSION_0330_ALPHA )));
277278 // any migration starting at the breaking migration or after it can upgrade to anything.
278- assertTrue (BootloaderApp .isLegalUpgrade (new AirbyteVersion ("0.32.0-alpha" ), new AirbyteVersion ("0.32.1-alpha" )));
279- assertTrue (BootloaderApp .isLegalUpgrade (new AirbyteVersion ("0.32.0-alpha" ), new AirbyteVersion ("0.33.0-alpha" )));
280- assertTrue (BootloaderApp .isLegalUpgrade (new AirbyteVersion ("0.32.1-alpha" ), new AirbyteVersion ("0.32.1-alpha" )));
281- assertTrue (BootloaderApp .isLegalUpgrade (new AirbyteVersion ("0.32.1-alpha" ), new AirbyteVersion ("0.33.0-alpha" )));
282- assertTrue (BootloaderApp .isLegalUpgrade (new AirbyteVersion ("0.33.0-alpha" ), new AirbyteVersion ("0.33.1-alpha" )));
283- assertTrue (BootloaderApp .isLegalUpgrade (new AirbyteVersion ("0.33.0-alpha" ), new AirbyteVersion ("0.34.0-alpha" )));
279+ assertTrue (BootloaderApp .isLegalUpgrade (new AirbyteVersion (VERSION_0320_ALPHA ), new AirbyteVersion (VERSION_0321_ALPHA )));
280+ assertTrue (BootloaderApp .isLegalUpgrade (new AirbyteVersion (VERSION_0320_ALPHA ), new AirbyteVersion (VERSION_0330_ALPHA )));
281+ assertTrue (BootloaderApp .isLegalUpgrade (new AirbyteVersion (VERSION_0321_ALPHA ), new AirbyteVersion (VERSION_0321_ALPHA )));
282+ assertTrue (BootloaderApp .isLegalUpgrade (new AirbyteVersion (VERSION_0321_ALPHA ), new AirbyteVersion (VERSION_0330_ALPHA )));
283+ assertTrue (BootloaderApp .isLegalUpgrade (new AirbyteVersion (VERSION_0330_ALPHA ), new AirbyteVersion ("0.33.1-alpha" )));
284+ assertTrue (BootloaderApp .isLegalUpgrade (new AirbyteVersion (VERSION_0330_ALPHA ), new AirbyteVersion ("0.34.0-alpha" )));
284285 }
285286
286287 @ Test
287288 void testPostLoadExecutionExecutes () throws Exception {
288289 final var testTriggered = new AtomicBoolean ();
289- val version = "0.33.0-alpha" ;
290-
291290 val mockedConfigs = mock (Configs .class );
292291 when (mockedConfigs .getConfigDatabaseUrl ()).thenReturn (container .getJdbcUrl ());
293292 when (mockedConfigs .getConfigDatabaseUser ()).thenReturn (container .getUsername ());
294293 when (mockedConfigs .getConfigDatabasePassword ()).thenReturn (container .getPassword ());
295294 when (mockedConfigs .getDatabaseUrl ()).thenReturn (container .getJdbcUrl ());
296295 when (mockedConfigs .getDatabaseUser ()).thenReturn (container .getUsername ());
297296 when (mockedConfigs .getDatabasePassword ()).thenReturn (container .getPassword ());
298- when (mockedConfigs .getAirbyteVersion ()).thenReturn (new AirbyteVersion (version ));
297+ when (mockedConfigs .getAirbyteVersion ()).thenReturn (new AirbyteVersion (VERSION_0330_ALPHA ));
299298 when (mockedConfigs .runDatabaseMigrationOnStartup ()).thenReturn (true );
300299 when (mockedConfigs .getConfigsDatabaseInitializationTimeoutMs ()).thenReturn (60000L );
301300 when (mockedConfigs .getJobsDatabaseInitializationTimeoutMs ()).thenReturn (60000L );
0 commit comments