Search in sources :

Example 71 with ImplementsNitrateTest

use of com.redhat.qe.auto.tcms.ImplementsNitrateTest in project rhsm-qe by RedHatQE.

the class MultiClientTests method testMultiClientRegisterAsPerson.

@// update=true,	// uncomment to make TestDefinition changes update Polarion testcases through the polarize testcase importer
TestDefinition(projectID = { Project.RHEL6, Project.RedHatEnterpriseLinux7 }, testCaseID = { "RHEL6-21881", "RHEL7-51733" }, 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 that only one person can be registered under username at a time", groups = { "Tier3Tests", "MultiClientRegisterAsPerson_Test" }, enabled = true)
public // @ImplementsNitrateTest(caseId=)
void testMultiClientRegisterAsPerson() throws JSONException, Exception {
    // test prerequisites
    if (client2tasks == null)
        throw new SkipException("This multi-client test requires a second client.");
    if (clienttasks.isPackageVersion("subscription-manager", ">=", "1.20.2-1")) {
        // post commit e0c34a729e9e347ab1e0f4f5fa656c8b20205fdf RFE Bug 1461003: Deprecate --type option on register command
        throw new SkipException("This test is no longer applicable using subscription-manager version >= 1.20.2-1 due to RFE Bug 1461003 which deprecated the ability to register with --type.  Attempting to register with --type=person will yield an Error: The --type option has been deprecated and may not be used.");
    }
    unregisterMultiClientRegisterAsPersonAfterGroups();
    // decide what username and password to test with
    String username = sm_clientUsername;
    String password = sm_clientPassword;
    String owner = sm_clientOrg;
    if (!sm_rhpersonalUsername.equals("")) {
        username = sm_rhpersonalUsername;
        password = sm_rhpersonalPassword;
        owner = sm_rhpersonalOrg;
    }
    // personIdForMultiClientRegisterAsPerson_Test = client1tasks.getCurrentConsumerId(client1tasks.register(clientusername, clientpassword, ConsumerType.person, null, null, null, null, null, null, null));
    client1tasks.register(username, password, owner, null, ConsumerType.person, null, null, null, null, null, (String) null, null, null, null, null, false, null, null, null, null);
    // attempt to register a second person consumer using the same username
    SSHCommandResult sshCommandResult = client2tasks.register_(username, password, owner, null, ConsumerType.person, null, null, null, null, null, (String) null, null, null, null, null, null, null, null, null, null);
    // assert the sshCommandResult here
    // User testuser1 has already registered a personal consumer
    // Assert.assertContainsMatch(sshCommandResult.getStderr().trim(), String.format("User %s has already registered a personal consumer", username),"stderr after attempt to register same person from a second different client:");
    Assert.assertContainsMatch(sshCommandResult.getStderr().trim(), String.format("User '%s' has already registered a personal consumer", username), "stderr after attempt to register same person from a second different client:");
    Integer expectedExitCode = new Integer(255);
    // EX_SOFTWARE	// post commit df95529a5edd0be456b3528b74344be283c4d258 bug 1119688
    if (clienttasks.isPackageVersion("subscription-manager", ">=", "1.13.8-1"))
        expectedExitCode = new Integer(70);
    Assert.assertEquals(sshCommandResult.getExitCode(), expectedExitCode, "exitCode after attempt to register same person from a second different client");
}
Also used : SSHCommandResult(com.redhat.qe.tools.SSHCommandResult) SkipException(org.testng.SkipException) TestDefinition(com.github.redhatqe.polarize.metadata.TestDefinition) Test(org.testng.annotations.Test) ImplementsNitrateTest(com.redhat.qe.auto.tcms.ImplementsNitrateTest)

Example 72 with ImplementsNitrateTest

use of com.redhat.qe.auto.tcms.ImplementsNitrateTest in project rhsm-qe by RedHatQE.

the class ContentTests method testArchRestrictedContentSetsEntitledAfterSubscribeAllSatisfiesTheSystemArch.

@// update=true	// uncomment to make TestDefinition changes update Polarion testcases through the polarize testcase importer
TestDefinition(projectID = { Project.RHEL6, Project.RedHatEnterpriseLinux7 }, testCaseID = { "RHEL6-20080", "RHEL7-33076" }, 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 = "Verify that all content sets granted from a subscription pool that are restricted to specific arches satisfy the current system's arch.", groups = { "Tier1Tests", "blockedByBug-706187", "blockedByBug-975520", "VerifyArchRestrictedContentSetsEntitledAfterSubscribeAllSatisfiesTheSystemArch_Test" }, enabled = true)
public // @ImplementsNitrateTest(caseId=)
void testArchRestrictedContentSetsEntitledAfterSubscribeAllSatisfiesTheSystemArch() throws JSONException, Exception {
    // get a list of all of the available poolIds that provide arch-based content sets
    List<List<Object>> subscriptionPoolsDataList = getAllAvailableSubscriptionPoolsProvidingArchBasedContentDataAsListOfLists();
    List<String> archBasedSubscriptionPoolIds = new ArrayList<String>();
    for (List<Object> subscriptionPoolsData : subscriptionPoolsDataList) {
        SubscriptionPool pool = (SubscriptionPool) subscriptionPoolsData.get(0);
        archBasedSubscriptionPoolIds.add(pool.poolId);
    }
    if (archBasedSubscriptionPoolIds.isEmpty())
        throw new SkipException("No subscriptions were found providing non-empty arch-based content.");
    // iterate over several possible system arches
    Map<String, String> factsMap = new HashMap<String, String>();
    for (String systemArch : Arrays.asList(new String[] { "i386", "i586", "i686", "x86_64", "ppc", "ppc64", "ia64", "arm", "s390", "s390x" })) {
        // avoid throttling RateLimitExceededException from IT-Candlepin
        if (CandlepinType.hosted.equals(sm_serverType)) {
            // strategically get a new consumer to avoid 60 repeated API calls from the same consumer
            // re-register as a new consumer
            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);
        } else
            // clienttasks.unsubscribe(true, (BigInteger)null, null, null, null);
            // return all current entitlements (Note: system is already registered by getAllAvailableSubscriptionPoolsProvidingArchBasedContentDataAsListOfLists())
            clienttasks.unsubscribe(true, (BigInteger) null, null, null, null, null, null);
        // fake the system's arch and update the facts
        log.info("Manipulating the system facts into thinking this is a '" + systemArch + "' system...");
        factsMap.put("uname.machine", String.valueOf(systemArch));
        clienttasks.createFactsFileWithOverridingValues(factsMap);
        clienttasks.facts(null, true, null, null, null, null);
        // subscribe to all the arch-based content set pools
        clienttasks.subscribe(false, null, archBasedSubscriptionPoolIds, null, null, null, null, null, null, null, null, null, null);
        // iterate over all of the granted entitlements
        for (EntitlementCert entitlementCert : clienttasks.getCurrentEntitlementCerts()) {
            for (ContentNamespace contentNamespace : entitlementCert.contentNamespaces) {
                if (contentNamespace.arches == null)
                    Assert.fail("This version of subscription-manager does not appear to parse arch restricted content.  Upgrade to a newer build of subscription-manager.");
                List<String> arches = new ArrayList<String>();
                // Note: the arches field can be a comma separated list of values
                if (!contentNamespace.arches.trim().isEmpty())
                    arches.addAll(Arrays.asList(contentNamespace.arches.trim().split(" *, *")));
                // Note: x86 is a general arch to cover all 32-bit intel microprocessors
                if (arches.contains("x86")) {
                    arches.addAll(Arrays.asList("i386", "i486", "i586", "i686"));
                }
                Assert.assertTrue(arches.isEmpty() || arches.contains("ALL") || arches.contains("noarch") || arches.contains(systemArch), "Content label '" + contentNamespace.label + "' restricted to arches '" + contentNamespace.arches + "' granted by entitlement cert '" + entitlementCert.orderNamespace.productName + "' matches the system's arch '" + systemArch + "'.");
            }
        }
    }
}
Also used : EntitlementCert(rhsm.data.EntitlementCert) HashMap(java.util.HashMap) ArrayList(java.util.ArrayList) ContentNamespace(rhsm.data.ContentNamespace) BigInteger(java.math.BigInteger) ArrayList(java.util.ArrayList) List(java.util.List) JSONObject(org.json.JSONObject) 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 ImplementsNitrateTest

