Search in sources :

Example 26 with InstalledProduct

use of rhsm.data.InstalledProduct in project rhsm-qe by RedHatQE.

the class ListTests method testListAvailableWithNoOverlap.

@// update=true	// uncomment to make TestDefinition changes update Polarion testcases through the polarize testcase importer
TestDefinition(projectID = { Project.RHEL6, Project.RedHatEnterpriseLinux7 }, testCaseID = { "RHEL6-36565", "RHEL7-51349" }, 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 = "Tier2")
@Test(description = "subscription-manager: subcription manager list all with --match-installed option", groups = { "Tier2Tests", "blockedByBug-654501", "blockedByBug-1022622", /*rhel7*/
"blockedByBug-1114717", /*rhel6*/
"blockedByBug-1493711" }, enabled = true)
public // @ImplementsNitrateTest(caseId=)
void testListAvailableWithNoOverlap() throws JSONException, Exception {
    clienttasks.register(sm_clientUsername, sm_clientPassword, sm_clientOrg, null, null, null, null, null, null, null, (String) null, null, null, null, false, null, null, null, null, null);
    clienttasks.autoheal(null, null, true, null, null, null, null);
    // assemble a list of currently installed product ids
    List<ProductCert> installedProductCerts = clienttasks.getCurrentProductCerts();
    List<String> installedProductIds = new ArrayList<String>();
    for (ProductCert productCert : installedProductCerts) installedProductIds.add(productCert.productId);
    // get the available subscription pools
    List<SubscriptionPool> availableSubscriptionPools = SubscriptionPool.parse(clienttasks.list(null, true, null, null, null, null, null, false, null, null, null, null, null, null).getStdout());
    // randomly attach a positive subset of available subscriptions
    List<SubscriptionPool> randomAvailableSubscriptionPools = getRandomSubsetOfList(availableSubscriptionPools, randomGenerator.nextInt(availableSubscriptionPools.size() - 1) + 1);
    List<String> poolIds = new ArrayList<String>();
    for (SubscriptionPool subscriptionPool : randomAvailableSubscriptionPools) poolIds.add(subscriptionPool.poolId);
    if (false) {
        // debugTesting will cause test to fail due to bugzilla https://bugzilla.redhat.com/show_bug.cgi?id=1022622#c0
        poolIds.clear();
        poolIds.add(SubscriptionPool.findFirstInstanceWithMatchingFieldFromList("subscriptionName", "Awesome OS Server Basic", availableSubscriptionPools).poolId);
        poolIds.add(SubscriptionPool.findFirstInstanceWithMatchingFieldFromList("subscriptionName", "Awesome OS for All Arch (excpt for x86_64 content)", availableSubscriptionPools).poolId);
        poolIds.add(SubscriptionPool.findFirstInstanceWithMatchingFieldFromList("subscriptionName", "Awesome OS with unlimited virtual guests", availableSubscriptionPools).poolId);
        poolIds.add(SubscriptionPool.findFirstInstanceWithMatchingFieldFromList("subscriptionName", "Multi-Attribute Stackable (2 GB, 2 Cores)", availableSubscriptionPools).poolId);
        poolIds.add(SubscriptionPool.findFirstInstanceWithMatchingFieldFromList("subscriptionName", "Awesome OS Server Basic (data center)", availableSubscriptionPools).poolId);
        poolIds.add(SubscriptionPool.findFirstInstanceWithMatchingFieldFromList("subscriptionName", "Multi-Attribute Stackable (2 sockets)", availableSubscriptionPools).poolId);
        poolIds.add(SubscriptionPool.findFirstInstanceWithMatchingFieldFromList("subscriptionName", "Awesome OS for systems with no sockets", availableSubscriptionPools).poolId);
        poolIds.add(SubscriptionPool.findFirstInstanceWithMatchingFieldFromList("subscriptionName", "Awesome OS Server Basic (multi-entitlement)", availableSubscriptionPools).poolId);
        poolIds.add(SubscriptionPool.findFirstInstanceWithMatchingFieldFromList("subscriptionName", "Awesome OS Modifier", availableSubscriptionPools).poolId);
    }
    clienttasks.subscribe(null, null, poolIds, null, null, "1", null, null, null, null, null, null, null);
    List<InstalledProduct> installedProducts = InstalledProduct.parse(clienttasks.list(null, null, null, true, null, null, null, null, null, null, null, null, null, null).getStdout());
    List<SubscriptionPool> availableSubscriptionPoolsWithoutOverlap = SubscriptionPool.parse(clienttasks.list(null, true, null, null, null, null, null, true, null, null, null, null, null, null).getStdout());
    // loop through the list of available subscription pools without overlap and assert that at least one of pool's provided products is not fully subscribed.
    for (SubscriptionPool subscriptionPool : availableSubscriptionPoolsWithoutOverlap) {
        boolean noOverlapFound = false;
        List<String> providedProductIds = CandlepinTasks.getPoolProvidedProductIds(sm_clientUsername, sm_clientPassword, sm_serverUrl, subscriptionPool.poolId);
        if (providedProductIds.isEmpty()) {
            Assert.assertTrue(providedProductIds.isEmpty(), "Subscription '" + subscriptionPool.subscriptionName + "' provides=" + subscriptionPool.provides + " reported in the list available with no-overlap provides no products and therefore does not overlap an already covered product.");
            noOverlapFound = true;
        }
        for (String providedProductId : providedProductIds) {
            InstalledProduct installedProduct = InstalledProduct.findFirstInstanceWithMatchingFieldFromList("productId", providedProductId, installedProducts);
            if (installedProduct != null) {
                if (!installedProduct.status.equalsIgnoreCase("Subscribed")) {
                    Assert.assertTrue(!installedProduct.status.equalsIgnoreCase("Subscribed"), "Subscription '" + subscriptionPool.subscriptionName + "' provides=" + subscriptionPool.provides + " reported in the list available with no-overlap provides product id '" + providedProductId + "' which is installed with status '" + installedProduct.status + "' and therefore does not overlap an already covered product.");
                    noOverlapFound = true;
                } else {
                    log.warning("Subscription '" + subscriptionPool.subscriptionName + "' provides=" + subscriptionPool.provides + " reported in the list available with no-overlap provides product id '" + providedProductId + "' which is installed with status '" + installedProduct.status + "'.");
                }
            } else {
                Assert.assertTrue(installedProduct == null, "Subscription '" + subscriptionPool.subscriptionName + "' provides=" + subscriptionPool.provides + " reported in the list available with no-overlap provides product id '" + providedProductId + "' which is not installed and therefore does not overlap an already covered product.");
                noOverlapFound = true;
            }
        }
        Assert.assertTrue(noOverlapFound, "Subscription '" + subscriptionPool.subscriptionName + "' provides=" + subscriptionPool.provides + " that is reported in the list available with no-overlap provides at least one product that is not fully Subscribed.");
    }
    // the remainder of this --no-overlap test has been fixed in subscription-manager-1.12.6-1 and newer; otherwise skip it.
    if (clienttasks.isPackageVersion("subscription-manager", "<", "1.12.6-1"))
        throw new SkipException("The installed version of subscription-manager does not contain the fix for https://bugzilla.redhat.com/show_bug.cgi?id=1022622#c3");
    // assert that availableSubscriptionPools that are not filtered out of the availableSubscriptionPoolsWithoutOverlap provide products that are all fully Subscribed
    availableSubscriptionPools = SubscriptionPool.parse(clienttasks.list(null, true, null, null, null, null, null, false, null, null, null, null, null, null).getStdout());
    for (SubscriptionPool availableSubscriptionPool : availableSubscriptionPools) {
        if (!availableSubscriptionPoolsWithoutOverlap.contains(availableSubscriptionPool)) {
            for (String providedProductId : CandlepinTasks.getPoolProvidedProductIds(sm_clientUsername, sm_clientPassword, sm_serverUrl, availableSubscriptionPool.poolId)) {
                InstalledProduct installedProduct = InstalledProduct.findFirstInstanceWithMatchingFieldFromList("productId", providedProductId, installedProducts);
                if (installedProduct != null) {
                    Assert.assertEquals(installedProduct.status, "Subscribed", "Subscription '" + availableSubscriptionPool.subscriptionName + "' provides=" + availableSubscriptionPool.provides + " is excluded from the list available with no-overlap.  It provides product id '" + providedProductId + "' which is installed and covered by an active subscription.");
                } else {
                // skip the providedProductId when not installed
                }
            }
        }
    }
}
Also used : InstalledProduct(rhsm.data.InstalledProduct) ArrayList(java.util.ArrayList) ProductCert(rhsm.data.ProductCert) 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 27 with InstalledProduct

