Example #1
0
 @Test(
     description = "assert the exit code from service rhsmcertd status when running and stopped",
     groups = {"blockedByBug-895263", "blockedByBug-824680", "blockedByBug-842464"})
 public void VerifyExitCodeStatusForRhmscertd_Test() {
   Integer expectedStoppedStatus = new Integer(3);
   Integer expectedRunningStatus = new Integer(0);
   log.info(
       "When service "
           + clienttasks.rhsmCertD
           + " is stopped, the expected service status exit code is: "
           + expectedStoppedStatus);
   log.info(
       "When service "
           + clienttasks.rhsmCertD
           + " is running, the expected service status exit code is: "
           + expectedRunningStatus);
   RemoteFileTasks.runCommandAndAssert(
       client,
       "service "
           + clienttasks.rhsmCertD
           + " stop  && service "
           + clienttasks.rhsmCertD
           + " status",
       new Integer(3));
   RemoteFileTasks.runCommandAndAssert(
       client,
       "service "
           + clienttasks.rhsmCertD
           + " start && service "
           + clienttasks.rhsmCertD
           + " status",
       new Integer(0));
 }
Example #2
0
 @Test(
     description = "subscription-manager-cli: attempt to access functionality without registering",
     groups = {"blockedByBug-749332"},
     dataProvider = "UnregisteredCommandData")
 @ImplementsNitrateTest(caseId = 50215)
 public void AttemptingCommandsWithoutBeingRegistered_Test(String command) {
   log.info(
       "Testing subscription-manager-cli command without being registered, expecting it to fail: "
           + command);
   clienttasks.unregister(null, null, null);
   // RemoteFileTasks.runCommandAndAssert(client,command,1,"^Error: You need to register this
   // system by running `register` command before using this option.",null);	// results changed
   // after bug fix 749332
   RemoteFileTasks.runCommandAndAssert(
       client, command, 255, "^" + clienttasks.msg_ConsumerNotRegistered, null);
 }
Example #3
0
  @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 + "'.");
      }
    }
  }
Example #4
0
  @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.");
  }