public void testDisableInternal(int q1NumberOfExecutions, int seconds, String testNamespace)
      throws Exception {
    int q2NumberOfExecutions = seconds - 1;
    ScheduledQueryKey schqKey1 = new ScheduledQueryKey("q1", testNamespace);
    ScheduledQueryKey schqKey2 = new ScheduledQueryKey("q2", testNamespace);
    createEverySecondSchq(schqKey1);
    createEverySecondSchq(schqKey2);

    // do some polls and report failure each time
    ScheduledQueryPollRequest request = new ScheduledQueryPollRequest();
    request.setClusterNamespace(testNamespace);
    ScheduledQueryPollResponse pollResult = null;
    int idx1 = 0;
    int idx2 = 0;
    for (int i = 0; i < seconds * 10 + 9; i++) {
      pollResult = client.scheduledQueryPoll(request);
      if (pollResult.isSetQuery()) {

        if (pollResult.getScheduleKey().equals(schqKey1)) {
          idx1++;
          if (idx1 == 1) {
            ScheduledQueryProgressInfo info =
                new ScheduledQueryProgressInfo(pollResult.getExecutionId(), QueryState.FINISHED, "executor-query-id");
            client.scheduledQueryProgress(info);

          } else {
            ScheduledQueryProgressInfo info =
                new ScheduledQueryProgressInfo(pollResult.getExecutionId(), QueryState.FAILED, "executor-query-id");
            info.setErrorMessage("some issue happened");
            client.scheduledQueryProgress(info);

          }

          ScheduledQuery schq = client.getScheduledQuery(pollResult.getScheduleKey());
          if (idx1 > q1NumberOfExecutions) {
            fail("unexpected execution of q1 happened");
          }
          if (idx1 == q1NumberOfExecutions) {
            assertFalse("Scheduled query q1 must be disabled at this point", schq.isEnabled());
          } else {
            assertTrue("Scheduled query q1 must be enabled at this point", schq.isEnabled());
          }
        }

        if (pollResult.getScheduleKey().equals(schqKey2)) {
          idx2++;
          ScheduledQueryProgressInfo info =
              new ScheduledQueryProgressInfo(pollResult.getExecutionId(), QueryState.FINISHED, "executor-query-id");
          client.scheduledQueryProgress(info);
          ScheduledQuery schq = client.getScheduledQuery(pollResult.getScheduleKey());
          assertTrue("Scheduled query q2 must be enabled", schq.isEnabled());
        }
      }
      Thread.sleep(100);
    }
    if (idx1 != q1NumberOfExecutions) {
      fail("expected " + q1NumberOfExecutions + " execution of q1; only " + idx1 + " happened");
    }
    if (idx2 < q2NumberOfExecutions) {
      fail("at least " + q2NumberOfExecutions + " expected for q2");
    }
  }
Simulates some schq failure scenario.

Q1 is executed correctly 1 time; but every further executions are end with failures
Q2 should be executed without without issues even thru Q1 will be disabled at some point
standalone-metastore/metastore-server/src/test/java/org/apache/hadoop/hive/metastore/client/TestMetastoreScheduledQueries.java