use of rhsm.data.InstalledProduct in project rhsm-qe by RedHatQE.

the class ListTests method testListInstalledWithWildcardMatches.

@// update=true	// uncomment to make TestDefinition changes update Polarion testcases through the polarize testcase importer
TestDefinition(projectID = { Project.RHEL6, Project.RedHatEnterpriseLinux7 }, testCaseID = { "RHEL6-36559", "RHEL7-51339" }, 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 = "Tier2")
@Test(description = "subscription-manager: subcription manager list --installed with wildcard --matches on Product Name, Product ID.  Note: wildcard match means * matches zero or more char and ? matches one char and is case insensitive.", groups = { "Tier2Tests", "blockedByBug-1146125" }, enabled = true)
public // @ImplementsNitrateTest(caseId=)
void testListInstalledWithWildcardMatches() throws JSONException, Exception {
    if (clienttasks.isPackageVersion("subscription-manager", "<", "1.13.6-1"))
        throw new SkipException("The list --matches function was not implemented in this version of subscription-manager.");
    String matchesString;
    List<InstalledProduct> actualInstalledProductMatches;
    // register if necessary
    if (clienttasks.getCurrentlyRegisteredOwnerKey() == null) {
        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);
        clienttasks.autoheal(null, null, true, null, null, null, null);
    } else
        clienttasks.unsubscribe_(true, (BigInteger) null, null, null, null, null, null);
    // attach one of all the currently available subscriptions (attaching only one so that some installed products might remain noncompliant)
    // assemble a list of all the available SubscriptionPool ids
    List<String> poolIds = new ArrayList<String>();
    List<SubscriptionPool> subscriptionPools = clienttasks.getCurrentlyAvailableSubscriptionPools();
    for (SubscriptionPool pool : subscriptionPools) poolIds.add(pool.poolId);
    if (!poolIds.isEmpty())
        clienttasks.subscribe(null, null, poolIds, null, null, "1", null, null, null, null, null, null, null);
    // get all the installed products
    List<InstalledProduct> installedProducts = InstalledProduct.parse(clienttasks.list(null, null, null, true, null, null, null, null, null, null, null, null, null, null).getStdout());
    // randomly choose one of the installed products
    InstalledProduct randomInstalledProduct = getRandomListItem(installedProducts);
    // [root@jsefler-os7 ~]# subscription-manager list --installed
    // Product Name:   Red Hat Enterprise Linux Server
    // Product ID:     69
    // Version:        7.0
    // Arch:           x86_64
    // Status:         Not Subscribed
    // Status Details: Not supported by a valid subscription.
    // Starts:
    // Ends:
    // Test 1: test wildcard --matches on Product Name:
    matchesString = randomInstalledProduct.productName;
    // drop first word
    matchesString = matchesString.replaceFirst("^\\S+\\s+", "*");
    actualInstalledProductMatches = InstalledProduct.parse(clienttasks.list(null, null, null, true, null, null, null, null, matchesString, null, null, null, null, null).getStdout());
    assertActualResultOfListInstalledWithMatches(matchesString, actualInstalledProductMatches, installedProducts);
    // also test case insensitivity
    matchesString = randomizeCaseOfCharactersInString(matchesString);
    // and drop last word
    matchesString = matchesString.replaceFirst("\\s+\\S+$", "*");
    actualInstalledProductMatches = InstalledProduct.parse(clienttasks.list(null, null, null, true, null, null, null, null, matchesString, null, null, null, null, null).getStdout());
    assertActualResultOfListInstalledWithMatches(matchesString, actualInstalledProductMatches, installedProducts);
    // Test 2: test wildcard --matches on Product ID:
    matchesString = randomInstalledProduct.productId;
    int i = randomGenerator.nextInt(matchesString.length());
    matchesString = matchesString.replaceAll(String.valueOf(matchesString.charAt(i)), "?");
    actualInstalledProductMatches = InstalledProduct.parse(clienttasks.list(null, null, null, true, null, null, null, null, matchesString, null, null, null, null, null).getStdout());
    assertActualResultOfListInstalledWithMatches(matchesString, actualInstalledProductMatches, installedProducts);
