Search in sources :

Example 71 with SSHCommandResult

use of com.redhat.qe.tools.SSHCommandResult in project rhsm-qe by RedHatQE.

the class BugzillaTests method testUnsubscribeAllForExpiredSubscription.

/**
 * @author skallesh
 * @throws Exception
 * @throws JSONException
 */
@// update=true,	// uncomment to make TestDefinition changes update Polarion testcases through the polarize testcase importer
TestDefinition(projectID = { Project.RHEL6, Project.RedHatEnterpriseLinux7 }, testCaseID = { "RHEL6-21974", "RHEL7-51836" }, level = DefTypes.Level.COMPONENT, component = "subscription-manager", testtype = @TestType(testtype = DefTypes.TestTypes.FUNCTIONAL, subtype1 = DefTypes.Subtypes.RELIABILITY, subtype2 = DefTypes.Subtypes.EMPTY), posneg = PosNeg.POSITIVE, importance = DefTypes.Importance.HIGH, automation = DefTypes.Automation.AUTOMATED, tags = "Tier3")
@Test(description = "subscription-manager unsubscribe --all on expired subscriptions removes certs from entitlement folder", groups = { "Tier3Tests", "VerifyUnsubscribeAllForExpiredSubscription", "blockedByBug-852630", "blockedByBug-906550", "blockedByBug-1555582" }, enabled = true)
public void testUnsubscribeAllForExpiredSubscription() throws JSONException, Exception {
    clienttasks.clean();
    clienttasks.register(sm_clientUsername, sm_clientPassword, sm_clientOrg, null, null, null, null, true, null, null, (String) null, null, null, null, true, false, null, null, null, null);
    String consumerId = clienttasks.getCurrentConsumerId();
    ownerKey = CandlepinTasks.getOwnerKeyOfConsumerId(sm_serverAdminUsername, sm_serverAdminPassword, sm_serverUrl, consumerId);
    String expiringPoolId = createTestPool(-60 * 24, 1, false);
    Calendar c1 = new GregorianCalendar();
    clienttasks.subscribe(null, null, expiringPoolId, null, null, null, null, null, null, null, null, null, null);
    Calendar c2 = new GregorianCalendar();
    // wait for the pool to expire
    // sleep(endingMinutesFromNow*60*1000);
    // trying to reduce the wait time for the expiration by subtracting off
    // some expensive test time
    sleep(1 * 60 * 1000 - (c2.getTimeInMillis() - c1.getTimeInMillis()));
    List<ProductSubscription> consumedProductSubscriptions = clienttasks.getCurrentlyConsumedProductSubscriptions();
    List<ProductSubscription> activeProductSubscriptions = ProductSubscription.findAllInstancesWithMatchingFieldFromList("isActive", Boolean.TRUE, consumedProductSubscriptions);
    Set<BigInteger> activeProductSubscriptionSerials = new HashSet<BigInteger>();
    for (ProductSubscription activeProductSubscription : activeProductSubscriptions) activeProductSubscriptionSerials.add(activeProductSubscription.serialNumber);
    List<ProductSubscription> expiredProductSubscriptions = ProductSubscription.findAllInstancesWithMatchingFieldFromList("isActive", Boolean.FALSE, consumedProductSubscriptions);
    Assert.assertEquals(expiredProductSubscriptions.size(), 1, "Found one expired entitlement (indicated by Active:False) among the list of consumed subscriptions.");
    SSHCommandResult result = clienttasks.unsubscribe(true, (BigInteger) null, null, null, null, null, null);
    String expected = String.format("%d subscriptions removed at the server.\n%d local certificates have been deleted.", activeProductSubscriptionSerials.size(), activeProductSubscriptionSerials.size() + expiredProductSubscriptions.size());
    if (clienttasks.isPackageVersion("subscription-manager", ">=", "1.20.2-1")) {
        // commit d88d09c7060a17fba34a138313e7efd21cc79d02  D-Bus service for removing entitlements (all/ID/serial num.)
        expected = String.format("%d local certificates have been deleted." + "\n" + "%d subscriptions removed at the server.", activeProductSubscriptionSerials.size() + expiredProductSubscriptions.size(), activeProductSubscriptionSerials.size());
    }
    if (activeProductSubscriptionSerials.size() + expiredProductSubscriptions.size() == 1)
        expected = expected.replace("local certificates have been", "local certificate has been");
    Assert.assertEquals(result.getStdout().trim(), expected);
}
Also used : SSHCommandResult(com.redhat.qe.tools.SSHCommandResult) GregorianCalendar(java.util.GregorianCalendar) Calendar(java.util.Calendar) GregorianCalendar(java.util.GregorianCalendar) ProductSubscription(rhsm.data.ProductSubscription) BigInteger(java.math.BigInteger) HashSet(java.util.HashSet) TestDefinition(com.github.redhatqe.polarize.metadata.TestDefinition) Test(org.testng.annotations.Test) ImplementsNitrateTest(com.redhat.qe.auto.tcms.ImplementsNitrateTest)

