AzkabanDatabaseUpdater { public static void main(final String[] args) throws Exception { final OptionParser parser = new OptionParser(); final OptionSpec<String> scriptDirectory = parser .acceptsAll(Arrays.asList("s", "script"), "Directory of update scripts.").withRequiredArg() .describedAs("script").ofType(String.class); final OptionSpec<Void> updateOption = parser.acceptsAll(Arrays.asList("u", "update"), "Will update if necessary"); final Props props = AzkabanServer.loadProps(args, parser); if (props == null) { logger.error("Properties not found. Need it to connect to the db."); logger.error("Exiting..."); return; } final OptionSet options = parser.parse(args); boolean updateDB = false; if (options.has(updateOption)) { updateDB = true; } else { logger.info("Running DatabaseUpdater in test mode"); } String scriptDir = "sql"; if (options.has(scriptDirectory)) { scriptDir = options.valueOf(scriptDirectory); } runDatabaseUpdater(props, scriptDir, updateDB); }  static void main(final String[] args); static void runDatabaseUpdater(final Props props, final String sqlDir,
      final boolean updateDB);  }
@Ignore @Test public void testMySQLAutoCreate() throws Exception { clearMySQLTestDb(); final URL resourceUrl = Resources.getResource("conf/dbtestmysql"); assertNotNull(resourceUrl); final File resource = new File(resourceUrl.toURI()); final String confDir = resource.getParent(); System.out.println("1.***Now testing check"); AzkabanDatabaseUpdater.main(new String[]{"-c", confDir}); System.out.println("2.***Now testing update"); AzkabanDatabaseUpdater.main(new String[]{"-u", "-c", confDir}); System.out.println("3.***Now testing check again"); AzkabanDatabaseUpdater.main(new String[]{"-c", confDir}); System.out.println("4.***Now testing update again"); AzkabanDatabaseUpdater.main(new String[]{"-c", confDir, "-u"}); System.out.println("5.***Now testing check again"); AzkabanDatabaseUpdater.main(new String[]{"-c", confDir}); }
@Test public void testH2AutoCreate() throws Exception { final URL resourceUrl = Resources.getResource("conf/dbtesth2"); assertNotNull(resourceUrl); final File resource = new File(resourceUrl.toURI()); final String confDir = resource.getParent(); System.out.println("1.***Now testing check"); AzkabanDatabaseUpdater.main(new String[]{"-c", confDir}); System.out.println("2.***Now testing update"); AzkabanDatabaseUpdater.main(new String[]{"-u", "-c", confDir}); System.out.println("3.***Now testing check again"); AzkabanDatabaseUpdater.main(new String[]{"-c", confDir}); System.out.println("4.***Now testing update again"); AzkabanDatabaseUpdater.main(new String[]{"-c", confDir, "-u"}); System.out.println("5.***Now testing check again"); AzkabanDatabaseUpdater.main(new String[]{"-c", confDir}); }