use of com.redhat.qe.auto.tcms.ImplementsNitrateTest in project rhsm-qe by RedHatQE.

the class ContentTests method testEUSProductContentSetsAssertingNonEmptyModifiesProducts.

@// update=true	// uncomment to make TestDefinition changes update Polarion testcases through the polarize testcase importer
TestDefinition(projectID = { Project.RHEL6, Project.RedHatEnterpriseLinux7 }, testCaseID = { "RHEL6-47914", "RHEL7-97069" }, linkedWorkItems = { @LinkedItem(// RHSM-REQ : Modifier Subscriptions (EUS)
workitemId = "RHEL6-28570", project = Project.RHEL6, role = DefTypes.Role.RELATES_TO), @LinkedItem(// RHSM-REQ : Modifier Subscriptions (EUS)
workitemId = "RHEL7-84951", project = Project.RedHatEnterpriseLinux7, role = DefTypes.Role.RELATES_TO) }, 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 = "Verify Extended Update Support content set repos (identified as containing '-eus-') have a non-empty list of modifiedProductIds", groups = { "Tier1Tests" }, dataProvider = "getAllEUSProductContentSetData", enabled = true)
public // @ImplementsNitrateTest(caseId=)
void testEUSProductContentSetsAssertingNonEmptyModifiesProducts(Object bugzilla, String eusProductName, String eusProductId, String eusContentSetName, String eusContentSetId, String eusContentSetLabel, List<String> modifiedProductIds) throws JSONException, Exception {
    log.info("The following curl request can be used to fetch the Candlepin representation for EUS Content Set '" + eusContentSetName + "': " + eusContentSetLabel);
    JSONObject jsonContent = new JSONObject(CandlepinTasks.getResourceUsingRESTfulAPI(sm_clientUsername, sm_clientPassword, sm_serverUrl, "/owners/" + getAllEUSProductContentSetDataAsListOfListsOwnerKey + "/content/" + eusContentSetId));
    // [root@jsefler-rhel7 ~]# curl --stderr /dev/null --insecure --user stage_ha_testuser:redhat --request GET 'https://subscription.rhsm.stage.redhat.com:443/subscription/owners/10992327/content/4180' | python -m json/tool
    // {
    // "arches": "x86_64",
    // "contentUrl": "/content/eus/rhel/server/7/$releasever/$basearch/highavailability/os",
    // "created": "2017-05-31T17:29:04+0000",
    // "gpgUrl": "file:///etc/pki/rpm-gpg/RPM-GPG-KEY-redhat-release",
    // "id": "4180",
    // "label": "rhel-ha-for-rhel-7-server-eus-rpms",
    // "metadataExpire": 86400,
    // "modifiedProductIds": [],
    // "name": "Red Hat Enterprise Linux High Availability (for RHEL 7 Server) - Extended Update Support (RPMs)",
    // "releaseVer": null,
    // "requiredTags": "rhel-7-server",
    // "type": "yum",
    // "updated": "2017-05-31T17:29:04+0000",
    // "uuid": "8a99f9825c5f84ae015c5f8dc05f0a77",
    // "vendor": "Red Hat"
    // }
    log.info("EUS Engineering Product:           " + eusProductName);
    log.info("EUS Engineering ProductId:         " + eusProductId);
    log.info("EUS ContentSet Repo Name:          " + eusContentSetName);
    log.info("EUS ContentSet Repo Label:         " + eusContentSetLabel);
    log.info("EUS ContentSet id:                 " + eusContentSetId);
    log.info("EUS ContentSet modifiedProductIds: " + modifiedProductIds);
    // if this does not pass, then the Candlepin API for /owners/{owner_key}/content/{content_id} is returning different values than returned from /owners/{owner_key}/products
    Assert.assertEquals(jsonContent.get("name"), eusContentSetName);
    // if this does not pass, then the Candlepin API for /owners/{owner_key}/content/{content_id} is returning different values than returned from /owners/{owner_key}/products
    Assert.assertEquals(jsonContent.get("label"), eusContentSetLabel);
    // skip Red Hat Software Collections
    if (modifiedProductIds.isEmpty() && eusContentSetLabel.contains("-rhscl-") && eusProductName.startsWith("Red Hat Software Collections")) {
        throw new SkipException("Skipping '" + eusProductName + "' content set '" + eusContentSetLabel + "' because both the eus and non-eus rhscl repos are both provided by the same engineering product.  Hence a subscription to a Red Hat Software Collection includes extended update support.");
    }
    // does this pool contain productContents that modify other products?
    Assert.assertTrue(!modifiedProductIds.isEmpty(), "EUS Product '" + eusProductName + "' (id=" + eusProductId + ") content set repository '" + eusContentSetLabel + "' (id=" + eusContentSetId + ") modifies a NON-EMPTY list of engineering productIds (actualModifiedProductIds=" + modifiedProductIds + ")");
}
Also used : JSONObject(org.json.JSONObject) SkipException(org.testng.SkipException) TestDefinition(com.github.redhatqe.polarize.metadata.TestDefinition) Test(org.testng.annotations.Test) ImplementsNitrateTest(com.redhat.qe.auto.tcms.ImplementsNitrateTest)

