@Test
  public void testYarnATSGuid() throws Exception {
    String udfName = SleepMsUDF.class.getName();
    Statement stmt1 = con.createStatement();
    stmt1.execute("create temporary function sleepMsUDF as '" + udfName + "'");
    stmt1.close();
    final Statement stmt = con.createStatement();
    final Holder<Boolean> yarnATSGuidSet = new Holder<Boolean>() {
      public Boolean b = false;

      public void set(Boolean b) {
        this.b = b;
      }

      public Boolean get() {
        return this.b;
      }
    };

    // Thread executing the query
    Thread tExecute = new Thread(new Runnable() {
      @Override
      public void run() {
        try {
          // The test table has 500 rows, so total query time should be ~ 500*1ms
          System.out.println("Executing query: ");
          stmt.executeQuery("select sleepMsUDF(t1.under_col, 1) as u0, t1.under_col as u1, "
              + "t2.under_col as u2 from " + tableName + " t1 join " + tableName
              + " t2 on t1.under_col = t2.under_col");
        } catch (SQLException e) {
          // No op
        }
      }
    });
    // Thread reading the ATS GUID
    Thread tGuid = new Thread(new Runnable() {
      @Override
      public void run() {
        while (true) {
          try {
            Thread.sleep(200);
          } catch (InterruptedException e) {
            e.printStackTrace();
          }
          String atsGuid = ((HiveStatement) stmt).getYarnATSGuid();
          if (atsGuid != null) {
            yarnATSGuidSet.set(true);
            System.out.println("Yarn ATS GUID: " + atsGuid);
            return;
          } else {
            yarnATSGuidSet.set(false);
            System.out.println("No Yarn ATS GUID yet");
          }
        }
      }
    });
    tExecute.start();
    tGuid.start();
    tExecute.join();
    tGuid.interrupt();
    if (!yarnATSGuidSet.get()) {
      fail("Failed to set the YARN ATS Guid");
    }
    stmt.close();
  }
Test the non-null value of the Yarn ATS GUID.
We spawn 2 threads - one running the query and
the other attempting to read the ATS GUID.
We're using a dummy udf to simulate a query,
that runs for a sufficiently long time.
@throws Exception
itests/hive-unit/src/test/java/org/apache/hive/jdbc/TestJdbcDriver2.java