Search in sources :

Example 46 with TestDefinition

use of com.github.redhatqe.polarize.metadata.TestDefinition in project rhsm-qe by RedHatQE.

the class StatusTests method testStatusWhileRegisteredWithEntitlements.

@// update=true,	// uncomment to make TestDefinition changes update Polarion testcases through the polarize testcase importer
TestDefinition(projectID = { Project.RHEL6, Project.RedHatEnterpriseLinux7 }, testCaseID = { "RHEL6-19968", "RHEL7-51007" }, 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 = "run subscription-manager status when registered with entitlements", groups = { "Tier1Tests", "blockedByBug-958827", "StatusWhileRegisteredWithEntitlements_Test" }, enabled = true)
public // @ImplementsNitrateTest(caseId=)
void testStatusWhileRegisteredWithEntitlements() throws JSONException, Exception {
    SSHCommandResult statusResult;
    // override the system facts setting the attribute count to a value for which all the stackable subscriptions are needed to achieve compliance
    Map<String, String> factsMap = new HashMap<String, String>();
    factsMap.put("memory.memtotal", "75");
    factsMap.put("cpu.cpu_socket(s)", "100");
    factsMap.put("cpu.core(s)_per_socket", "2");
    clienttasks.createFactsFileWithOverridingValues(factsMap);
    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);
    clienttasks.subscribeToTheCurrentlyAvailableSubscriptionPoolsCollectively();
    String systemEntitlementsValid = clienttasks.getFactValue("system.entitlements_valid");
    statusResult = clienttasks.status(null, null, null, null, null);
    // [root@jsefler-5 ~]# subscription-manager status
    // +-------------------------------------------+
    // System Status Details
    // +-------------------------------------------+
    // Overall Status: Invalid
    // 
    // Large File Support Bits:
    // - Not covered by a valid subscription.
    // 
    // Awesome OS for x86 Bits:
    // - Not covered by a valid subscription.
    // 
    // Stackable Cores Package (8 cores)/Stackable Cores Package (8 cores):
    // - Only covers 16 of 200 cores.
    // 
    // Awesome OS for S390X Bits:
    // - Not covered by a valid subscription.
    // 
    // Awesome OS for S390 Bits:
    // - Not covered by a valid subscription.
    // 
    // Load Balancing Bits:
    // - Not covered by a valid subscription.
    // 
    // Awesome OS Workstation Bits:
    // - Not covered by a valid subscription.
    // 
    // Clustering Bits:
    // - Not covered by a valid subscription.
    // 
    // Awesome OS for i386 Bits:
    // - Not covered by a valid subscription.
    // 
    // Stackable with Awesome OS for x86_64/Awesome OS for x86_64/Stackable with Awesome OS for x86_64/Awesome OS for x86_64:
    // - Only covers 4 of 100 sockets.
    // 
    // Multi-Attribute (non-stackable) (6 cores, 8GB):
    // - Only covers 6 of 200 cores.
    // 
    // Awesome OS for ia64 Bits:
    // - Not covered by a valid subscription.
    // 
    // Awesome OS Developer Basic:
    // - Not covered by a valid subscription.
    // 
    // Multi-Attribute (multi-entitlement only) (8 cores, 4GB):
    // - Only covers 8 of 200 cores.
    // 
    // Cores Package (26 cores):
    // - Only covers 26 of 200 cores.
    // 
    // Multiplier Product Bits:
    // - Not covered by a valid subscription.
    // 
    // RAM/Cores Package (8GB, 4 cores):
    // - Only covers 4 of 200 cores.
    // 
    // Shared Storage Bits:
    // - Not covered by a valid subscription.
    // 
    // Awesome OS for ppc64 Bits:
    // - Not covered by a valid subscription.
    // 
    // Awesome OS for i686 Bits:
    // - Not covered by a valid subscription.
    // 
    // Awesome OS Premium Architecture Bits:
    // - Not covered by a valid subscription.
    // 
    // Multi-Attribute Stackable (4 cores)/Multi-Attribute Stackable (2 GB, 2 Cores)/Multi-Attribute Stackable (4 cores)/Multi-Attribute Stackable (2 GB, 2 Cores)/Multi-Attribute Stackable (16
    // cores, 4 sockets, 8GB RAM)/Multi-Attribute Stackable (2 sockets)/Multi-Attribute Stackable (2 GB)/Multi-Attribute Stackable (2 sockets)/Multi-Attribute Stackable (16 cores, 4 sockets, 8GB
    // RAM)/Multi-Attribute Stackable (2 GB):
    // - Only covers 44 of 200 cores.
    // - Only covers 12 of 100 sockets.
    // 
    // Management Bits:
    // - Not covered by a valid subscription.
    // 
    // Virt Only Awesome OS for i386 Bits:
    // - Not covered by a valid subscription.
    // 
    // Awesome OS Developer Bits:
    // - Not covered by a valid subscription.
    // 
    // Awesome OS for x86_64/i686/ia64/ppc/ppc64/s390x/s390 Bits:
    // - Not covered by a valid subscription.
    // Awesome OS Server Bits:
    // - Guest has not been reported on any host and is using a temporary unmapped guest subscription.
    // assert the overall status
    String expectedStatus = null;
    if (systemEntitlementsValid.equals("valid")) {
        // translation for "valid"
        expectedStatus = "Overall Status: Current";
    } else if (systemEntitlementsValid.equals("invalid")) {
        // translation for "invalid"
        expectedStatus = "Overall Status: Invalid";
    } else if (systemEntitlementsValid.equals("partial")) {
        // translation for "partial"	// Bug 959124 - "Compliant status" of the system set to "Insufficient" if any partial subscription is attached to a product (which is not exsiting )
        expectedStatus = "Overall Status: Insufficient";
    } else if (systemEntitlementsValid.equals("unknown")) {
        // translation for "unknown"
        expectedStatus = "Overall Status: Unknown";
    } else {
        Assert.fail("Encountered an unexpected value for systemEntitlementsValid '" + systemEntitlementsValid + "'.");
    }
    Assert.assertTrue(statusResult.getStdout().contains(expectedStatus), "Expecting '" + expectedStatus + "'.");
    // if (clienttasks.isPackageVersion("subscription-manager",">=","1.13.8-1")) {		// post commit 7957b8df95c575e6e8713c2f1a0f8f754e32aed3 bug 1119688
    if (clienttasks.isPackageVersion("subscription-manager", ">=", "1.13.10-1")) {
        // exit code of 0 indicates valid compliance, otherwise exit code is 1
        if (systemEntitlementsValid.equals("valid")) {
            Assert.assertEquals(statusResult.getExitCode(), new Integer(0), "When the system's overall status is valid, an exit code of 0 should be returned.");
        } else {
            Assert.assertEquals(statusResult.getExitCode(), new Integer(1), "When the system's overall status is NOT valid, an exit code of 1 should be returned.");
        }
    }
    // assert the individual installed product status details
    for (InstalledProduct installedProduct : clienttasks.getCurrentlyInstalledProducts()) {
        // status details from the individual installed products is only included in the status report when the product is Not Subscribed
        if (installedProduct.status.equals("Not Subscribed")) {
            // expectedDetails "Not covered by a valid subscription."
            if (installedProduct.statusDetails.isEmpty())
                log.warning("Status Details appears empty.  Is your candlepin server older than 0.8.6?");
            Assert.assertTrue(!getSubstringMatches(statusResult.getStdout(), "^" + installedProduct.productName.replaceAll("\\(", "\\\\(").replaceAll("\\)", "\\\\)") + ":").isEmpty(), "Installed product '" + installedProduct.productName + "' should be included in the overall status details report when its own status is Not Subscribed.");
            for (String statusDetail : installedProduct.statusDetails) {
                Assert.assertTrue(!getSubstringMatches(statusResult.getStdout(), "^" + installedProduct.productName.replaceAll("\\(", "\\\\(").replaceAll("\\)", "\\\\)") + ":(\\n- .*)*?\\n- " + statusDetail.replaceAll("\\(", "\\\\(").replaceAll("\\)", "\\\\)")).isEmpty(), "Expecting the status detail '" + statusDetail + "' of installed product '" + installedProduct.productName + "' to appear in the list of overall status details.");
                // Assert.assertTrue(!doesStringContainMatches(listStatusResult.getStdout(), "(\\n^- "+statusDetail+"){2,}"),
                // "Status detail '"+statusDetail+"' of installed product '"+installedProduct.productName+"' should NOT appear in duplicate.");
                Assert.assertTrue(!doesStringContainMatches(statusResult.getStdout(), statusDetail.replaceAll("\\(", "\\\\(").replaceAll("\\)", "\\\\)") + "(\\n- .*)*?\\n- " + statusDetail.replaceAll("\\(", "\\\\(").replaceAll("\\)", "\\\\)")), "Status detail '" + statusDetail + "' of installed product '" + installedProduct.productName + "' should not appear in duplicate.");
            }
        } else {
            // TEMPORARY WORKAROUND FOR BUG:
            boolean invokeWorkaroundWhileBugIsOpen = true;
            // Bug 1197897 - subscription-manager status is yellow due to 24-hour subscription despite redundant coverage from a green subscription
            String bugId = "1197897";
            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 && !getSubstringMatches(statusResult.getStdout(), "^" + installedProduct.productName.replaceAll("\\(", "\\\\(").replaceAll("\\)", "\\\\)") + ":").isEmpty()) {
                String expectedReason = "Guest has not been reported on any host and is using a temporary unmapped guest subscription.";
                log.warning("Verifying that the reason product '" + installedProduct.productName + "' appears in the status report is because a temporary 24 hour subscription has been attached since '" + expectedReason + "'.");
                Assert.assertTrue(!getSubstringMatches(statusResult.getStdout(), "^" + installedProduct.productName.replaceAll("\\(", "\\\\(").replaceAll("\\)", "\\\\)") + ":" + "\n- " + expectedReason).isEmpty(), "Installed product '" + installedProduct.productName + "' appears to be covered by a temporary 24 hours entitlement because the status module reports '" + expectedReason + "'");
            } else
                // assert
                // END OF WORKAROUND
                Assert.assertTrue(getSubstringMatches(statusResult.getStdout(), "^" + installedProduct.productName.replaceAll("\\(", "\\\\(").replaceAll("\\)", "\\\\)") + ":").isEmpty(), "Installed product '" + installedProduct.productName + "' should NOT be included in the overall status details report when its own status '" + installedProduct.status + "' is something other than Not Subscribed.");
        }
    }
    // assert the individual consumed subscription status details
    List<ProductSubscription> currentlyConsumedProductSubscriptions = clienttasks.getCurrentlyConsumedProductSubscriptions();
    for (ProductSubscription productSubscription : currentlyConsumedProductSubscriptions) {
        // if (productSubscription.statusDetails.isEmpty()) {	// is not sufficient after bug 1180400 implementation
        if (productSubscription.statusDetails.isEmpty() && clienttasks.isPackageVersion("subscription-manager", "<", "1.13.13-1")) {
            // since this productSubscription is empty, it should NOT be reported in the Status report
            Assert.assertTrue(getSubstringMatches(statusResult.getStdout(), "(^|/)" + productSubscription.productName.replaceAll("\\(", "\\\\(").replaceAll("\\)", "\\\\)") + "(|/.+):").isEmpty(), "Expecting the empty status details " + productSubscription.statusDetails + " of consumed subscription '" + productSubscription.productName + "' to NOT appear in the list of overall status details of the installed products.");
        } else if (productSubscription.statusDetails.size() == 1 && productSubscription.statusDetails.get(0).trim().equals("Subscription is current") && clienttasks.isPackageVersion("subscription-manager", ">=", "1.13.13-1")) {
            // commit 252ec4520fb6272b00ae379703cd004f558aac63	// bug 1180400: "Status Details" are now populated on CLI
            // since this productSubscription appears to be current, it should NOT be reported in the Status report, UNLESS there is another overconsumed subscription by the same name that is not current.
            // assume
            boolean allOtherConsumedProductSubscriptionsWithThisProductNameAreCurrent = true;
            for (ProductSubscription otherConsumedProductSubscription : currentlyConsumedProductSubscriptions) {
                if (otherConsumedProductSubscription.productName.equals(productSubscription.productName) && !otherConsumedProductSubscription.poolId.equals(productSubscription.poolId) && !otherConsumedProductSubscription.statusDetails.isEmpty() && !otherConsumedProductSubscription.statusDetails.get(0).equals("Subscription is current")) {
                    allOtherConsumedProductSubscriptionsWithThisProductNameAreCurrent = false;
                    log.warning("There are multiple consumed subscriptions for '" + productSubscription.productName + "'.  Not all of them are current.");
                }
            }
            boolean statusReportIncludesProductSubscriptionProductName = getSubstringMatches(statusResult.getStdout(), "(^|/)" + productSubscription.productName.replaceAll("\\(", "\\\\(").replaceAll("\\)", "\\\\)") + "(|/.+):").isEmpty();
            if (allOtherConsumedProductSubscriptionsWithThisProductNameAreCurrent) {
                Assert.assertTrue(statusReportIncludesProductSubscriptionProductName, "Since the status details of consumed subscription '" + productSubscription.productName + "' states Subscription is current, product '" + productSubscription.productName + "' should NOT appear in the list of overall status details of the installed products.");
            }
        // else the actual status report will be asserted when the outer for loop hits the otherConsumedProductSubscriptionsWithThisProductName
        } else {
            // since this productSubscription is not current, its status details should be reported in the Status report under the subscription's name.
            for (String statusDetail : productSubscription.statusDetails) {
                Assert.assertTrue(!getSubstringMatches(statusResult.getStdout(), "(^|/)" + productSubscription.productName.replaceAll("\\(", "\\\\(").replaceAll("\\)", "\\\\)") + "(|/.+):(\\n- .*)*?\\n- " + statusDetail.replaceAll("\\(", "\\\\(").replaceAll("\\)", "\\\\)")).isEmpty(), "Expecting the status detail '" + statusDetail + "' of consumed subscription '" + productSubscription.productName + "' to appear in the list of overall status details.");
                // Assert.assertTrue(!doesStringContainMatches(listStatusResult.getStdout(), "(\\n^- "+statusDetail+"){2,}"),
                // "Status detail '"+statusDetail+"' of consumed subscription '"+productSubscription+"' should NOT appear in duplicate.");
                Assert.assertTrue(!doesStringContainMatches(statusResult.getStdout(), statusDetail.replaceAll("\\(", "\\\\(").replaceAll("\\)", "\\\\)") + "(\\n- .*)*?\\n- " + statusDetail.replaceAll("\\(", "\\\\(").replaceAll("\\)", "\\\\)")), "Status detail '" + statusDetail + "' of consumed subscription '" + productSubscription.productName + "' should not appear in duplicate.");
            }
        }
    }
}
Also used : HashMap(java.util.HashMap) SSHCommandResult(com.redhat.qe.tools.SSHCommandResult) InstalledProduct(rhsm.data.InstalledProduct) ProductSubscription(rhsm.data.ProductSubscription) BugzillaAPIException(com.redhat.qe.auto.bugzilla.BugzillaAPIException) TestDefinition(com.github.redhatqe.polarize.metadata.TestDefinition) Test(org.testng.annotations.Test)