Example 72 with SSHCommandResult

use of com.redhat.qe.tools.SSHCommandResult in project rhsm-qe by RedHatQE.

the class BugzillaTests method testSubscribingWithIncorrectFormatForPoolId.

/**
 * @author skallesh
 * @throws IOException
 */
@// update=true,	// uncomment to make TestDefinition changes update Polarion testcases through the polarize testcase importer
TestDefinition(projectID = { Project.RHEL6, Project.RedHatEnterpriseLinux7 }, testCaseID = { "RHEL6-21958", "RHEL7-51820" }, level = DefTypes.Level.COMPONENT, component = "subscription-manager", testtype = @TestType(testtype = DefTypes.TestTypes.FUNCTIONAL, subtype1 = DefTypes.Subtypes.RELIABILITY, subtype2 = DefTypes.Subtypes.EMPTY), posneg = PosNeg.NEGATIVE, importance = DefTypes.Importance.HIGH, automation = DefTypes.Automation.AUTOMATED, tags = "Tier3")
@Test(description = "subscription-manager: subscribe multiple pools in incorrect format", groups = { "Tier3Tests", "MysubscribeTest", "blockedByBug-772218" }, enabled = true)
public void testSubscribingWithIncorrectFormatForPoolId() throws IOException {
    clienttasks.register(sm_clientUsername, sm_clientPassword, sm_clientOrg, null, null, null, null, null, null, null, (String) null, null, null, null, true, null, null, null, null, null);
    List<String> poolid = new ArrayList<String>();
    for (SubscriptionPool pool : clienttasks.getCurrentlyAllAvailableSubscriptionPools()) {
        poolid.add(pool.poolId);
    }
    if (poolid.isEmpty())
        throw new SkipException("Cannot randomly pick a pool for subscribing when there are no available pools for testing.");
    int i = randomGenerator.nextInt(poolid.size());
    int j = randomGenerator.nextInt(poolid.size());
    if (i == j) {
        j = randomGenerator.nextInt(poolid.size());
    }
    SSHCommandResult subscribeResult = subscribeInvalidFormat_(null, null, poolid.get(i), poolid.get(j), null, null, null, null, null, null, null, null);
    Assert.assertEquals(subscribeResult.getStdout().trim(), "cannot parse argument: " + poolid.get(j));
}
Also used : SSHCommandResult(com.redhat.qe.tools.SSHCommandResult) ArrayList(java.util.ArrayList) SkipException(org.testng.SkipException) SubscriptionPool(rhsm.data.SubscriptionPool) TestDefinition(com.github.redhatqe.polarize.metadata.TestDefinition) Test(org.testng.annotations.Test) ImplementsNitrateTest(com.redhat.qe.auto.tcms.ImplementsNitrateTest)

Example 73 with SSHCommandResult

