Search in sources :

Example 21 with EntitlementCert

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

the class CertificateTests method testRctCatCertReportsOrdersWithQuantityUnlimited.

@// update=true,	// uncomment to make TestDefinition changes update Polarion testcases through the polarize testcase importer
TestDefinition(projectID = { Project.RHEL6, Project.RedHatEnterpriseLinux7 }, testCaseID = { "RHEL6-20032", "RHEL7-33086" }, 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 = "Tier1")
@Test(description = "assert that the rct cat-cert tool reports orders as Unlimited instead of -1", groups = { "Tier1Tests", "blockedByBug-1011961" }, enabled = true)
public // @ImplementsNitrateTest(caseId=)
void testRctCatCertReportsOrdersWithQuantityUnlimited() throws JSONException, Exception {
    int numberOfUnlimitedPools = 0;
    boolean isSystemVirtual = Boolean.valueOf(clienttasks.getFactValue("virt.is_guest"));
    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);
    for (SubscriptionPool pool : clienttasks.getCurrentlyAllAvailableSubscriptionPools()) {
        if (pool.quantity.equalsIgnoreCase("Unlimited")) {
            // skip physical_only subscriptions when run on a virtual system (not necessary if getCurrentlyAllAvailableSubscriptionPools() was changed to getCurrentlyAvailableSubscriptionPools())
            if (CandlepinTasks.isPoolRestrictedToPhysicalSystems(sm_clientUsername, sm_clientPassword, sm_serverUrl, pool.poolId) && isSystemVirtual)
                continue;
            // skip virt_only subscriptions when run on a physical system (not necessary if getCurrentlyAllAvailableSubscriptionPools() was changed to getCurrentlyAvailableSubscriptionPools())
            if (CandlepinTasks.isPoolRestrictedToVirtualSystems(sm_clientUsername, sm_clientPassword, sm_serverUrl, pool.poolId) && !isSystemVirtual)
                continue;
            numberOfUnlimitedPools++;
            File entitlementCertFile = clienttasks.subscribeToSubscriptionPool(pool, /*sm_serverAdminUsername*/
            sm_clientUsername, /*sm_serverAdminPassword*/
            sm_clientPassword, sm_serverUrl);
            EntitlementCert entitlementCert = clienttasks.getEntitlementCertFromEntitlementCertFile(entitlementCertFile);
            Assert.assertEquals(entitlementCert.orderNamespace.quantity, pool.quantity, "The Order:Quantity from the granted entitlement should match the Quantity from the available Subscription Pool: " + pool);
        } else if (pool.quantity.equals("-1")) {
            Assert.fail("Available SubscriptionPools should NOT report a quantity of '" + pool.quantity + "': " + pool);
        }
    }
    if (numberOfUnlimitedPools == 0)
        throw new SkipException("Could not find any available pools with an unlimited quantity for this test.");
}
Also used : EntitlementCert(rhsm.data.EntitlementCert) SkipException(org.testng.SkipException) 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 22 with EntitlementCert

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

the class ComplianceTests method testAutoSubscribeAttemptsWhenNotCompliantAndSomeProductsAreSubscribable.

@// update=true,	// uncomment to make TestDefinition changes update Polarion testcases through the polarize testcase importer
TestDefinition(projectID = { Project.RHEL6, Project.RedHatEnterpriseLinux7 }, testCaseID = { "RHEL6-21714", "RHEL7-51079" }, 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 = "Tier1")
@Test(description = "when some installed products are subscribable and system is NOT compliant, auto-subscribing again should try but not get any new entitlements", groups = { "Tier1Tests", "cli.tests", "blockedByBug-723044" }, // dependsOnMethods={"testSystemCompliantFactWhenSomeProductsAreSubscribable"},
priority = 320, enabled = true)
public // @ImplementsTCMS(id="")
void testAutoSubscribeAttemptsWhenNotCompliantAndSomeProductsAreSubscribable() throws JSONException, Exception {
    if (!configureProductCertDirForSomeProductsSubscribableCompleted)
        throw new SkipException("Unsatisfied dependency configureProductCertDirForSomeProductsSubscribableCompleted=" + configureProductCertDirForSomeProductsSubscribableCompleted);
    if (clienttasks.getCurrentlyRegisteredOwnerKey() == null)
        throw new SkipException("Unsatisfied dependency - expected system to already have been registered during a preceding testcase.");
    List<EntitlementCert> entitlementCertsBefore = clienttasks.getCurrentEntitlementCerts();
    SSHCommandResult result = clienttasks.subscribe(true, null, (List<String>) null, null, null, null, null, null, null, null, null, null, null);
    Assert.assertTrue(!result.getStdout().trim().startsWith(autosubscribeCompliantMessage), "When the system is not compliant, an attempt to auto-subscribe should NOT inform us with this message: " + autosubscribeCompliantMessage);
    List<EntitlementCert> entitlementCertsAfter = clienttasks.getCurrentEntitlementCerts();
    Assert.assertTrue(entitlementCertsBefore.containsAll(entitlementCertsAfter) && entitlementCertsAfter.containsAll(entitlementCertsBefore), "The entitlement certs have not changed after an attempt to autosubscribe a second time.");
    Assert.assertEquals(entitlementCertsBefore.size(), entitlementCertsAfter.size(), "The number of entitlement certs did not change after an attempt to autosubscribe a second time.");
}
Also used : EntitlementCert(rhsm.data.EntitlementCert) SSHCommandResult(com.redhat.qe.tools.SSHCommandResult) SkipException(org.testng.SkipException) TestDefinition(com.github.redhatqe.polarize.metadata.TestDefinition) Test(org.testng.annotations.Test)