Example 47 with TestDefinition

use of com.github.redhatqe.polarize.metadata.TestDefinition in project rhsm-qe by RedHatQE.

the class StatusTests method testStatusOnInvalidDate.

@// update=true,	// uncomment to make TestDefinition changes update Polarion testcases through the polarize testcase importer
TestDefinition(projectID = { Project.RHEL6, Project.RedHatEnterpriseLinux7 }, testCaseID = { "RHEL6-36567", "RHEL7-51355" }, 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 = "Tier2")
@Test(description = "run subscription-manager status ondate (invalid)", groups = { "Tier2Tests" }, enabled = true)
public // @ImplementsNitrateTest(caseId=)
void testStatusOnInvalidDate() throws JSONException, Exception {
    if (clienttasks.isPackageVersion("subscription-manager", "<", "1.9.2-1"))
        throw new SkipException("Installed package '" + clienttasks.installedPackageVersionMap.get("subscription-manager") + "' does not support status --ondate option.  It was introduced in subscription-manager-1.9.2-1.");
    // call status with an invalid ondate
    // lucky month 13
    SSHCommandResult statusResultYesterday = clienttasks.status_("2000-13-01", null, null, null, null);
    DateFormat yyyy_MM_dd_DateFormat = new SimpleDateFormat("yyyy-MM-dd");
    String today = yyyy_MM_dd_DateFormat.format(Calendar.getInstance().getTime());
    if (clienttasks.isPackageVersion("subscription-manager", ">=", "1.13.8-1")) {
        // post commit df95529a5edd0be456b3528b74344be283c4d258 bug 1119688
        Assert.assertEquals(statusResultYesterday.getStderr().trim(), String.format("Date entered is invalid. Date should be in YYYY-MM-DD format (example: %s )", today), "Stderr from call to status ondate invalid.");
        Assert.assertEquals(statusResultYesterday.getStdout().trim(), "", "Stdout from call to status ondate invalid.");
        Assert.assertEquals(statusResultYesterday.getExitCode(), Integer.valueOf(65), /*EX_DATAERR*/
        "ExitCode from call to status ondate invalid.");
    } else {
        Assert.assertEquals(statusResultYesterday.getStdout().trim(), String.format("Date entered is invalid. Date should be in YYYY-MM-DD format (example: %s )", today), "Stdout from call to status ondate invalid.");
        Assert.assertEquals(statusResultYesterday.getStderr().trim(), "", "Stderr from call to status ondate invalid.");
        Assert.assertEquals(statusResultYesterday.getExitCode(), Integer.valueOf(1), "ExitCode from call to status ondate invalid.");
    }
}
Also used : SSHCommandResult(com.redhat.qe.tools.SSHCommandResult) SimpleDateFormat(java.text.SimpleDateFormat) DateFormat(java.text.DateFormat) SkipException(org.testng.SkipException) SimpleDateFormat(java.text.SimpleDateFormat) TestDefinition(com.github.redhatqe.polarize.metadata.TestDefinition) Test(org.testng.annotations.Test)