use of com.redhat.qe.tools.SSHCommandResult in project rhsm-qe by RedHatQE.

the class BugzillaTests method testFactsWithIncorrectProxy_Test.

/**
 * @author skallesh
 * @throws Exception
 * @throws JSONException
 */
@// update=true,	// uncomment to make TestDefinition changes update Polarion testcases through the polarize testcase importer
TestDefinition(projectID = { Project.RHEL6, Project.RedHatEnterpriseLinux7 }, testCaseID = { "RHEL6-21950", "RHEL7-51812" }, level = DefTypes.Level.COMPONENT, component = "subscription-manager", testtype = @TestType(testtype = DefTypes.TestTypes.FUNCTIONAL, subtype1 = DefTypes.Subtypes.RELIABILITY, subtype2 = DefTypes.Subtypes.EMPTY), posneg = PosNeg.NEGATIVE, importance = DefTypes.Importance.HIGH, automation = DefTypes.Automation.AUTOMATED, tags = "Tier3")
@Test(description = "Verify facts update with incorrect proxy url produces traceback.", groups = { "Tier3Tests", "VerifyFactsWithIncorrectProxy_Test", "blockedByBug-744504" }, enabled = true)
public void testFactsWithIncorrectProxy_Test() throws JSONException, Exception {
    clienttasks.register(sm_clientUsername, sm_clientPassword, sm_clientOrg, null, null, null, null, null, null, null, (String) null, null, null, null, true, null, null, null, null, null);
    String basicauthproxyUrl = String.format("%s:%s", "testmachine.com", sm_basicauthproxyPort);
    basicauthproxyUrl = basicauthproxyUrl.replaceAll(":$", "");
    SSHCommandResult factsResult = clienttasks.facts_(null, true, basicauthproxyUrl, null, null, null);
    String factsResultExpected = clienttasks.msg_NetworkErrorUnableToConnect;
    factsResultExpected = "Error updating system data on the server, see /var/log/rhsm/rhsm.log for more details.";
    factsResultExpected = clienttasks.msg_ProxyConnectionFailed;
    Assert.assertEquals(factsResult.getStdout().trim() + factsResult.getStderr().trim(), factsResultExpected);
}
Also used : SSHCommandResult(com.redhat.qe.tools.SSHCommandResult) TestDefinition(com.github.redhatqe.polarize.metadata.TestDefinition) Test(org.testng.annotations.Test) ImplementsNitrateTest(com.redhat.qe.auto.tcms.ImplementsNitrateTest)

Example 74 with SSHCommandResult

use of com.redhat.qe.tools.SSHCommandResult in project rhsm-qe by RedHatQE.

the class BugzillaTests method testImportedCertGetsDeletedByRepoCommand.

/**
 * @author skallesh
 * @throws Exception
 * @throws JSONException
 */