Example 23 with EntitlementCert

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

the class ComplianceTests method setupProductCertDirsBeforeClass.

@BeforeClass(groups = { "setup" }, dependsOnMethods = { "moveOriginalProductCertDefaultDirFilesBeforeClass" })
public void setupProductCertDirsBeforeClass() throws JSONException, Exception {
    // clean out the productCertDirs
    for (String productCertDir : new String[] { productCertDirForSomeProductsSubscribable, productCertDirForAllProductsSubscribable, productCertDirForNoProductsSubscribable, productCertDirForNoProductsinstalled, productCertDirForAllProductsSubscribableInTheFuture, productCertDirForAllProductsSubscribableByOneCommonServiceLevel, productCertDirForAllProductsSubscribableByMoreThanOneCommonServiceLevel }) {
        RemoteFileTasks.runCommandAndAssert(client, "rm -rf " + productCertDir, 0);
        RemoteFileTasks.runCommandAndAssert(client, "mkdir " + productCertDir, 0);
    }
    // register and subscribe to all available subscriptions
    clienttasks.register(sm_clientUsername, sm_clientPassword, sm_clientOrg, null, null, null, null, null, null, null, (String) null, null, null, null, true, false, null, null, null, null);
    // to avoid unmapped_guests_only pools
    if (Boolean.valueOf(clienttasks.getFactValue("virt.is_guest")))
        clienttasks.mapSystemAsAGuestOfItself();
    clienttasks.subscribeToTheCurrentlyAvailableSubscriptionPoolsCollectively();
    // get the current certs
    List<EntitlementCert> currentEntitlementCerts = clienttasks.getCurrentEntitlementCerts();
    List<ProductCert> currentProductCerts = clienttasks.getCurrentProductCerts();
    List<InstalledProduct> installedProducts = clienttasks.getCurrentlyInstalledProducts();
    // distribute a copy of the product certs amongst the productCertDirs based on their status
    for (ProductCert productCert : currentProductCerts) {
        InstalledProduct installedProduct = clienttasks.getInstalledProductCorrespondingToProductCert(productCert, installedProducts);
        if (installedProduct.status.equals("Not Subscribed")) {
            // "Not Subscribed" case...
            RemoteFileTasks.runCommandAndAssert(client, "cp " + productCert.file + " " + productCertDirForNoProductsSubscribable, 0);
            RemoteFileTasks.runCommandAndAssert(client, "cp " + productCert.file + " " + productCertDirForSomeProductsSubscribable, 0);
        } else if (installedProduct.status.equals("Subscribed")) {
            // "Subscribed" case...
            RemoteFileTasks.runCommandAndAssert(client, "cp " + productCert.file + " " + productCertDirForAllProductsSubscribable, 0);
            RemoteFileTasks.runCommandAndAssert(client, "cp " + productCert.file + " " + productCertDirForSomeProductsSubscribable, 0);
        } else {
        // TODO "Partially Subscribed" case
        // InstalledProduct installedProduct = clienttasks.getInstalledProductCorrespondingToEntitlementCert(correspondingEntitlementCert);
        }
    }
    // setup for productCertDirForAllProductsSubscribableInTheFuture
    // clienttasks.unsubscribeFromAllOfTheCurrentlyConsumedProductSubscriptions();
    List<File> productCertFilesCopied = new ArrayList<File>();
    futureSystemSubscriptionPools = new ArrayList<SubscriptionPool>();
    for (List<Object> futureSystemSubscriptionPoolsDataRow : getAllFutureSystemSubscriptionPoolsDataAsListOfLists()) {
        SubscriptionPool futureSystemSubscriptionPool = (SubscriptionPool) futureSystemSubscriptionPoolsDataRow.get(0);
        // for (ProductCert productCert : clienttasks.getCurrentProductCertsProvidedBySubscriptionPool(futureSystemSubscriptionPool)) {	// TODO not efficient; testing fix on next line
        for (ProductCert productCert : clienttasks.getProductCertsProvidedBySubscriptionPool(currentProductCerts, futureSystemSubscriptionPool)) {
            if (!productCertFilesCopied.contains(productCert.file)) {
                // RemoteFileTasks.runCommandAndAssert(client, "cp -n "+productCert.file+" "+productCertDirForAllProductsSubscribableInTheFuture, 0);	// RHEL5 does not understand cp -n
                // no clobber copy for both RHEL5 ad RHEL6
                RemoteFileTasks.runCommandAndAssert(client, "if [ ! -e " + productCertDirForAllProductsSubscribableInTheFuture + File.separator + productCert.file.getName() + " ]; then cp " + productCert.file + " " + productCertDirForAllProductsSubscribableInTheFuture + "; fi;", 0);
                productCertFilesCopied.add(productCert.file);
                if (!futureSystemSubscriptionPools.contains(futureSystemSubscriptionPool)) {
                    futureSystemSubscriptionPools.add(futureSystemSubscriptionPool);
                }
            }
        }
    }
    // determine the serviceLevel and all the products that are subscribable by one common service level
    // Map<String,Set<String>> serviceLevelToProductIdsMap = getServiceLevelToProductIdsMapFromEntitlementCerts(clienttasks.getCurrentEntitlementCerts());	// TODO not efficient; testing fix on next line
    Map<String, Set<String>> serviceLevelToProductIdsMap = getServiceLevelToProductIdsMapFromEntitlementCerts(currentEntitlementCerts);
    // /*debugTesting*/ serviceLevelToProductIdsMap.get("Premium").add("17000");
    Map<String, Set<String>> productIdsToServiceLevelsMap = getInvertedMap(serviceLevelToProductIdsMap);
    Set<String> allProductsSubscribableByOneCommonServiceLevelCandidates = productIdsToServiceLevelsMap.keySet();
    boolean allProductsSubscribableByOneCommonServiceLevelDeterminable = true;
    OUT: do {
        String serviceLevelCandidate = getKeyToLongestMap(serviceLevelToProductIdsMap);
        Assert.assertNotNull(serviceLevelCandidate, "If the key to the longest map of serviceLevel to ProductIds is null, then there are probably no subscriptions available.");
        // does this candidate have all candidate products?
        if (serviceLevelToProductIdsMap.get(serviceLevelCandidate).containsAll(allProductsSubscribableByOneCommonServiceLevelCandidates)) {
            // is there another serviceLevel that has all candidate products?
            for (String serviceLevel : serviceLevelToProductIdsMap.keySet()) {
                if (serviceLevel.equals(serviceLevelCandidate))
                    continue;
                if (serviceLevelToProductIdsMap.get(serviceLevel).size() == serviceLevelToProductIdsMap.get(serviceLevelCandidate).size()) {
                    allProductsSubscribableByOneCommonServiceLevelDeterminable = false;
                    break OUT;
                }
            }
            allProductsSubscribableByOneCommonServiceLevelValue = serviceLevelCandidate;
        } else {
            // pluck the first candidate product that is not in the serviceLevelCandidate map of products
            for (String productId : (String[]) allProductsSubscribableByOneCommonServiceLevelCandidates.toArray(new String[] {})) {
                if (!serviceLevelToProductIdsMap.get(serviceLevelCandidate).contains(productId)) {
                    allProductsSubscribableByOneCommonServiceLevelCandidates.remove(productId);
                    for (String serviceLevel : serviceLevelToProductIdsMap.keySet()) {
                        serviceLevelToProductIdsMap.get(serviceLevel).remove(productId);
                    }
                    break;
                }
            }
        }
    } while (allProductsSubscribableByOneCommonServiceLevelValue == null && allProductsSubscribableByOneCommonServiceLevelDeterminable);
    // copy the products to productCertDirForAllProductsSubscribableByOneCommonServiceLevel
    if (allProductsSubscribableByOneCommonServiceLevelDeterminable) {
        // for (ProductCert productCert : clienttasks.getCurrentProductCerts()) {	// TODO not efficient; testing fix on next line
        for (ProductCert productCert : currentProductCerts) {
            if (allProductsSubscribableByOneCommonServiceLevelCandidates.contains(productCert.productId)) {
                RemoteFileTasks.runCommandAndAssert(client, "cp " + productCert.file + " " + productCertDirForAllProductsSubscribableByOneCommonServiceLevel, 0);
            }
        }
    } else {
        log.warning("Cannot determine a set of products where allProductsSubscribableByOneCommonServiceLevel.");
    }
    // determine the serviceLevels and all the products that are subscribable by more than one common service level
    // serviceLevelToProductIdsMap = getServiceLevelToProductIdsMapFromEntitlementCerts(clienttasks.getCurrentEntitlementCerts());	// TODO not efficient; testing fix on next line
    serviceLevelToProductIdsMap = getServiceLevelToProductIdsMapFromEntitlementCerts(currentEntitlementCerts);
    productIdsToServiceLevelsMap = getInvertedMap(serviceLevelToProductIdsMap);
    List<String> allProductsSubscribableByMoreThanOneCommonServiceLevelCandidates = new ArrayList<String>();
    for (String productId : productIdsToServiceLevelsMap.keySet()) {
        if (productIdsToServiceLevelsMap.get(productId).size() > 1)
            allProductsSubscribableByMoreThanOneCommonServiceLevelCandidates.add(productId);
    }
    if (!allProductsSubscribableByMoreThanOneCommonServiceLevelCandidates.isEmpty()) {
        // randomly choose the service levels from the candidates
        // allProductsSubscribableByMoreThanOneCommonServiceLevelValues = Arrays.asList(productIdsToServiceLevelsMap.get(allProductsSubscribableByMoreThanOneCommonServiceLevelCandidates.get(randomGenerator.nextInt(allProductsSubscribableByMoreThanOneCommonServiceLevelCandidates.size()))).toArray(new String[]{}));
        allProductsSubscribableByMoreThanOneCommonServiceLevelValues.addAll(productIdsToServiceLevelsMap.get(allProductsSubscribableByMoreThanOneCommonServiceLevelCandidates.get(randomGenerator.nextInt(allProductsSubscribableByMoreThanOneCommonServiceLevelCandidates.size()))));
        // pluck out the productIds that do not map to all of the values in allProductsSubscribableByMoreThanOneCommonServiceLevelValues
        for (String productId : productIdsToServiceLevelsMap.keySet()) {
            if (!productIdsToServiceLevelsMap.get(productId).containsAll(allProductsSubscribableByMoreThanOneCommonServiceLevelValues)) {
                allProductsSubscribableByMoreThanOneCommonServiceLevelCandidates.remove(productId);
            }
        }
        // for (ProductCert productCert : clienttasks.getCurrentProductCerts()) {	// TODO not efficient; testing fix on next line
        for (ProductCert productCert : currentProductCerts) {
            if (allProductsSubscribableByMoreThanOneCommonServiceLevelCandidates.contains(productCert.productId)) {
                RemoteFileTasks.runCommandAndAssert(client, "cp " + productCert.file + " " + productCertDirForAllProductsSubscribableByMoreThanOneCommonServiceLevel, 0);
            }
        }
    } else {
        log.warning("Cannot determine a set of products where allProductsSubscribableByMoreThanOneCommonServiceLevel.");
    }
    // remember the originally configured productCertDir
    this.originalProductCertDir = clienttasks.productCertDir;
}
Also used : HashSet(java.util.HashSet) Set(java.util.Set) EntitlementCert(rhsm.data.EntitlementCert) ArrayList(java.util.ArrayList) ProductCert(rhsm.data.ProductCert) InstalledProduct(rhsm.data.InstalledProduct) File(java.io.File) SubscriptionPool(rhsm.data.SubscriptionPool) BeforeClass(org.testng.annotations.BeforeClass)