// also test case insensitivity
/* not necessary since productId is an integer
		matchesString = randomizeCaseOfCharactersInString(matchesString);
		actualInstalledProductMatches = InstalledProduct.parse(clienttasks.list(null, null, null, true, null, null, null, null, matchesString, null, null, null).getStdout());
		assertActualResultOfListInstalledWithMatches(matchesString,actualInstalledProductMatches,installedProducts);
		*/
}
Also used : InstalledProduct(rhsm.data.InstalledProduct) ArrayList(java.util.ArrayList) BigInteger(java.math.BigInteger) 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 28 with InstalledProduct

use of rhsm.data.InstalledProduct in project rhsm-qe by RedHatQE.

the class ReleaseTests method testRateLimitExceededExceptionShouldNotAlterRedhatRepo.

@// update=true,	// uncomment to make TestDefinition changes update Polarion testcases through the polarize testcase importer
TestDefinition(projectID = { Project.RHEL6, Project.RedHatEnterpriseLinux7 }, testCaseID = { "RHEL6-47938", "RHEL7-99713" }, 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 = "Tier1")
@Test(description = "subscription-manager: after using the release module to pin the content set repos paths, use yum repolist to bombard the IT-Candlepin server with GET requests to /subscription/consumers/{uuid}/release so as to generate a RateLimitExceededException", groups = { "Tier1Tests", "blockedByBug-1481384", "blockedByBug-1486549" }, enabled = true)
public // @ImplementsNitrateTest(caseId=)
void testRateLimitExceededExceptionShouldNotAlterRedhatRepo() throws JSONException, Exception {
    // register a new consumer and auto-subscribe to cover the installed RHEL product
    clienttasks.unregister(null, null, null, null);
    clienttasks.register(sm_clientUsername, sm_clientPassword, sm_clientOrg, null, null, null, null, true, null, null, (String) null, null, null, null, null, false, null, null, null, null);
    ProductCert rhelProductCert = clienttasks.getCurrentRhelProductCert();
    if (rhelProductCert == null)
        throw new SkipException("This test requires an entitlement to an installed RHEL product");
    InstalledProduct installedRhelProduct = InstalledProduct.findFirstInstanceWithMatchingFieldFromList("productId", rhelProductCert.productId, clienttasks.getCurrentlyInstalledProducts());
    if (installedRhelProduct == null)
        Assert.fail("Could not find the installed product corresponding to the current RHEL product cert: " + rhelProductCert);
    if (!installedRhelProduct.status.equals("Subscribed"))
        throw new SkipException("This test requires attachment to a RHEL subscription for the installed RHEL product.");
    // assert that there are some occurrences of $releasever in redhat.repo (for non Beta)
    String sshCommandGreppingRedhatRepoForNumberReleaseverOccurrences = "grep '$releasever' " + clienttasks.redhatRepoFile + " | wc --lines";
    Integer numberReleaseverOccurrences = Integer.valueOf(client.runCommandAndWait(sshCommandGreppingRedhatRepoForNumberReleaseverOccurrences).getStdout().trim());
    if (false) {
        // NOT A VALID ASSERTION BECAUSE RCM HAS CHOSEN TO USE THE SAME TAGS ON BETA ENG IDS 362,363,433 AS THEIR GA COUNTERPARTS 420,419,434 WHICH MEANS THAT IF A SUBSCRIPTION THAT PROVIDES BOTH BETA AND GA ARE ATTACHED TO A SYSTEM WITH ONLY THE BETA PRODUCT CERT INSTALLED THEN ACCESS TO GA CONTENT WITH $releasever IS GRANTED.
        if (Arrays.asList("362", "363", "433").contains(installedRhelProduct.productId)) {
            Assert.assertEquals(numberReleaseverOccurrences, Integer.valueOf(0), "Because the currently installed RHEL engineering product '" + installedRhelProduct.productId + "' should only provide content access to beta|htb repositories, none of the current entitled repo urls should contain reference to $releasever.");
            throw new SkipException("This test requires a RHEL entitlement to an engineering product with content sets that can be pinned to a $releasever.");
        }
    }
    if (numberReleaseverOccurrences == 0)
        throw new SkipException("This test requires a RHEL entitlement providing an engineering product with content sets that can be pinned to a $releasever.");
    // NOT A VALID ASSERTION Assert.assertTrue(numberReleaseverOccurrences>0, "The number of occurrences ("+numberReleaseverOccurrences+") for '$releasever' in '"+clienttasks.redhatRepoFile+"' is greater than zero.");
    // are any releases available?
    List<String> availableReleases = clienttasks.getCurrentlyAvailableReleases(null, null, null, null);
    if (availableReleases.isEmpty())
        throw new SkipException("When no releases are available, this test must be skipped.");
    // set a release
    // assume the first release is good enough for this test
    String release = availableReleases.get(0);
    if (availableReleases.contains("7.3"))
        release = "7.3";
    clienttasks.release(null, null, release, null, null, null, null, null);
    // assert that no occurrences of $releasever are in redhat.repo
    Assert.assertEquals(client.runCommandAndWait(sshCommandGreppingRedhatRepoForNumberReleaseverOccurrences).getStdout().trim(), "0", "Number of occurances for \"$releasever\" in '" + clienttasks.redhatRepoFile + "' after setting the release to '" + release + "'.");
    // remember the number of available packages
    Integer numPackagesAvailableBeforeExceedingRateLimit = clienttasks.getYumListAvailable("--disablerepo=beaker*").size();
    // now bombard the server with more than 60 hits to encounter a RateLimitExceededException
    client.runCommandAndWait("for i in {1..60}; do yum repolist --disablerepo=beaker* --quiet; done;");
    String rhsmLogMarker = System.currentTimeMillis() + " testRateLimitExceededExceptionShouldNotAlterRedhatRepo...";
    RemoteFileTasks.markFile(client, clienttasks.rhsmLogFile, rhsmLogMarker);
    Integer numPackagesAvailableAfterExceedingRateLimit = clienttasks.getYumListAvailable("--disablerepo=beaker*").size();
    // assert that there are still no occurrences of $releasever in redhat.repo
    Assert.assertEquals(client.runCommandAndWait(sshCommandGreppingRedhatRepoForNumberReleaseverOccurrences).getStdout().trim(), "0", "Number of occurances for \"$releasever\" in '" + clienttasks.redhatRepoFile + "' after setting the release to '" + release + "' and then bombarding the server via the subscription-manager yum plugin via system invocations of yum repolist.");
    // assert that there is an ERROR in the rhsm.log for the RateLimitExceededException
    String rhsmLogStatement = RemoteFileTasks.getTailFromMarkedFile(client, clienttasks.rhsmLogFile, rhsmLogMarker, "ERROR").trim();
    // 2017-09-01 16:16:47,199 [ERROR] yum:16448:MainThread @cache.py:235 - Access rate limit exceeded
    if (!rhsmLogStatement.isEmpty())
        log.warning(rhsmLogStatement);
    // https://github.com/candlepin/subscription-manager/pull/1694	// commit abca9b07c0cbc852d015dc9316927f8e39d1ba0d 1481384: Do not update redhat.repo at RateLimitExceededException
    String expectedErrorMsg = "Access rate limit exceeded";
    Assert.assertTrue(rhsmLogStatement.contains(expectedErrorMsg), "After bombarding the server to purposefully invoke a RateLimitExceededException, the '" + clienttasks.rhsmLogFile + "' reports expected ERROR '" + expectedErrorMsg + "'.");
    // assert that the number of available packages remains the same
    Assert.assertEquals(numPackagesAvailableAfterExceedingRateLimit, numPackagesAvailableBeforeExceedingRateLimit, "The number of yum available packages after exceeding the rate limit (" + numPackagesAvailableAfterExceedingRateLimit + ") matches the number before exceeding the rate limit (" + numPackagesAvailableBeforeExceedingRateLimit + ").");
}
Also used : BigInteger(java.math.BigInteger) InstalledProduct(rhsm.data.InstalledProduct) ProductCert(rhsm.data.ProductCert) SkipException(org.testng.SkipException) TestDefinition(com.github.redhatqe.polarize.metadata.TestDefinition) Test(org.testng.annotations.Test)

