use of com.redhat.qe.auto.bugzilla.BugzillaAPIException 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.");
}
}
}
}
use of com.redhat.qe.auto.bugzilla.BugzillaAPIException in project rhsm-qe by RedHatQE.
the class SubscribeTests method testSubscribeWithAutoMoreThanOnce.
@// update=true, // uncomment to make TestDefinition changes update Polarion testcases through the polarize testcase importer
TestDefinition(projectID = { Project.RHEL6, Project.RedHatEnterpriseLinux7 }, testCaseID = { "RHEL6-36580", "RHEL7-51382" }, 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: autosubscribe consumer more than once and verify we are not duplicately subscribed", groups = { "Tier2Tests", "blockedByBug-723044", "blockedByBug-743082", "blockedByBug-977321" }, enabled = true)
public // @ImplementsNitrateTest(caseId=)
void testSubscribeWithAutoMoreThanOnce() throws Exception {
// before testing, make sure all the expected subscriptionPoolProductId are available
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);
// TEMPORARY WORKAROUND
if (Boolean.valueOf(clienttasks.getFactValue("virt.is_guest"))) {
boolean invokeWorkaroundWhileBugIsOpen = true;
// Bug 1198494 - Auto-heal continuously attaches subscriptions to make the system compliant on a guest machine
String bugId = "1198494";
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) {
clienttasks.mapSystemAsAGuestOfItself();
}
}
// END OF WORKAROUND
// autosubscribe once
SSHCommandResult result1 = clienttasks.subscribe(Boolean.TRUE, null, (String) null, null, null, null, null, null, null, null, null, null, null);
List<File> entitlementCertFiles1 = clienttasks.getCurrentEntitlementCertFiles();
List<InstalledProduct> autosubscribedProductStatusList1 = InstalledProduct.parse(result1.getStdout());
// autosubscribe twice
SSHCommandResult result2 = clienttasks.subscribe(Boolean.TRUE, null, (String) null, null, null, null, null, null, null, null, null, null, null);
List<File> entitlementCertFiles2 = clienttasks.getCurrentEntitlementCertFiles();
List<InstalledProduct> autosubscribedProductStatusList2 = InstalledProduct.parse(result2.getStdout());
// assert results
Assert.assertEquals(entitlementCertFiles2.size(), entitlementCertFiles1.size(), "The number of granted entitlement certs is the same after a second autosubscribe.");
Assert.assertEquals(autosubscribedProductStatusList2.size(), autosubscribedProductStatusList1.size(), "The stdout from autosubscribe reports the same number of installed product status entries after a second autosubscribe.");
Assert.assertTrue(autosubscribedProductStatusList1.containsAll(autosubscribedProductStatusList2), "The list of installed product status entries from a second autosubscribe is the same as the first.");
}
use of com.redhat.qe.auto.bugzilla.BugzillaAPIException in project rhsm-qe by RedHatQE.
the class TemporaryPoolTests method testAutomaticRemovalOfAnAttachedUnmappedGuestsOnlySubpoolOnceGuestIsMapped.
@// update=true, // uncomment to make TestDefinition changes update Polarion testcases through the polarize testcase importer
TestDefinition(projectID = { Project.RHEL6, Project.RedHatEnterpriseLinux7 }, testCaseID = { "RHEL6-22237", "RHEL7-59322" }, 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 = "Once a guest is mapped, while consuming a temporary pool entitlement, the entitlement should be removed at the next checkin. Verify this while autoheal is disabled.", groups = { "Tier1Tests", "blockedByBug-1198494" }, dataProvider = "getAvailableUnmappedGuestsOnlySubscriptionPoolsData", enabled = true)
public // @ImplementsNitrateTest(caseId=)
void testAutomaticRemovalOfAnAttachedUnmappedGuestsOnlySubpoolOnceGuestIsMapped(Object bugzilla, SubscriptionPool unmappedGuestsOnlyPool) throws JSONException, Exception {
// system facts were overridden in dataProvider with factsMap to fake this system as a guest
// make sure we are freshly registered (to discard a consumer from a former data provided iteration that has mapped guests)
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);
// ensure that auto-healing is off
clienttasks.autoheal(null, null, true, null, null, null, null);
// attach the unmapped guests only pool
clienttasks.subscribe_(null, null, unmappedGuestsOnlyPool.poolId, null, null, null, null, null, null, null, null, null, null);
ProductSubscription consumedUnmappedGuestsOnlyProductSubscription = ProductSubscription.findFirstInstanceWithMatchingFieldFromList("poolId", unmappedGuestsOnlyPool.poolId, clienttasks.getCurrentlyConsumedProductSubscriptions());
Assert.assertNotNull(consumedUnmappedGuestsOnlyProductSubscription, "Successfully found the consumed product subscription after attaching temporary pool '" + unmappedGuestsOnlyPool.subscriptionName + "' (poolId='" + unmappedGuestsOnlyPool.poolId + "').");
// map the guest
clienttasks.mapSystemAsAGuestOfItself();
// trigger a rhsmcertd checkin (either of these calls are valid - randomly choose)
// TEMPORARY WORKAROUND FOR BUG
// Bug 1366301 - Server error attempting a PUT to /subscription/consumers/<UUID>/certificates?lazy_regen=true returned status 404
String bugId = "1366301";
boolean invokeWorkaroundWhileBugIsOpen = true;
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 && CandlepinType.hosted.equals(sm_serverType)) {
log.warning("Skipping a random call to refresh local certificates while bug '" + bugId + "' is open.");
// no need to pass autoheal option because it is already set true on the consumer
clienttasks.run_rhsmcertd_worker(null);
} else // END OF WORKAROUND
if (getRandomListItem(Arrays.asList(true, false)))
clienttasks.refresh(null, null, null, null);
else
// no need to pass autoheal option because it is already set true on the consumer
clienttasks.run_rhsmcertd_worker(null);
// verify that the attached temporary subscription has automatically been removed
List<ProductSubscription> currentlyConsumedProductSubscriptions = clienttasks.getCurrentlyConsumedProductSubscriptions();
Assert.assertTrue(ProductSubscription.findAllInstancesWithMatchingFieldFromList("poolId", unmappedGuestsOnlyPool.poolId, currentlyConsumedProductSubscriptions).isEmpty(), "Now that the guest is mapped, the consumed entitlements from the temporary pool '" + unmappedGuestsOnlyPool.subscriptionName + "' (poolId='" + unmappedGuestsOnlyPool.poolId + "') have automatically been removed.");
Assert.assertTrue(currentlyConsumedProductSubscriptions.isEmpty(), "Now that the guest is mapped (and autoheal was off at the instant the guest was mapped), not only is the temporary entitlement removed, but no new entitlements are granted.");
}
use of com.redhat.qe.auto.bugzilla.BugzillaAPIException in project rhsm-qe by RedHatQE.
the class TemporaryPoolTests method testAutoHealingOfAnAttachedUnmappedGuestsOnlySubpoolOnceGuestIsMapped.
@// update=true, // uncomment to make TestDefinition changes update Polarion testcases through the polarize testcase importer
TestDefinition(projectID = { Project.RHEL6, Project.RedHatEnterpriseLinux7 }, testCaseID = { "RHEL6-22236", "RHEL7-59321" }, 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 = "Once a guest is mapped, while consuming a temporary pool entitlement, the entitlement should be removed and the system auto-healed at the next checkin. Verify it.", groups = { "Tier1Tests", "blockedByBug-1198494" }, dataProvider = "getAvailableUnmappedGuestsOnlySubscriptionPoolsData", enabled = true)
public // @ImplementsNitrateTest(caseId=)
void testAutoHealingOfAnAttachedUnmappedGuestsOnlySubpoolOnceGuestIsMapped(Object bugzilla, SubscriptionPool unmappedGuestsOnlyPool) throws JSONException, Exception {
// system facts were overridden in dataProvider with factsMap to fake this system as a guest
// make sure we are freshly registered (to discard a consumer from a former data provided iteration that has mapped guests)
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);
// ensure that auto-healing is on
clienttasks.autoheal(null, true, null, null, null, null, null);
// attach the unmapped guests only pool
clienttasks.subscribe_(null, null, unmappedGuestsOnlyPool.poolId, null, null, null, null, null, null, null, null, null, null);
ProductSubscription consumedUnmappedGuestsOnlyProductSubscription = ProductSubscription.findFirstInstanceWithMatchingFieldFromList("poolId", unmappedGuestsOnlyPool.poolId, clienttasks.getCurrentlyConsumedProductSubscriptions());
Assert.assertNotNull(consumedUnmappedGuestsOnlyProductSubscription, "Successfully found the consumed product subscription after attaching temporary pool '" + unmappedGuestsOnlyPool.subscriptionName + "' (poolId='" + unmappedGuestsOnlyPool.poolId + "').");
// map the guest
clienttasks.mapSystemAsAGuestOfItself();
// trigger a rhsmcertd checkin (either of these calls are valid - randomly choose)
// TEMPORARY WORKAROUND FOR BUG
// Bug 1366301 - Server error attempting a PUT to /subscription/consumers/<UUID>/certificates?lazy_regen=true returned status 404
String bugId = "1366301";
boolean invokeWorkaroundWhileBugIsOpen = true;
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 && CandlepinType.hosted.equals(sm_serverType)) {
log.warning("Skipping a random call to refresh local certificates while bug '" + bugId + "' is open.");
// no need to pass autoheal option because it is already set true on the consumer
clienttasks.run_rhsmcertd_worker(null);
} else // END OF WORKAROUND
if (getRandomListItem(Arrays.asList(true, false)))
clienttasks.refresh(null, null, null, null);
else
// no need to pass autoheal option because it is already set true on the consumer
clienttasks.run_rhsmcertd_worker(null);
// verify that the attached temporary subscription has automatically been removed
Assert.assertTrue(ProductSubscription.findAllInstancesWithMatchingFieldFromList("poolId", unmappedGuestsOnlyPool.poolId, clienttasks.getCurrentlyConsumedProductSubscriptions()).isEmpty(), "Now that the guest is mapped, the consumed entitlements from the temporary pool '" + unmappedGuestsOnlyPool.subscriptionName + "' (poolId='" + unmappedGuestsOnlyPool.poolId + "') have automatically been removed.");
// assert that we have been autohealed as well as possible
List<File> entitlementCertFileAfterMapping = clienttasks.getCurrentEntitlementCertFiles();
clienttasks.subscribe(true, null, (String) null, null, null, null, null, null, null, null, null, null, null);
List<File> entitlementCertFileAfterAutosubscribing = clienttasks.getCurrentEntitlementCertFiles();
Assert.assertTrue(entitlementCertFileAfterMapping.containsAll(entitlementCertFileAfterAutosubscribing) && entitlementCertFileAfterAutosubscribing.containsAll(entitlementCertFileAfterMapping), "When the entitlement certs on the system are identical after a guest has been mapped and auto-healed and an explicit auto-subscribe is attempted, then we are confident that the guest was auto-healed at the instant the guest was mapped.)");
}
use of com.redhat.qe.auto.bugzilla.BugzillaAPIException in project rhsm-qe by RedHatQE.
the class SubscriptionManagerTasks method identity.
/**
* "subscription-manager-cli identity"
* @param username
* @param password
* @param regenerate
* @param force
* @param proxy
* @param proxyuser
* @param proxypassword
* @param noproxy TODO
* @return
*/
public SSHCommandResult identity(String username, String password, Boolean regenerate, Boolean force, String proxy, String proxyuser, String proxypassword, String noproxy) {
SSHCommandResult sshCommandResult = identity_(username, password, regenerate, force, proxy, proxyuser, proxypassword, noproxy);
// the non-null default value for regenerate is false
regenerate = regenerate == null ? false : regenerate;
// assert results for a successful identify
/* Example sshCommandResult.getStdout():
* Current identity is: 8f4dd91a-2c41-4045-a937-e3c8554a5701 name: testuser1
*/
Assert.assertEquals(sshCommandResult.getExitCode(), Integer.valueOf(0), "The exit code from the identity command indicates a success.");
// TEMPORARY WORKAROUND FOR BUG: https://bugzilla.redhat.com/show_bug.cgi?id=719109 - jsefler 7/05/2011
boolean invokeWorkaroundWhileBugIsOpen = true;
String bugId = "719109";
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) {
// skip the assertion of user feedback in stdout
return sshCommandResult;
}
if (regenerate) {
Assert.assertEquals(sshCommandResult.getStdout().trim(), "Identity certificate has been regenerated.");
}
// from the identity command
return sshCommandResult;
}
Aggregations