@// update=true,	// uncomment to make TestDefinition changes update Polarion testcases through the polarize testcase importer
TestDefinition(projectID = { Project.RHEL6, Project.RedHatEnterpriseLinux7 }, testCaseID = { "RHEL6-21957", "RHEL7-51819" }, level = DefTypes.Level.COMPONENT, component = "subscription-manager", testtype = @TestType(testtype = DefTypes.TestTypes.FUNCTIONAL, subtype1 = DefTypes.Subtypes.RELIABILITY, subtype2 = DefTypes.Subtypes.EMPTY), posneg = PosNeg.POSITIVE, importance = DefTypes.Importance.HIGH, automation = DefTypes.Automation.AUTOMATED, tags = "Tier3")
@Test(description = "verify subscription-manager repos --list does not delete an imported entitlement certificate on a system", groups = { "Tier3Tests", "VerifyImportedCertgetsDeletedByRepoCommand", "blockedByBug-1160150" }, enabled = true)
public void testImportedCertGetsDeletedByRepoCommand() throws Exception {
    clienttasks.register(sm_clientUsername, sm_clientPassword, sm_clientOrg, null, null, null, null, false, null, null, (String) null, null, null, null, true, null, null, null, null, null);
    // disable
    clienttasks.autoheal(null, null, true, null, null, null, null);
    SubscriptionPool pool = getRandomSubsetOfList(clienttasks.getCurrentlyAvailableSubscriptionPools(), 1).get(0);
    File importEntitlementCertFile = clienttasks.subscribeToSubscriptionPool(pool, sm_clientUsername, sm_clientPassword, sm_serverUrl);
    File importEntitlementKeyFile = clienttasks.getEntitlementCertKeyFileCorrespondingToEntitlementCertFile(importEntitlementCertFile);
    File importCertificateFile = new File(importCertificatesDir1 + File.separator + importEntitlementCertFile.getName());
    List<Repo> subscribedReposBefore = clienttasks.getCurrentlySubscribedRepos();
    client.runCommandAndWait("mkdir -p " + importCertificatesDir1);
    client.runCommandAndWait("cat " + importEntitlementCertFile + " " + importEntitlementKeyFile + " > " + importCertificateFile);
    String path = importCertificateFile.getPath();
    clienttasks.clean();
    clienttasks.importCertificate(path);
    int Ceritificate_countBeforeRepoCommand = clienttasks.getCurrentEntitlementCertFiles().size();
    SSHCommandResult Result = clienttasks.repos_(true, null, null, (String) null, null, null, null, null, null);
    int Ceritificate_countAfterRepoCommand = clienttasks.getCurrentEntitlementCertFiles().size();
    List<Repo> subscribedReposAfter = clienttasks.getCurrentlySubscribedRepos();
    Assert.assertEquals(Ceritificate_countBeforeRepoCommand, Ceritificate_countAfterRepoCommand);
    Assert.assertEquals(Result.getExitCode(), new Integer(0));
    Assert.assertTrue(subscribedReposBefore.containsAll(subscribedReposAfter) && subscribedReposAfter.containsAll(subscribedReposBefore), "The list of subscribed repos is the same before and after importing the entitlement certificate.");
}
Also used : BigInteger(java.math.BigInteger) Repo(rhsm.data.Repo) YumRepo(rhsm.data.YumRepo) SSHCommandResult(com.redhat.qe.tools.SSHCommandResult) SubscriptionPool(rhsm.data.SubscriptionPool) File(java.io.File) TestDefinition(com.github.redhatqe.polarize.metadata.TestDefinition) Test(org.testng.annotations.Test) ImplementsNitrateTest(com.redhat.qe.auto.tcms.ImplementsNitrateTest)

Example 75 with SSHCommandResult

use of com.redhat.qe.tools.SSHCommandResult in project rhsm-qe by RedHatQE.

the class BugzillaTests method testRegisterAttemptsWithVariousConsumerNames.

/**
 * @author skallesh
 * @throws Exception
 * @throws JSONException
 */
