https://www.programcreek.com/java-api-examples/?api=org.apache.tez.client.TezClient
void runDAGAndVerify(DAG dag, DAGStatus.State finalState,
TezClient session) throws Exception {
session.waitTillReady();
DAGClient dagClient = session.submitDAG(dag);
DAGStatus dagStatus = dagClient.getDAGStatus(null);
while (!dagStatus.isCompleted()) {
LOG.info("Waiting for dag to complete. Sleeping for 500ms."
+ " DAG name: " + dag.getName()
+ " DAG appId: " + dagClient.getApplicationId()
+ " Current state: " + dagStatus.getState());
Thread.sleep(100);
dagStatus = dagClient.getDAGStatus(null);
}
Assert.assertEquals(finalState, dagStatus.getState());
}