Example 24 with EntitlementCert

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

the class ComplianceTests method getServiceLevelToProductIdsMapFromEntitlementCerts.

protected Map<String, Set<String>> getServiceLevelToProductIdsMapFromEntitlementCerts(List<EntitlementCert> entitlementCerts) {
    // {Standard=[37065, 27060, 37069, 37068, 37067, 37070,        37060],
    // None    =[37060],
    // Premium =[37065,        37069, 37068, 37067, 37070,        37060]}
    // 
    // 
    // {27060=[Standard],
    // 37065=[Standard, Premium],
    // 37069=[Standard, Premium],
    // 37068=[Standard, Premium],
    // 37067=[Standard, Premium],
    // 37070=[Standard, Premium],
    // 37060=[Standard, Premium, None]}
    // create maps of serviceLevel-to-productIds and productIds-to-serviceLevel
    Map<String, Set<String>> serviceLevelToProductIdsMap = new HashMap<String, Set<String>>();
    for (EntitlementCert entitlementCert : entitlementCerts) {
        String serviceLevel = entitlementCert.orderNamespace.supportLevel;
        // skip all entitlements without a service level
        if (serviceLevel == null || serviceLevel.equals(""))
            continue;
        // skip all entitlements with an exempt service level
        if (sm_exemptServiceLevelsInUpperCase.contains(serviceLevel.toUpperCase()))
            continue;
        if (!serviceLevelToProductIdsMap.containsKey(serviceLevel))
            serviceLevelToProductIdsMap.put(serviceLevel, new HashSet<String>());
        HashSet<String> productIdSet = (HashSet<String>) serviceLevelToProductIdsMap.get(serviceLevel);
        for (ProductNamespace productNamespace : entitlementCert.productNamespaces) {
            // /*debugTesting*/ if (productNamespace.id.equals("27060")) continue;
            productIdSet.add(productNamespace.id);
        }
    }
    return serviceLevelToProductIdsMap;
}
Also used : HashSet(java.util.HashSet) Set(java.util.Set) EntitlementCert(rhsm.data.EntitlementCert) HashMap(java.util.HashMap) ProductNamespace(rhsm.data.ProductNamespace) HashSet(java.util.HashSet)