Example 29 with InstalledProduct

use of rhsm.data.InstalledProduct in project rhsm-qe by RedHatQE.

the class ReleaseTests method testReleaseListExcludes56OnRHEL5System.

@TestDefinition(projectID = {/*Project.RHEL5*/
}, testCaseID = {})
@Test(description = "register to a RHEL subscription and verify that release --list excludes 5.6, 5.5, 5.4, 5.3, 5.2, 5.1, 5.0", groups = { "Tier1Tests", "blockedByBug-785989", /*,"blockedByBug-840509" MOVED TO TEMPORARY WORKAROUND*/
"blockedByBug-919700" }, enabled = true)
public // @ImplementsNitrateTest(caseId=)
void testReleaseListExcludes56OnRHEL5System() throws JSONException, Exception {
    if (!clienttasks.redhatReleaseX.equals("5"))
        throw new SkipException("This test is only applicable on RHEL5.");
    // TEMPORARY WORKAROUND
    boolean invokeWorkaroundWhileBugIsOpen = true;
    String bugId = "840509";
    try {
        if (invokeWorkaroundWhileBugIsOpen && BzChecker.getInstance().isBugOpen(bugId)) {
            log.fine("Invoking workaround for " + BzChecker.getInstance().getBugState(bugId).toString() + " Bugzilla " + bugId + ".  (https://bugzilla.redhat.com/show_bug.cgi?id=" + bugId + ")");
            SubscriptionManagerCLITestScript.addInvokedWorkaround(bugId);
        } else {
            invokeWorkaroundWhileBugIsOpen = false;
        }
    } catch (BugzillaAPIException be) {
    /* ignore exception */
    } catch (RuntimeException re) {
    /* ignore exception */
    }
    if (invokeWorkaroundWhileBugIsOpen) {
        throw new SkipException("blockedByBug-840509");
    }
    // END OF WORKAROUND
    // make sure we are newly registered with autosubscribe
    clienttasks.register(sm_clientUsername, sm_clientPassword, sm_clientOrg, null, null, null, null, true, null, null, (List<String>) null, null, null, null, true, null, null, null, null, null);
    // get the current base RHEL product cert
    String providingTag = "rhel-" + clienttasks.redhatReleaseX;
    List<ProductCert> rhelProductCerts = clienttasks.getCurrentProductCerts(providingTag);
    // TODO: Don't know how to predict which one since I believe Workstation is really born after consuming a child channel of Client rather than a base channel; for now let's just assume the other
    if (clienttasks.releasever.equals("5Client") && rhelProductCerts.isEmpty()) {
        providingTag += "-workstation";
        rhelProductCerts = clienttasks.getCurrentProductCerts(providingTag);
    }
    Assert.assertEquals(rhelProductCerts.size(), 1, "Only one product cert is installed that provides RHEL tag '" + providingTag + "'");
    ProductCert rhelProductCert = rhelProductCerts.get(0);
    // assert that it was autosubscribed
    InstalledProduct rhelInstalledProduct = InstalledProduct.findFirstInstanceWithMatchingFieldFromList("productId", rhelProductCert.productId, clienttasks.getCurrentlyInstalledProducts());
    Assert.assertNotNull(rhelInstalledProduct, "Our base installed RHEL product was autosubscribed during registration.");
    // get the actual release listing
    List<String> actualReleases = clienttasks.getCurrentlyAvailableReleases(null, null, null, null);
    // assert that the list excludes 5.6, 5.5, 5.4, 5.3, 5.2, 5.1, 5.0, but includes the current X.Y release
    for (String release : new String[] { "5.6", "5.5", "5.4", "5.3", "5.2", "5.1", "5.0" }) {
        Assert.assertTrue(!actualReleases.contains(release), "The subscription-manager releases list should exclude '" + release + "' since '" + clienttasks.command + "' did not exist in RHEL Release '" + release + "'.");
    }
// NOT PRACTICAL SINCE CONTENT FROM THIS Y-STREAM MAY NOT BE AVAILABLE UNTIL GA Assert.assertTrue(actualReleases.contains(clienttasks.redhatReleaseXY), "The subscription-manager releases list should include '"+clienttasks.redhatReleaseXY+"' since it is the current RHEL Release under test.");
}
Also used : InstalledProduct(rhsm.data.InstalledProduct) ProductCert(rhsm.data.ProductCert) SkipException(org.testng.SkipException) BugzillaAPIException(com.redhat.qe.auto.bugzilla.BugzillaAPIException) TestDefinition(com.github.redhatqe.polarize.metadata.TestDefinition) Test(org.testng.annotations.Test)