@// update=true,	// uncomment to make TestDefinition changes update Polarion testcases through the polarize testcase importer
TestDefinition(projectID = { Project.RHEL6, Project.RedHatEnterpriseLinux7 }, testCaseID = { "RHEL6-21942", "RHEL7-51804" }, level = DefTypes.Level.COMPONENT, component = "subscription-manager", testtype = @TestType(testtype = DefTypes.TestTypes.FUNCTIONAL, subtype1 = DefTypes.Subtypes.RELIABILITY, subtype2 = DefTypes.Subtypes.EMPTY), posneg = PosNeg.POSITIVE, importance = DefTypes.Importance.HIGH, automation = DefTypes.Automation.AUTOMATED, tags = "Tier3")
@Test(description = "verify if CLI lets you set consumer name to empty string and defaults to sm_clientUsername", groups = { "Tier3Tests", "VerifyConsumerNameTest", "blockedByBug-669395", "blockedByBug-1451003" }, enabled = true)
public void testRegisterAttemptsWithVariousConsumerNames() throws JSONException, Exception {
    String consumerName = "tester";
    clienttasks.register(sm_clientUsername, sm_clientPassword, sm_clientOrg, null, null, null, null, null, null, null, (String) null, null, null, null, true, null, null, null, null, null);
    SSHCommandResult result = clienttasks.identity(null, null, null, null, null, null, null, null);
    Assert.assertContainsMatch(result.getStdout(), "name: " + clienttasks.hostname);
    clienttasks.register(sm_clientUsername, sm_clientPassword, sm_clientOrg, null, null, consumerName, null, null, null, null, (String) null, null, null, null, true, null, null, null, null, null);
    result = clienttasks.identity(null, null, null, null, null, null, null, null);
    String expected = "name: " + consumerName;
    Assert.assertContainsMatch(result.getStdout(), expected);
    String consumerId = clienttasks.getCurrentConsumerId();
    clienttasks.clean();
    consumerName = "consumer";
    clienttasks.register(sm_clientUsername, sm_clientPassword, sm_clientOrg, null, null, consumerName, consumerId, null, null, null, (String) null, null, null, null, null, null, null, null, null, null);
    result = clienttasks.identity(null, null, null, null, null, null, null, null);
    Assert.assertContainsMatch(result.getStdout(), expected);
    clienttasks.clean();
    result = clienttasks.register_(sm_clientUsername, sm_clientPassword, sm_clientOrg, null, null, "", consumerId, null, null, null, (String) null, null, null, null, true, null, null, null, null, null);
    if (clienttasks.isPackageVersion("subscription-manager", ">=", "1.13.8-1")) {
        // post
        // commit
        // df95529a5edd0be456b3528b74344be283c4d258
        Assert.assertEquals(result.getStderr().trim(), "Error: system name can not be empty.", "stderr");
    } else {
        Assert.assertEquals(result.getStdout().trim(), "Error: system name can not be empty.", "stdout");
    }
    result = clienttasks.register_(sm_clientUsername, sm_clientPassword, sm_clientOrg, null, null, "", null, null, null, null, (String) null, null, null, null, true, null, null, null, null, null);
    if (clienttasks.isPackageVersion("subscription-manager", ">=", "1.13.8-1")) {
        // post
        // commit
        // df95529a5edd0be456b3528b74344be283c4d258
        Assert.assertEquals(result.getStderr().trim(), "Error: system name can not be empty.", "stderr");
    } else {
        Assert.assertEquals(result.getStdout().trim(), "Error: system name can not be empty.", "stdout");
    }
}
Also used : SSHCommandResult(com.redhat.qe.tools.SSHCommandResult) TestDefinition(com.github.redhatqe.polarize.metadata.TestDefinition) Test(org.testng.annotations.Test) ImplementsNitrateTest(com.redhat.qe.auto.tcms.ImplementsNitrateTest)

Aggregations

SSHCommandResult (com.redhat.qe.tools.SSHCommandResult)553 Test (org.testng.annotations.Test)416 TestDefinition (com.github.redhatqe.polarize.metadata.TestDefinition)401 SkipException (org.testng.SkipException)219 ImplementsNitrateTest (com.redhat.qe.auto.tcms.ImplementsNitrateTest)201 ArrayList (java.util.ArrayList)101 BugzillaAPIException (com.redhat.qe.auto.bugzilla.BugzillaAPIException)79 BigInteger (java.math.BigInteger)68 File (java.io.File)58 SubscriptionPool (rhsm.data.SubscriptionPool)53 JSONObject (org.json.JSONObject)47 HashMap (java.util.HashMap)42 ProductSubscription (rhsm.data.ProductSubscription)31 EntitlementCert (rhsm.data.EntitlementCert)30 List (java.util.List)21 YumRepo (rhsm.data.YumRepo)18 ProductCert (rhsm.data.ProductCert)17 Repo (rhsm.data.Repo)16 InstalledProduct (rhsm.data.InstalledProduct)15 Calendar (java.util.Calendar)13