Example 25 with EntitlementCert

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

the class ContentIntegrationTests method testInstallAndRemoveUniquePackageFromContentNamespace.

@Test(description = "ensure a unique available package can be installed/removed from the enabled repo ", groups = { "Tier2Tests" }, dependsOnMethods = { "testRegisterAndSubscribe" }, alwaysRun = true, dependsOnGroups = { "VerifyPackagesAreAvailable" }, dataProvider = "getContentNamespaceData", // disabled in favor of various ContentTests which do not depend on the maintenance of dataProvider="getSubscribeData"
enabled = false)
public // @ImplementsNitrateTest(caseId=) //TODO Find a tcms caseId
void testInstallAndRemoveUniquePackageFromContentNamespace(String username, String password, ConsumerType type, String productId, Integer sockets, ContentNamespace contentNamespace) {
    EntitlementCert entitlementCert = recallTheEntitlementCertGrantedAfterSubscribing(username, password, type, productId, sockets);
    // if (!contentNamespace.label.equals("rhel-6-server-beta-debug-rpms")) throw new SkipException("debugging");
    // register
    registerConsumerWhenNotAlreadyRegistered(username, password, type, sockets);
    // subscribe
    if (!currentlySubscribedProductIds.contains(productId)) {
        // try to save some time by not re-subscribing
        clienttasks.subscribeToProductId(productId);
        currentlySubscribedProductIds.add(productId);
    } else {
        log.info("Saving time by assuming that we are already subscribed to productId='" + productId + "'");
    // clienttasks.list_(null,null,null, Boolean.TRUE, null, null, null, null);
    }
    // make sure that the products required for this repo are installed
    /* not needed anymore since this case is already filtered out by the dataProvider
		if (!clienttasks.areAllRequiredTagsInContentNamespaceProvidedByProductCerts(contentNamespace, currentProductCerts)) {
			throw new SkipException("This contentNamespace has requiredTags '"+contentNamespace.requiredTags+"' that were not found amongst all of the currently installed products.  Therefore we cannot install and remove any package from repo '"+contentNamespace.label+"'.");
		}
		*/
    // make sure there is a positive package count provided by this repo
    /* not needed anymore since this case is already filtered out by the dataProvider
		Integer packageCount = clienttasks.getYumRepolistPackageCount(contentNamespace.label+" --enablerepo="+contentNamespace.label);
		if (packageCount==0) {
			throw new SkipException("Cannot install a package from this repo '"+contentNamespace.label+"' since it is not providing any packages.");
		}
		*/
    // find an available package that is uniquely provided by this repo
    String pkg = clienttasks.findUniqueAvailablePackageFromRepo(contentNamespace.label);
    if (pkg == null) {
        throw new SkipException("Could NOT find a unique available package from this repo '" + contentNamespace.label + "' to attempt an install/remove test.");
    }
    // pkg="cairo-spice-debuginfo.x86_64";
    // install the package and assert that it is successfully installed
    // pkgInstalled = true;
    clienttasks.yumInstallPackageFromRepo(pkg, contentNamespace.label, null);
    // 06/09/2011 TODO Would also like to add an assert that the productid.pem file is also installed.
    /* To do this, we need to also include the List of ProductNamepaces from the entitlement cert as another argument to this test,
		 * Then after the yum install, we need to make sure that at least one of the hash values in the list of product ids is
		 * included in the installed products.  If the list of ProductNamespaces from the entitlement cert is one, then this is
		 * a definitive test.  If the list is greater than one, then we don't know for sure if the product hash(s) that is installed is actually the 
		 * right one.  But we do know that if none of the product hashes are installed, then the repo is missing the product ids and this test should fail.
		 * Also note that we should probably make this assertion after removing the package so that we don't over install all the packages in the repo.
		 */
    // 06/10/2011 Mostly Done in the following blocks of code; jsefler
    // determine if at least one of the productids from the productNamespaces was found installed on the client after running yumInstallPackageFromRepo(...)
    // ideally there is only one ProductNamespace in productNamespaces in which case we can definitively know that the correct product cert is installed
    // when there are more than one ProductNamespace in productNamespaces, then we can't say for sure if the product cert installed actually corresponds to the repo under test
    // however if none of the productNamespaces ends up installed, then the yum product-id plugin is not installing the expected product cert
    int numberOfProductNamespacesInstalled = 0;
    ProductCert productCertInstalled = null;
    for (ProductCert productCert : clienttasks.getCurrentProductCerts()) {
        for (ProductNamespace productNamespace : entitlementCert.productNamespaces) {
            if (productNamespace.id.equals(productCert.productId)) {
                numberOfProductNamespacesInstalled++;
                productCertInstalled = productCert;
            }
        }
    }
    // FIXME check if the package was obsolete and its replacement was installed instead
    // if (!obsoletedByPkg.isEmpty()) pkg = obsoletedByPkg;
    // now remove the package
    clienttasks.yumRemovePackage(pkg);
    // Note: I am making this assertion after the yumRemovePackage call to avoid leaving packages installed in case this assert fails.
    if (numberOfProductNamespacesInstalled > 1) {
        log.info("Found product certs installed that match the ProductNamespaces from the entitlement cert that granted the right to install package '" + pkg + "' from repo '" + contentNamespace.label + "'.");
    } else if (numberOfProductNamespacesInstalled == 1) {
        Assert.assertTrue(true, "An installed product cert (productName='" + productCertInstalled.productName + "' productId='" + productCertInstalled.productId + "') corresponding to installed package '" + pkg + "' from repo '" + contentNamespace.label + "' was found after it was installed.");
    } else {
        Assert.fail("After installing package '" + pkg + "' from repo '" + contentNamespace.label + "', there was no product cert installed.  Expected one of the following product certs to get installed via the yum product-id plugin: " + entitlementCert.productNamespaces);
    }
}
Also used : EntitlementCert(rhsm.data.EntitlementCert) ProductCert(rhsm.data.ProductCert) SkipException(org.testng.SkipException) ProductNamespace(rhsm.data.ProductNamespace) Test(org.testng.annotations.Test)

Aggregations

EntitlementCert (rhsm.data.EntitlementCert)94 Test (org.testng.annotations.Test)63 TestDefinition (com.github.redhatqe.polarize.metadata.TestDefinition)58 SkipException (org.testng.SkipException)39 ArrayList (java.util.ArrayList)38 File (java.io.File)36 ImplementsNitrateTest (com.redhat.qe.auto.tcms.ImplementsNitrateTest)35 SubscriptionPool (rhsm.data.SubscriptionPool)33 SSHCommandResult (com.redhat.qe.tools.SSHCommandResult)30 JSONObject (org.json.JSONObject)29 ContentNamespace (rhsm.data.ContentNamespace)26 ProductCert (rhsm.data.ProductCert)23 BugzillaAPIException (com.redhat.qe.auto.bugzilla.BugzillaAPIException)17 BigInteger (java.math.BigInteger)17 ProductSubscription (rhsm.data.ProductSubscription)17 List (java.util.List)16 Calendar (java.util.Calendar)11 HashMap (java.util.HashMap)11 ProductNamespace (rhsm.data.ProductNamespace)11 HashSet (java.util.HashSet)8