Example 74 with ImplementsNitrateTest

use of com.redhat.qe.auto.tcms.ImplementsNitrateTest in project rhsm-qe by RedHatQE.

the class ContentTests method testRedHatRepoFileDoesNotContainExcessiveBlankLines_DEPRECATED.

@Test(description = "verify redhat.repo file does not contain an excessive (more than two) number of successive blank lines", groups = { "Tier2Tests", "blockedByBug-737145" }, // Disabling... this test takes too long to execute.  VerifyRedHatRepoFileIsPurgedOfBlankLinesByYumPlugin_Test effectively provides the same test coverage.
enabled = false)
@Deprecated
public // @ImplementsNitrateTest(caseId=)
void testRedHatRepoFileDoesNotContainExcessiveBlankLines_DEPRECATED() {
    // successive blank lines in redhat.repo must not exceed N
    // (\n\s*){4,}
    int N = 2;
    // (\n\s*){4,}
    String regex = "(\\n\\s*){" + (N + 2) + ",}";
    String redhatRepoFileContents = "";
    // check for excessive blank lines after a new register
    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);
    // --disableplugin=rhnplugin helps avoid: up2date_client.up2dateErrors.AbuseError
    client.runCommandAndWait("yum -q repolist --disableplugin=rhnplugin");
    redhatRepoFileContents = client.runCommandAndWait("cat " + clienttasks.redhatRepoFile).getStdout();
    Assert.assertContainsNoMatch(redhatRepoFileContents, regex, null, "At most '" + N + "' successive blank are acceptable inside " + clienttasks.redhatRepoFile);
    // check for excessive blank lines after subscribing to each pool
    for (SubscriptionPool pool : clienttasks.getCurrentlyAvailableSubscriptionPools()) {
        clienttasks.subscribe_(null, null, pool.poolId, null, null, null, null, null, null, null, null, null, null);
        // --disableplugin=rhnplugin helps avoid: up2date_client.up2dateErrors.AbuseError
        client.runCommandAndWait("yum -q repolist --disableplugin=rhnplugin");
    }
    redhatRepoFileContents = client.runCommandAndWait("cat " + clienttasks.redhatRepoFile).getStdout();
    Assert.assertContainsNoMatch(redhatRepoFileContents, regex, null, "At most '" + N + "' successive blank are acceptable inside " + clienttasks.redhatRepoFile);
    // check for excessive blank lines after unsubscribing from each serial
    List<BigInteger> serialNumbers = new ArrayList<BigInteger>();
    for (ProductSubscription productSubscription : clienttasks.getCurrentlyConsumedProductSubscriptions()) {
        // save some time by avoiding redundant unsubscribes
        if (serialNumbers.contains(productSubscription.serialNumber))
            continue;
        clienttasks.unsubscribe_(null, productSubscription.serialNumber, null, null, null, null, null);
        serialNumbers.add(productSubscription.serialNumber);
        // --disableplugin=rhnplugin helps avoid: up2date_client.up2dateErrors.AbuseError
        client.runCommandAndWait("yum -q repolist --disableplugin=rhnplugin");
    }
    redhatRepoFileContents = client.runCommandAndWait("cat " + clienttasks.redhatRepoFile).getStdout();
    Assert.assertContainsNoMatch(redhatRepoFileContents, regex, null, "At most '" + N + "' successive blank are acceptable inside " + clienttasks.redhatRepoFile);
    // assert the comment heading is present
    // Assert.assertContainsMatch(redhatRepoFileContents,"^# Red Hat Repositories$",null,"Comment heading \"Red Hat Repositories\" was found inside "+clienttasks.redhatRepoFile);
    Assert.assertContainsMatch(redhatRepoFileContents, "^# Certificate-Based Repositories$", null, "Comment heading \"Certificate-Based Repositories\" was found inside " + clienttasks.redhatRepoFile);
    Assert.assertContainsMatch(redhatRepoFileContents, "^# Managed by \\(rhsm\\) subscription-manager$", null, "Comment heading \"Managed by (rhsm) subscription-manager\" was found inside " + clienttasks.redhatRepoFile);
}
Also used : ArrayList(java.util.ArrayList) ProductSubscription(rhsm.data.ProductSubscription) BigInteger(java.math.BigInteger) SubscriptionPool(rhsm.data.SubscriptionPool) Test(org.testng.annotations.Test) ImplementsNitrateTest(com.redhat.qe.auto.tcms.ImplementsNitrateTest)

