コード例 #1
0
ファイル: GeneralTests.java プロジェクト: kbidarkar/rhsm-qe
  @Test(
      description = "assert rhsmd is logged to both /var/log/rhsm/rhsm.log and /var/log/messages",
      groups = {"blockedbyBug-976868"},
      enabled = true)
  // @ImplementsTCMS(id="")
  public void VerifyRhsmdForceSignalsToRhsmlogAndSyslog_Test() {
    clienttasks.register(
        sm_clientUsername,
        sm_clientPassword,
        sm_clientOrg,
        null,
        null,
        null,
        null,
        null,
        null,
        null,
        (List<String>) null,
        null,
        null,
        null,
        null,
        null,
        null,
        null,
        null);

    Map<String, String> signalMap = new HashMap<String, String>();
    signalMap.put("valid", "");
    signalMap.put(
        "expired",
        "This system is missing one or more subscriptions. Please run subscription-manager for more information.");
    signalMap.put(
        "warning",
        "This system's subscriptions are about to expire. Please run subscription-manager for more information.");
    signalMap.put(
        "partial",
        "This system is missing one or more subscriptions to fully cover its products. Please run subscription-manager for more information.");

    for (String signal : signalMap.keySet()) {
      String command = clienttasks.rhsmComplianceD + " -s -d -i -f " + signal;
      String marker =
          System.currentTimeMillis() + " Testing VerifyRhsmdLogsToRhsmlogAndSyslog_Test...";
      RemoteFileTasks.markFile(client, clienttasks.rhsmLogFile, marker);
      RemoteFileTasks.markFile(client, clienttasks.varLogMessagesFile, marker);

      // run and verify the command result
      String expectedStdout = "forcing status signal from cli arg";
      RemoteFileTasks.runCommandAndAssert(
          client, command, Integer.valueOf(0), expectedStdout, null);

      // verify the logs
      sleep(100); // give the message thread time to be logged
      String logResult;
      if (signalMap.get(signal).isEmpty()) {
        String unExpectedMessage = "Please run subscription-manager for more information.";
        logResult =
            RemoteFileTasks.getTailFromMarkedFile(
                    client, clienttasks.varLogMessagesFile, marker, null)
                .trim();
        Assert.assertTrue(
            !logResult.contains(unExpectedMessage),
            clienttasks.varLogMessagesFile
                + " does NOT contain message '"
                + unExpectedMessage
                + "'.");
        logResult =
            RemoteFileTasks.getTailFromMarkedFile(client, clienttasks.rhsmLogFile, marker, null)
                .trim();
        Assert.assertTrue(
            !logResult.contains(unExpectedMessage),
            clienttasks.rhsmLogFile + " does NOT contain message '" + unExpectedMessage + "'.");
        Assert.assertTrue(
            logResult.contains(expectedStdout),
            clienttasks.rhsmLogFile + " contains expected message '" + expectedStdout + "'.");

      } else {
        String expectedMessage = signalMap.get(signal);
        logResult =
            RemoteFileTasks.getTailFromMarkedFile(
                    client, clienttasks.varLogMessagesFile, marker, null)
                .trim();
        Assert.assertTrue(
            logResult.contains(expectedMessage),
            clienttasks.varLogMessagesFile
                + " contains expected message '"
                + expectedMessage
                + "'.");
        logResult =
            RemoteFileTasks.getTailFromMarkedFile(client, clienttasks.rhsmLogFile, marker, null)
                .trim();
        Assert.assertTrue(
            logResult.contains(expectedMessage),
            clienttasks.rhsmLogFile + " contains expected message '" + expectedMessage + "'.");
        Assert.assertTrue(
            logResult.contains(expectedStdout),
            clienttasks.rhsmLogFile + " contains expected message '" + expectedStdout + "'.");
      }
    }
  }
コード例 #2
0
ファイル: GeneralTests.java プロジェクト: kbidarkar/rhsm-qe
  @Test(
      description = "assert the exit code from service rhsmcertd status when running and stopped",
      groups = {"AcceptanceTests", "blockedByBug-913118", "blockedByBug-912707"})
  protected void verifyRhsmcertdDoesNotThrowDeprecationWarnings_Test()
      throws JSONException, Exception {
    clienttasks.unregister(null, null, null);
    String marker =
        System.currentTimeMillis()
            + " Testing verifyRhsmcertdDoesNotThrowDeprecationWarnings_Test...";
    RemoteFileTasks.markFile(client, clienttasks.varLogMessagesFile, marker);

    String command = clienttasks.rhsmComplianceD + " -s";
    SSHCommandResult result = client.runCommandAndWait(command);
    Assert.assertEquals(
        result.getExitCode(), Integer.valueOf(0), "ExitCode from command '" + command + "'.");
    Assert.assertTrue(
        result.getStdout().isEmpty(), "Stdout from command '" + command + "' is empty.");
    Assert.assertTrue(
        result.getStderr().isEmpty(), "Stderr from command '" + command + "' is empty.");

    String rhsmcertdLogResult =
        RemoteFileTasks.getTailFromMarkedFile(client, clienttasks.varLogMessagesFile, marker, null)
            .trim();
    String expectedMessage =
        "In order for Subscription Manager to provide your system with updates, your system must be registered with the Customer Portal. Please enter your Red Hat login to ensure your system is up-to-date.";
    Assert.assertTrue(
        rhsmcertdLogResult.contains(expectedMessage),
        "Syslog contains expected message '" + expectedMessage + "'.");
    String unexpectedMessage = "DeprecationWarning";
    Assert.assertTrue(
        !rhsmcertdLogResult.contains(unexpectedMessage),
        "Syslog does not contain message '" + unexpectedMessage + "'.");

    clienttasks.register(
        sm_clientUsername,
        sm_clientPassword,
        sm_clientOrg,
        null,
        null,
        null,
        null,
        null,
        null,
        null,
        (List<String>) null,
        null,
        null,
        null,
        null,
        null,
        null,
        null,
        null);
    /*
    List<SubscriptionPool> pools = clienttasks.getCurrentlyAvailableSubscriptionPools();
    if (pools.isEmpty()) throw new SkipException("Cannot randomly pick a pool for subscribing when there are no available pools for testing.");
    SubscriptionPool pool = pools.get(randomGenerator.nextInt(pools.size())); // randomly pick a pool
    clienttasks.subscribe(null,null,pool.poolId,null,null,null,null,null,null,null,null);
    */
    clienttasks.subscribeToTheCurrentlyAvailableSubscriptionPoolsCollectively();
    // TODO: I can only seem to reproduce the error after consuming an entitlement from stage -
    // don't know why - maybe it requires an entitlement with a warning period - let's just
    // subscribe to all the pools.
    result = client.runCommandAndWait(command);
    //	[root@rhsm-accept-rhel5 ~]# /usr/libexec/rhsmd -s
    //	/usr/lib64/python2.4/site-packages/rhsm/certificate.py:123: DeprecationWarning: Call to
    // deprecated function: hasNow
    //	  category=DeprecationWarning)
    //	[root@rhsm-accept-rhel5 ~]#
    Assert.assertEquals(
        result.getExitCode(), Integer.valueOf(0), "ExitCode from command '" + command + "'.");
    Assert.assertTrue(
        result.getStdout().isEmpty(), "Stdout from command '" + command + "' is empty.");
    Assert.assertTrue(
        result.getStderr().isEmpty(), "Stderr from command '" + command + "' is empty.");
  }