@Test
  public void testSkip2() throws Exception {
    metaStore.getConf().set(MetastoreConf.ConfVars.SCHEDULED_QUERIES_AUTODISABLE_COUNT.getVarname(), "4");
    metaStore.getConf().set(MetastoreConf.ConfVars.SCHEDULED_QUERIES_SKIP_OPPORTUNITIES_AFTER_FAILURES.getVarname(),
        "2");
    client.close();
    client = metaStore.getClient();
    testDisableInternal(5, 6, "skip2");

    try (PersistenceManager pm = PersistenceManagerProvider.getPersistenceManager()) {

      ScheduledQueryKey key = new ScheduledQueryKey("q1", "skip2");
      Query query = pm.newQuery(MScheduledExecution.class);
      query.setOrdering("scheduledExecutionId descending");
      query.setRange(0, 20);
      List<MScheduledExecution> list = (List<MScheduledExecution>) query.execute();
      List<MScheduledExecution> q1list = new ArrayList<MScheduledExecution>();

      List<Integer> tList = new ArrayList<Integer>();

      for (MScheduledExecution schqExec : list) {
        if (schqExec.getScheduledQuery().getScheduleKey().equals(key)) {
          q1list.add(schqExec);
          tList.add(schqExec.getStartTime());
        }
      }

      tList = Lists.reverse(tList);
      Integer startTime = tList.get(0);
      tList = tList.stream().map(e -> e - startTime).collect(Collectors.toList());

      assertArrayEquals(new Integer[] { 0, 1, 2, 4, 6, 6 }, tList.toArray());
    }

  }
Tests handling of scheduled queries related calls to the metastore.

Checks whether expected state changes are being done to the HMS database.
standalone-metastore/metastore-server/src/test/java/org/apache/hadoop/hive/metastore/client/TestMetastoreScheduledQueries.java