private void runTest(boolean local, TestFunction test) throws Exception { Properties conf = createConf(local); LivyClient client = null; try { test.config(conf); client = new LivyClientBuilder(new URI("local:spark")).setAll(conf).build(); test.call(client); } finally { if (client != null) { client.stop(); } } }