Example 30 with InstalledProduct

use of rhsm.data.InstalledProduct in project rhsm-qe by RedHatQE.

the class RAMTests method testDisableCertV3ForRamBasedSubscription.

/**
 * @author skallesh
 * @throws Exception
 * @throws JSONException
 */
@Test(description = "verify Ram Subscription with disabled certv3 from candlepin ", groups = { "Tier2Tests", "DisableCertV3ForRamBasedSubscription" }, enabled = false)
public void testDisableCertV3ForRamBasedSubscription() throws JSONException, Exception {
    servertasks.updateConfFileParameter("candlepin.enable_cert_v3", "false");
    servertasks.restartTomcat();
    SubscriptionManagerCLITestScript.sleep(1 * 60 * 1000);
    clienttasks.restart_rhsmcertd(null, null, null);
    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);
    for (InstalledProduct installed : getRamBasedProducts()) {
        Assert.assertEquals(installed.status.trim(), "Not Subscribed", "Status of installed product '" + installed.productName + "'.");
    }
}
Also used : InstalledProduct(rhsm.data.InstalledProduct) Test(org.testng.annotations.Test)

Aggregations

InstalledProduct (rhsm.data.InstalledProduct)77 Test (org.testng.annotations.Test)71 TestDefinition (com.github.redhatqe.polarize.metadata.TestDefinition)66 ImplementsNitrateTest (com.redhat.qe.auto.tcms.ImplementsNitrateTest)33 SkipException (org.testng.SkipException)27 SubscriptionPool (rhsm.data.SubscriptionPool)25 ArrayList (java.util.ArrayList)22 ProductCert (rhsm.data.ProductCert)21 ProductSubscription (rhsm.data.ProductSubscription)16 SSHCommandResult (com.redhat.qe.tools.SSHCommandResult)15 BugzillaAPIException (com.redhat.qe.auto.bugzilla.BugzillaAPIException)14 HashMap (java.util.HashMap)13 BigInteger (java.math.BigInteger)12 JSONObject (org.json.JSONObject)10 File (java.io.File)9 Calendar (java.util.Calendar)7 HashSet (java.util.HashSet)7 EntitlementCert (rhsm.data.EntitlementCert)6 GregorianCalendar (java.util.GregorianCalendar)5 JSONArray (org.json.JSONArray)5