Example 48 with TestDefinition

use of com.github.redhatqe.polarize.metadata.TestDefinition in project rhsm-qe by RedHatQE.

the class StatusTests method testStatusWithoutBeingRegistered.

@// update=true,	// uncomment to make TestDefinition changes update Polarion testcases through the polarize testcase importer
TestDefinition(projectID = { Project.RHEL6, Project.RedHatEnterpriseLinux7 }, testCaseID = { "RHEL6-36569", "RHEL7-51357" }, 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 = "Tier2")
@Test(description = "run subscription-manager status without being registered; status should be Unknown", groups = { "Tier2Tests" }, enabled = true)
public // @ImplementsNitrateTest(caseId=)
void testStatusWithoutBeingRegistered() {
    SSHCommandResult statusResult;
    clienttasks.unregister(null, null, null, null);
    statusResult = clienttasks.status(null, null, null, null, null);
    // [root@jsefler-5 ~]# subscription-manager status
    // +-------------------------------------------+
    // System Status Details
    // +-------------------------------------------+
    // Overall Status: Unknown
    String expectedStatus = "Overall Status: Unknown";
    Assert.assertTrue(statusResult.getStdout().contains(expectedStatus), "Expecting '" + expectedStatus + "' when not registered.");
    Assert.assertEquals(statusResult.getStdout().replaceFirst("\\+-+\\+\\n\\s*System Status Details\\s*\\n\\+-+\\+", "").trim(), expectedStatus, "Expecting ONLY '" + expectedStatus + "' to be reported when not registered.");
}
Also used : SSHCommandResult(com.redhat.qe.tools.SSHCommandResult) TestDefinition(com.github.redhatqe.polarize.metadata.TestDefinition) Test(org.testng.annotations.Test)