Example 75 with ImplementsNitrateTest

use of com.redhat.qe.auto.tcms.ImplementsNitrateTest in project rhsm-qe by RedHatQE.

the class ContentTests method testEnableDisableManageReposAndVerifyContentAvailable.

// Test methods ***********************************************************************
@// update=true	// uncomment to make TestDefinition changes update Polarion testcases through the polarize testcase importer
TestDefinition(projectID = { Project.RHEL6, Project.RedHatEnterpriseLinux7 }, testCaseID = { "RHEL6-25987", "RHEL7-51485" }, 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 Yum plugin: enable/disable", groups = { "Tier2Tests", "FipsTests", "EnableDisableManageReposAndVerifyContentAvailable_Test", "blockedByBug-804227", "blockedByBug-871146", "blockedByBug-905546", "blockedByBug-1017866" }, // dataProvider="getAvailableSubscriptionPoolsData",	// very thorough, but takes too long to execute and rarely finds more bugs
dataProvider = "getRandomSubsetOfAvailableSubscriptionPoolsData", enabled = true)
@ImplementsNitrateTest(caseId = 41696, fromPlan = 2479)
public void testEnableDisableManageReposAndVerifyContentAvailable(SubscriptionPool pool) throws JSONException, Exception {
    // get the currently installed product certs to be used when checking for conditional content tagging
    List<ProductCert> currentProductCerts = clienttasks.getCurrentProductCerts();
    log.info("Before beginning this test, we will stop the rhsmcertd so that it does not interfere with this test and make sure we are not subscribed...");
    clienttasks.stop_rhsmcertd();
    clienttasks.unsubscribe_(true, (BigInteger) null, null, null, null, null, null);
    // Enable rhsm manage_repos configuration
    clienttasks.config(null, null, true, new String[] { "rhsm", "manage_repos", "1" });
    log.info("Subscribe to the pool and start testing that yum repolist reports the expected repo id/labels...");
    File entitlementCertFile = clienttasks.subscribeToSubscriptionPool_(pool);
    Assert.assertNotNull(entitlementCertFile, "Found the entitlement cert file that was granted after subscribing to pool: " + pool);
    EntitlementCert entitlementCert = clienttasks.getEntitlementCertFromEntitlementCertFile(entitlementCertFile);
    // 1. Run a 'yum repolist' and get a list of all of the available repositories corresponding to your entitled products
    // 1. Repolist contains repositories corresponding to your entitled products
    ArrayList<String> repolist = clienttasks.getYumRepolist("enabled");
    for (ContentNamespace contentNamespace : entitlementCert.contentNamespaces) {
        if (!contentNamespace.type.equalsIgnoreCase("yum"))
            continue;
        if (!clienttasks.areAllRequiredTagsInContentNamespaceProvidedByProductCerts(contentNamespace, currentProductCerts)) {
            Assert.assertFalse(repolist.contains(contentNamespace.label), "Yum repolist enabled excludes repo id/label '" + contentNamespace.label + "' after having subscribed to Subscription ProductId '" + entitlementCert.orderNamespace.productId + "' with the manage_repos configuration enabled because not all requiredTags (" + contentNamespace.requiredTags + ") in the contentNamespace are provided by the currently installed productCerts.");
            continue;
        }
        if (contentNamespace.enabled) {
            Assert.assertTrue(repolist.contains(contentNamespace.label), "Yum repolist enabled includes enabled repo id/label '" + contentNamespace.label + "' after having subscribed to Subscription ProductId '" + entitlementCert.orderNamespace.productId + "' with manage_repos configuration enabled.");
        } else {
            Assert.assertFalse(repolist.contains(contentNamespace.label), "Yum repolist enabled excludes disabled repo id/label '" + contentNamespace.label + "' after having subscribed to Subscription ProductId '" + entitlementCert.orderNamespace.productId + "' with manage_repos configuration enabled.");
        }
    }
    repolist = clienttasks.getYumRepolist("disabled");
    for (ContentNamespace contentNamespace : entitlementCert.contentNamespaces) {
        if (!contentNamespace.type.equalsIgnoreCase("yum"))
            continue;
        if (!clienttasks.areAllRequiredTagsInContentNamespaceProvidedByProductCerts(contentNamespace, currentProductCerts)) {
            Assert.assertFalse(repolist.contains(contentNamespace.label), "Yum repolist disabled excludes repo id/label '" + contentNamespace.label + "' after having subscribed to Subscription ProductId '" + entitlementCert.orderNamespace.productId + "' with manage_repos configuration enabled because not all requiredTags (" + contentNamespace.requiredTags + ") in the contentNamespace are provided by the currently installed productCerts.");
            continue;
        }
        if (contentNamespace.enabled) {
            Assert.assertFalse(repolist.contains(contentNamespace.label), "Yum repolist disabled excludes enabled repo id/label '" + contentNamespace.label + "' after having subscribed to Subscription ProductId '" + entitlementCert.orderNamespace.productId + "' with manage_repos configuration enabled.");
        } else {
            Assert.assertTrue(repolist.contains(contentNamespace.label), "Yum repolist disabled includes disabled repo id/label '" + contentNamespace.label + "' after having subscribed to Subscription ProductId '" + entitlementCert.orderNamespace.productId + "' with manage_repos configuration enabled.");
        }
    }
    repolist = clienttasks.getYumRepolist("all");
    for (ContentNamespace contentNamespace : entitlementCert.contentNamespaces) {
        if (!contentNamespace.type.equalsIgnoreCase("yum"))
            continue;
        if (clienttasks.areAllRequiredTagsInContentNamespaceProvidedByProductCerts(contentNamespace, currentProductCerts)) {
            Assert.assertTrue(repolist.contains(contentNamespace.label), "Yum repolist all includes repo id/label '" + contentNamespace.label + "' after having subscribed to Subscription ProductId '" + entitlementCert.orderNamespace.productId + "' with manage_repos configuration enabled.");
        } else {
            Assert.assertFalse(repolist.contains(contentNamespace.label), "Yum repolist all excludes repo id/label '" + contentNamespace.label + "' after having subscribed to Subscription ProductId '" + entitlementCert.orderNamespace.productId + "' with manage_repos configuration enabled because not all requiredTags (" + contentNamespace.requiredTags + ") in the contentNamespace are provided by the currently installed productCerts.");
        }
    }
    log.info("Unsubscribe from the pool and verify that yum repolist no longer reports the expected repo id/labels...");
    clienttasks.unsubscribeFromSerialNumber(entitlementCert.serialNumber);
    repolist = clienttasks.getYumRepolist("all");
    for (ContentNamespace contentNamespace : entitlementCert.contentNamespaces) {
        if (!contentNamespace.type.equalsIgnoreCase("yum"))
            continue;
        Assert.assertFalse(repolist.contains(contentNamespace.label), "Yum repolist all excludes repo id/label '" + contentNamespace.label + "' after having unsubscribed from Subscription ProductId '" + entitlementCert.orderNamespace.productId + "' with manage_repos configuration enabled.");
    }
    // Disable rhsm manage_repos configuration
    log.info("Now we will disable the rhsm manage_repos configuration with enabled=0..");
    clienttasks.config(null, null, true, new String[] { "rhsm", "manage_repos", "0" });
    log.info("Again let's subscribe to the same pool and verify that yum repolist does NOT report any of the entitled repo id/labels since the manage_repos has been disabled...");
    entitlementCertFile = clienttasks.subscribeToSubscriptionPool_(pool);
    Assert.assertNotNull(entitlementCertFile, "Found the entitlement cert file that was granted after subscribing to pool: " + pool);
    entitlementCert = clienttasks.getEntitlementCertFromEntitlementCertFile(entitlementCertFile);
    // 2. Run a 'yum repolist' and get a list of all of the available repositories corresponding to your entitled products
    // 2. Repolist does not contain repositories corresponding to your entitled products
    repolist = clienttasks.getYumRepolist("all");
    for (ContentNamespace contentNamespace : entitlementCert.contentNamespaces) {
        if (!contentNamespace.type.equalsIgnoreCase("yum"))
            continue;
        Assert.assertFalse(repolist.contains(contentNamespace.label), "Yum repolist all excludes repo id/label '" + contentNamespace.label + "' after having subscribed to Subscription ProductId '" + entitlementCert.orderNamespace.productId + "' with the manage_repos configuration disabled.");
    }
    log.info("Now we will enable manage_repos and expect the repo list to be updated");
    clienttasks.config(null, null, true, new String[] { "rhsm", "manage_repos", "1" });
    repolist = clienttasks.getYumRepolist("all");
    for (ContentNamespace contentNamespace : entitlementCert.contentNamespaces) {
        if (!contentNamespace.type.equalsIgnoreCase("yum"))
            continue;
        if (clienttasks.areAllRequiredTagsInContentNamespaceProvidedByProductCerts(contentNamespace, currentProductCerts)) {
            Assert.assertTrue(repolist.contains(contentNamespace.label), "Yum repolist all now includes repo id/label '" + contentNamespace.label + "' after having subscribed to Subscription ProductId '" + entitlementCert.orderNamespace.productId + "' followed by manage_repos configuration enabled.");
        } else {
            Assert.assertFalse(repolist.contains(contentNamespace.label), "Yum repolist all still excludes repo id/label '" + contentNamespace.label + "' after having subscribed to Subscription ProductId '" + entitlementCert.orderNamespace.productId + "' followed by manage_repos configuration enabled because not all requiredTags (" + contentNamespace.requiredTags + ") in the contentNamespace are provided by the currently installed productCerts.");
        }
    }
}
Also used : ContentNamespace(rhsm.data.ContentNamespace) EntitlementCert(rhsm.data.EntitlementCert) ProductCert(rhsm.data.ProductCert) File(java.io.File) TestDefinition(com.github.redhatqe.polarize.metadata.TestDefinition) Test(org.testng.annotations.Test) ImplementsNitrateTest(com.redhat.qe.auto.tcms.ImplementsNitrateTest) ImplementsNitrateTest(com.redhat.qe.auto.tcms.ImplementsNitrateTest)

Aggregations

ImplementsNitrateTest (com.redhat.qe.auto.tcms.ImplementsNitrateTest)267 Test (org.testng.annotations.Test)267 TestDefinition (com.github.redhatqe.polarize.metadata.TestDefinition)244 SSHCommandResult (com.redhat.qe.tools.SSHCommandResult)146 SkipException (org.testng.SkipException)125 SubscriptionPool (rhsm.data.SubscriptionPool)71 ArrayList (java.util.ArrayList)62 BigInteger (java.math.BigInteger)53 BugzillaAPIException (com.redhat.qe.auto.bugzilla.BugzillaAPIException)42 ProductSubscription (rhsm.data.ProductSubscription)42 File (java.io.File)36 JSONObject (org.json.JSONObject)33 EntitlementCert (rhsm.data.EntitlementCert)32 ProductCert (rhsm.data.ProductCert)32 InstalledProduct (rhsm.data.InstalledProduct)15 ConsumerCert (rhsm.data.ConsumerCert)14 HashMap (java.util.HashMap)11 Calendar (java.util.Calendar)10 List (java.util.List)10 JSONArray (org.json.JSONArray)8