@Override public DbDeployerAppContext cleanEnvironment() { return delegate.cleanEnvironment(); }
@Override public DbDeployerAppContext cleanEnvironment() { return delegate.cleanEnvironment(); }
@Override public void value(DbEnvironment dbEnvironment) { dbEnvironment.buildAppContext() .setupEnvInfra().cleanEnvironment() .deploy(); } });
@Test @Ignore("Ignoring re-deploy in the flow") public void testRedeploy() { File outputDir = new File("./target/outputReveng/final"); DbEnvironment prod = DbEnvironmentFactory.getInstance().readOneFromSourcePath(outputDir.getPath(), "prod"); prod.setCleanBuildAllowed(true); prod.buildAppContext("deploybuilddbo", "deploybuilddb0") .cleanEnvironment() .deploy(); } }
@Test @Ignore("Ignoring re-deploy in the flow") public void testRedeploy() { File outputDir = new File("./target/outputReveng/final"); DbEnvironment prod = DbEnvironmentFactory.getInstance().readOneFromSourcePath(outputDir.getPath(), "prod"); prod.setCleanBuildAllowed(true); prod.buildAppContext("deploybuilddbo", "deploybuilddb0") .cleanEnvironment() .deploy(); } }
@Test public void testIQ_Ver_15_4() { DbDeployerAppContext dbDeployerAppContext = getAppContext.valueOf(1); dbDeployerAppContext .cleanEnvironment() .setupEnvInfra() .deploy(); // TODO add an assertion against the DB that a table did get created } }
@Test public void testIQ_Ver_15_4() { DbDeployerAppContext dbDeployerAppContext = getAppContext.valueOf(1); dbDeployerAppContext .cleanEnvironment() .setupEnvInfra() .deploy(); // TODO add an assertion against the DB that a table did get created } }
@Test public void testThatDeploySucceedsWithWarningsIfGrantsFail() { DbDeployerAppContext dbDeployerAppContext = DbEnvironmentFactory.getInstance() .readOneFromSourcePath("scenariotests/permsynctest/step1") .buildAppContext() .setupEnvInfra().cleanEnvironment(); dbDeployerAppContext.deploy(); // TODO add validations around the grants } }
@Test public void testDeploy() throws Exception { getAppContext.valueOf(1) .setupEnvInfra() .setupEnvInfra() .cleanEnvironment() .deploy(); // ensuring that we can modify DbDeployerAppContext dbDeployerAppContext = getAppContext.valueOf(2); dbDeployerAppContext .cleanEnvironment() .setupEnvInfra() .deploy(); JdbcHelper jdbc = new JdbcHelper(); Connection conn = ds.getConnection(); try { List<Map<String, Object>> results = jdbc.queryForList(conn, "select * from " + dbDeployerAppContext.getEnvironment().getPhysicalSchema("schema1") + ".TABLE_A order by a_id"); assertEquals(3, results.size()); this.validateResults(results.get(0), 2, 3, "fasdfasd", "2013-02-02 11:11:11.65432", 9); this.validateResults(results.get(1), 3, 4, "ABC", null, 9); this.validateResults(results.get(2), 4, 2, "ABC", "2012-01-01 12:12:12", null); } finally { DbUtils.closeQuietly(conn); } }
/** * builds a base environment w/ tables but without the audit table so that we can simulate the auto-init behavior. */ private void setupPreExistingEnvironmentForAutoInitTests() { DbDeployerAppContext dbDeployerAppContext = DbEnvironmentFactory.getInstance().readOneFromSourcePath("./src/test/resources/scenariotests/initusecase/step1") .buildAppContext("abc", "abc"); dbDeployerAppContext.setupEnvInfra().cleanEnvironment() .deploy(); jdbc.update(conn, "DROP TABLE SCHEMA1.ARTIFACTDEPLOYMENT"); } }
@Ignore("Not yet trying this out") @Test public void verifyThatReverseEngineeredSqlCanBeDeployed() { DbEnvironment prod = DbEnvironmentFactory.getInstance().readOneFromSourcePath("./target/outputReveng", "prod"); prod.setCleanBuildAllowed(true); prod.buildAppContext("deploybuilddbo", "deploybuilddb0") .cleanEnvironment() .deploy(); } }
@Test @Override public void testReverseEngineeringFromFile() throws Exception { AquaRevengArgs args = new AquaRevengArgs(); args.setDbSchema("MYSCHEMA01"); args.setGenerateBaseline(false); args.setJdbcUrl("jdbc:hsqldb:mem:hsqldbreveng"); args.setUsername("myuser"); args.setPassword("mypass"); File outputDir = new File("./target/outputReveng"); FileUtils.deleteDirectory(outputDir); args.setOutputPath(outputDir); args.setInputPath(new File("./src/test/resources/reveng/hsql/input.sql")); new HsqlDbPlatform().getDdlReveng().reveng(args); DirectoryAssert.assertDirectoriesEqual(new File("./src/test/resources/reveng/hsql/expected"), new File(outputDir, "final")); // Ensure that we can still build the schema that was reverse engineered DbEnvironment prod = DbEnvironmentFactory.getInstance().readOneFromSourcePath(new File(outputDir, "final").getAbsolutePath(), "prod"); prod.setCleanBuildAllowed(true); prod.buildAppContext("sa", "") .setupEnvInfra() .cleanEnvironment() .deploy(); } }
@Test public void testBaselineScenario() { LOG.info("Step 1: Setting up the initial deployment version"); DbEnvironmentFactory.getInstance().readOneFromSourcePath("scenariotests/baseline-scenario/step1", "test") .buildAppContext() .setupEnvInfra().cleanEnvironment() .deploy(); LOG.info("Step 2: Performing the baseline (chng1 chng2 chng3 go away from the baseline) and chng4 is added"); DbEnvironmentFactory.getInstance().readOneFromSourcePath("scenariotests/baseline-scenario/step2", "test") .buildAppContext() .deploy(); LOG.info("Step 3: Doing 1 more change on TABLE_A after the baseline, w/ the baseline entries removed (no longer needed)"); DbEnvironmentFactory.getInstance().readOneFromSourcePath("scenariotests/baseline-scenario/step3", "test") .buildAppContext() .deploy(); // TODO add some assertions } }
@Test public void testChangesetAppliedAtOnce() { DbDeployerAppContext dbDeployerAppContext = DbEnvironmentFactory.getInstance() .readOneFromSourcePath("scenariotests/changesetDeploy/step1") .buildAppContext() .setupEnvInfra().cleanEnvironment(); dbDeployerAppContext.deploy(new MainDeployerArgs().allChangesets(true)); checkForIndex(dbDeployerAppContext, "TABLE_A", "TABLE_A_IND1", true); checkForIndex(dbDeployerAppContext, "TABLE_B", "TABLE_B_IND1", true); checkForIndex(dbDeployerAppContext, "TABLE_C", "TABLE_C_IND1", true); }
@Test public void testDeploy() { // step 1 - deploy the tables with FKs DbEnvironmentFactory.getInstance().readOneFromSourcePath("./src/test/resources/scenariotests/metadata-group/step1") .buildAppContext() .setupEnvInfra().cleanEnvironment() .deploy(); // step 2 - now deploy the metadata, ensure that the logic is fine DbEnvironmentFactory.getInstance().readOneFromSourcePath("./src/test/resources/scenariotests/metadata-group/step2") .buildAppContext() .deploy(); } }
@Test public void testFailureDeploy() { DbEnvironmentFactory.getInstance().readOneFromSourcePath("./src/test/resources/scenariotests/initusecase/step1") .buildAppContext("abc", "abc") .setupEnvInfra().cleanEnvironment() .deploy(); try { DbEnvironmentFactory.getInstance().readOneFromSourcePath("./src/test/resources/scenariotests/initusecase/step2") .buildAppContext("abc", "abc") .deploy(); // don't do init this time fail("Expecting a failure here as we have changed the files w/out doing the -performInitOnly step"); } catch (IllegalArgumentException expected) { } }
@Test public void testMigration() throws Exception { DbEnvironmentFactory.getInstance().readOneFromSourcePath("scenariotests/migration-example/step1", "test") .buildAppContext("sa", "") .setupEnvInfra() .cleanEnvironment() .deploy(); DbEnvironmentFactory.getInstance().readOneFromSourcePath("scenariotests/migration-example/step2", "test") .buildAppContext("sa", "") .deploy(); // Run it twice to ensure that we don't duplicate data DbDeployerAppContext context = DbEnvironmentFactory.getInstance().readOneFromSourcePath("scenariotests/migration-example/step2", "test") .buildAppContext("sa", "") .deploy(); this.validateInstance("MigrationExample", "SCHEMA1"); }
@Test public void testDeploy() { DbEnvironmentFactory.getInstance().readOneFromSourcePath("./src/test/resources/scenariotests/initusecase/step1") .buildAppContext("abc", "abc") .setupEnvInfra().cleanEnvironment() .deploy(); // TODO the SystemOutRule doesn't work w/ Maven, as no system output is captured // Leave this commented-code in; I REALLY would like to get this to work! // systemOutRule.enableLog(); DbEnvironmentFactory.getInstance().readOneFromSourcePath("./src/test/resources/scenariotests/initusecase/step2") .buildAppContext("abc", "abc") .deploy(new MainDeployerArgs().performInitOnly(true)); // init // validate that the warning message is getting printed out for doing an INIT when tables already exist // assertThat(systemOutRule.getLog(), containsString(DbDeployer.INIT_WARNING_MESSAGE)); DbEnvironmentFactory.getInstance().readOneFromSourcePath("./src/test/resources/scenariotests/initusecase/step2") .buildAppContext("abc", "abc") .deploy(); }
@Test public void testAseDeploy() throws Exception { DbDeployerAppContext step1Context = getAppContext.valueOf(1); step1Context .setupEnvInfra() .cleanEnvironment() .deploy(); String physicalSchemaStr = step1Context.getEnvironment().getPlatform().getSchemaPrefix(step1Context.getEnvironment().getPhysicalSchema("oats")); this.validateStep1(step1Context.getDataSource(), physicalSchemaStr, new JdbcHelper()); DbDeployerAppContext step2Context = getAppContext.valueOf(2); step2Context .setupEnvInfra() .deploy(); this.validateStep2(step2Context.getDataSource(), physicalSchemaStr, new JdbcHelper()); }
@Test public void testChangesetsAppliedInPhases() { DbDeployerAppContext dbDeployerAppContext = DbEnvironmentFactory.getInstance() .readOneFromSourcePath("scenariotests/changesetDeploy/step1") .buildAppContext() .setupEnvInfra().cleanEnvironment(); dbDeployerAppContext.deploy(); // in the default phase, all the checkForIndex(dbDeployerAppContext, "TABLE_A", "TABLE_A_IND1", false); checkForIndex(dbDeployerAppContext, "TABLE_B", "TABLE_B_IND1", false); checkForIndex(dbDeployerAppContext, "TABLE_C", "TABLE_C_IND1", false); dbDeployerAppContext.deploy(new MainDeployerArgs().changesetNames(Sets.immutable.with("phaseA"))); checkForIndex(dbDeployerAppContext, "TABLE_A", "TABLE_A_IND1", true); checkForIndex(dbDeployerAppContext, "TABLE_B", "TABLE_B_IND1", true); checkForIndex(dbDeployerAppContext, "TABLE_C", "TABLE_C_IND1", false); dbDeployerAppContext.deploy(new MainDeployerArgs().changesetNames(Sets.immutable.with("phaseB"))); checkForIndex(dbDeployerAppContext, "TABLE_A", "TABLE_A_IND1", true); checkForIndex(dbDeployerAppContext, "TABLE_B", "TABLE_B_IND1", true); checkForIndex(dbDeployerAppContext, "TABLE_C", "TABLE_C_IND1", true); }