Example 49 with TestDefinition

use of com.github.redhatqe.polarize.metadata.TestDefinition in project rhsm-qe by RedHatQE.

the class StorageBandTests method testAutoHealStorageBandSubscription.

/**
 * @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-21461", "RHEL7-51710" }, 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 you auto-heal a system using 300TB of storage, installed storage product is fully subscribed from multiple pools that provide 256TB of coverage.", groups = { "Tier3Tests", "AutoHealStorageBandSubscription" }, dataProvider = "getStorageBandSubscriptions", enabled = true)
public void testAutoHealStorageBandSubscription(Object Bugzilla, SubscriptionPool storagebandpool) 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);
    log.info("To auto-heal this system for '" + bandStorageUsage + "'TB of storage, there must be more than one stackable pool for product SKU '" + storagebandpool.productId + "'.");
    // to troubleshoot the existance of multiple pools
    SSHCommandResult listResult = clienttasks.list(null, true, null, null, null, null, null, null, storagebandpool.productId, null, null, null, null, null);
    List<SubscriptionPool> availableStorageBandPools = SubscriptionPool.parse(listResult.getStdout());
    String expectedStatus = availableStorageBandPools.size() > 1 ? "Subscribed" : "Not Subscribed";
    clienttasks.autoheal(null, true, null, null, null, null, null);
    clienttasks.run_rhsmcertd_worker(true);
    List<String> providedProductIds = CandlepinTasks.getPoolProvidedProductIds(sm_clientUsername, sm_clientPassword, sm_serverUrl, storagebandpool.poolId);
    List<InstalledProduct> installedProducts = clienttasks.getCurrentlyInstalledProducts();
    for (String providedProductId : providedProductIds) {
        InstalledProduct installedProduct = InstalledProduct.findFirstInstanceWithMatchingFieldFromList("productId", providedProductId, installedProducts);
        if (installedProduct != null) {
            Assert.assertEquals(installedProduct.status.trim(), expectedStatus, "Status of installed product '" + installedProduct.productName + "' provided for by Storage Band entitlement pools that covers only 256TB on a system using '" + bandStorageUsage + "'TBs (that has been autohealed with '" + availableStorageBandPools.size() + "' available '" + storagebandpool.productId + "' pools)");
        }
    }
}
Also used : SSHCommandResult(com.redhat.qe.tools.SSHCommandResult) InstalledProduct(rhsm.data.InstalledProduct) SubscriptionPool(rhsm.data.SubscriptionPool) TestDefinition(com.github.redhatqe.polarize.metadata.TestDefinition) Test(org.testng.annotations.Test)

Example 50 with TestDefinition

use of com.github.redhatqe.polarize.metadata.TestDefinition in project rhsm-qe by RedHatQE.

the class StorageBandTests method testPartiallySubscribedStorageBandSubscription.

/**
 * @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-21462", "RHEL7-51711" }, 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 attaching a quantity of 1 entitlement from a pool capable of covering 256TB on a system with 300TB of usage, installed product will be partially subscribed", groups = { "Tier3Tests", "PartiallySubscribeStorageBandSubscription" }, dataProvider = "getStorageBandSubscriptions", enabled = true)
public void testPartiallySubscribedStorageBandSubscription(Object Bugzilla, SubscriptionPool storagebandpool) 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);
    clienttasks.subscribe(null, null, storagebandpool.poolId, null, null, "1", null, null, null, null, null, null, null);
    List<String> providedProductIds = CandlepinTasks.getPoolProvidedProductIds(sm_clientUsername, sm_clientPassword, sm_serverUrl, storagebandpool.poolId);
    List<InstalledProduct> installedProducts = clienttasks.getCurrentlyInstalledProducts();
    for (String providedProductId : providedProductIds) {
        InstalledProduct installedProduct = InstalledProduct.findFirstInstanceWithMatchingFieldFromList("productId", providedProductId, installedProducts);
        if (installedProduct != null) {
            Assert.assertEquals(installedProduct.status.trim(), "Partially Subscribed", "Status of installed product '" + installedProduct.productName + "' provided for by Storage Band entitlement pools that covers only 256TB on a system using '" + bandStorageUsage + "'TBs (that has been subscribed to pool SKU '" + storagebandpool.productId + "' '" + storagebandpool.subscriptionName + "' with quantity 1)");
            String expectedReason = String.format("Only supports %dTB of %dTB of storage.", 1, bandStorageUsage);
            Assert.assertTrue(installedProduct.statusDetails.contains(expectedReason), "Status Details includes expected reason '" + expectedReason + "'.");
        }
    }
}
Also used : InstalledProduct(rhsm.data.InstalledProduct) TestDefinition(com.github.redhatqe.polarize.metadata.TestDefinition) Test(org.testng.annotations.Test)

Aggregations

TestDefinition (com.github.redhatqe.polarize.metadata.TestDefinition)687 Test (org.testng.annotations.Test)687 SSHCommandResult (com.redhat.qe.tools.SSHCommandResult)401 ImplementsNitrateTest (com.redhat.qe.auto.tcms.ImplementsNitrateTest)366 SkipException (org.testng.SkipException)328 ArrayList (java.util.ArrayList)144 SubscriptionPool (rhsm.data.SubscriptionPool)137 JSONObject (org.json.JSONObject)95 BigInteger (java.math.BigInteger)90 BugzillaAPIException (com.redhat.qe.auto.bugzilla.BugzillaAPIException)88 HashMap (java.util.HashMap)78 File (java.io.File)74 ProductSubscription (rhsm.data.ProductSubscription)72 InstalledProduct (rhsm.data.InstalledProduct)66 EntitlementCert (rhsm.data.EntitlementCert)58 ProductCert (rhsm.data.ProductCert)54 YumRepo (rhsm.data.YumRepo)34 Repo (rhsm.data.Repo)26 Calendar (java.util.Calendar)25 List (java.util.List)24