use of com.redhat.qe.tools.SSHCommandResult in project rhsm-qe by RedHatQE.
the class UnsubscribeTests method testUnsubscribeFromAnInvalidSerial.
@// update=true, // uncomment to make TestDefinition changes update Polarion testcases through the polarize testcase importer
TestDefinition(projectID = { Project.RHEL6, Project.RedHatEnterpriseLinux7 }, testCaseID = { "RHEL6-36598", "RHEL7-51403" }, linkedWorkItems = { @LinkedItem(// RHSM-REQ : subscription-manager cli attaching and removing subscriptions
workitemId = "RHEL6-28489", project = Project.RHEL6, role = DefTypes.Role.VERIFIES), @LinkedItem(// RHSM-REQ : subscription-manager cli attaching and removing subscriptions
workitemId = "RHEL7-84911", project = Project.RedHatEnterpriseLinux7, role = DefTypes.Role.VERIFIES) }, 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 = "Attempt to unsubscribe when from an invalid serial number", groups = { "Tier2Tests", "blockedByBug-706889", "blockedByBug-867766" }, enabled = true)
public // @ImplementsNitrateTest(caseId=)
void testUnsubscribeFromAnInvalidSerial() {
SSHCommandResult result;
BigInteger serial = BigInteger.valueOf(-123);
result = clienttasks.unsubscribe_(null, serial, null, null, null, null, null);
Integer expectedExitCode = new Integer(255);
// EX_USAGE // post commit 5697e3af094be921ade01e19e1dfe7b548fb7d5b bug 1119688
if (clienttasks.isPackageVersion("subscription-manager", ">=", "1.13.8-1"))
expectedExitCode = new Integer(64);
Assert.assertEquals(result.getExitCode(), expectedExitCode, "Asserting exit code when attempting to unsubscribe from an invalid serial number.");
// Assert.assertEquals(result.getStderr().trim(), "Error: '-123' is not a valid serial number");
// Assert.assertEquals(result.getStdout().trim(), "");
// stderr moved to stdout by Bug 867766 - [RFE] unsubscribe from multiple entitlement certificates using serial numbers
Assert.assertEquals(result.getStdout().trim(), String.format("Error: '%s' is not a valid serial number", serial), "Stdout");
Assert.assertEquals(result.getStderr().trim(), "", "Stderr");
List<BigInteger> serials = Arrays.asList(new BigInteger[] { BigInteger.valueOf(123), BigInteger.valueOf(-456), BigInteger.valueOf(789) });
result = clienttasks.unsubscribe_(null, serials, null, null, null, null, null);
Assert.assertEquals(result.getExitCode(), expectedExitCode, "Asserting exit code when attempting to unsubscribe from an invalid serial number.");
Assert.assertEquals(result.getStdout().trim(), String.format("Error: '%s' is not a valid serial number", serials.get(1)), "Stdout");
Assert.assertEquals(result.getStderr().trim(), "", "Stderr");
}
use of com.redhat.qe.tools.SSHCommandResult in project rhsm-qe by RedHatQE.
the class VersionTests method testNoErrorWhileCheckingServerVersion.
@// update=true, // uncomment to make TestDefinition changes update Polarion testcases through the polarize testcase importer
TestDefinition(projectID = { Project.RHEL6, Project.RedHatEnterpriseLinux7 }, testCaseID = { "RHEL6-25814", "RHEL7-51275" }, 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 = "assert that no errors are reported while executing version module while registered and unregistered", groups = { "Tier2Tests", "blockedByBug-848409", "blockedByBug-1284120" }, enabled = true)
public // @ImplementsNitrateTest(caseId=)
void testNoErrorWhileCheckingServerVersion() {
// from Bug 848409 - Error while checking server version: No such file or directory
// [root@jsefler-59server ~]# subscription-manager version
// Error while checking server version: No such file or directory
// remote entitlement server: Unknown
// remote entitlement server type: Unknown
// subscription-manager: 1.0.13-1.git.27.2a76fe7.el5
// assert results from version do not contain an error (while unregistered)
String error = "Error";
clienttasks.unregister(null, null, null, null);
SSHCommandResult versionResult = clienttasks.version(null, null, null, null);
Assert.assertTrue(!versionResult.getStdout().contains(error), "Stdout from the version report does NOT contain an '" + error + "' message (while unregistered).");
Assert.assertTrue(!versionResult.getStderr().contains(error), "Stderr from the version report does NOT contain an '" + error + "' message (while unregistered).");
// assert results from version do not contain an error (while registered)
clienttasks.register(sm_clientUsername, sm_clientPassword, sm_clientOrg, null, null, null, null, null, null, null, (List<String>) null, null, null, null, null, null, null, null, null, null);
versionResult = clienttasks.version(null, null, null, null);
Assert.assertTrue(!versionResult.getStdout().contains(error), "Stdout from the version report does NOT contain an '" + error + "' message (while registered).");
Assert.assertTrue(!versionResult.getStderr().contains(error), "Stderr from the version report does NOT contain an '" + error + "' message (while registered).");
}
use of com.redhat.qe.tools.SSHCommandResult in project rhsm-qe by RedHatQE.
the class VirtualizationTests method testHostAndGuestPoolsAreSubscribableOnGuestSystem.
@// update=true, // uncomment to make TestDefinition changes update Polarion testcases through the polarize testcase importer
TestDefinition(projectID = { Project.RHEL6, Project.RedHatEnterpriseLinux7 }, testCaseID = { "RHEL6-27131", "RHEL7-64494" }, 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 = "Verify host and guest pools to a virtualization-aware subscription are subscribable on a guest system (unless it is physical_only).", groups = { "Tier2Tests", "VerifyHostAndGuestPoolsAreSubscribableOnGuestSystem_Test" }, dependsOnGroups = {}, dataProvider = "getVirtSubscriptionData", enabled = true)
public void testHostAndGuestPoolsAreSubscribableOnGuestSystem(String subscriptionId, String productName, String productId, int quantity, String virtLimit, String hostPoolId, String guestPoolId, Boolean physicalOnly) throws JSONException, Exception {
if (hostPoolId == null && guestPoolId == null)
throw new SkipException("Failed to find expected host and guest pools derived from virtualization-aware subscription id '" + subscriptionId + "' (" + productName + ").");
// trick this system into believing it is a virt guest
forceVirtWhatToReturnGuest("kvm");
// assert that the hostPoolId is available...
List<SubscriptionPool> availablePools = clienttasks.getCurrentlyAvailableSubscriptionPools();
SubscriptionPool hostPool = SubscriptionPool.findFirstInstanceWithMatchingFieldFromList("poolId", hostPoolId, availablePools);
if (physicalOnly == null || !physicalOnly) {
// ...when the originating subscription is not physical_only
Assert.assertNotNull(hostPool, "A host pool derived from the virtualization-aware subscription id '" + subscriptionId + "' is available on a guest system. hostPool=" + hostPool);
// attempt to subscribe to the hostPoolId (should succeed)
// clienttasks.subscribeToSubscriptionPool(hostPool); // too much overhead
clienttasks.subscribe(null, null, hostPoolId, null, null, null, null, null, null, null, null, null, null);
} else {
// ...but not when the originating subscription is physical_only
// introduced by Bug 1066120
Assert.assertNull(hostPool, "A host pool derived from the virtualization-aware subscription id '" + subscriptionId + "' that is physical_only is NOT available on a guest system.");
// however, it should still be available from --all --available
hostPool = SubscriptionPool.findFirstInstanceWithMatchingFieldFromList("poolId", hostPoolId, clienttasks.getCurrentlyAllAvailableSubscriptionPools());
// introduced by Bug 1066120
Assert.assertNotNull(hostPool, "A host pool derived from the virtualization-aware subscription id '" + subscriptionId + "' that is physical_only is included in --all available on a guest system.");
Assert.assertEquals(hostPool.machineType, "Physical", "The machine type for a physical_only pool.");
// attempt to subscribe to the hostPoolId (should fail)
// [root@jsefler-7 ~]# subscription-manager attach --pool 8a9087e3443db08f01443db1810c125e
// Pool is restricted to physical systems: '8a9087e3443db08f01443db1810c125e'.
SSHCommandResult result = clienttasks.subscribe_(null, null, hostPoolId, null, null, null, null, null, null, null, null, null, null);
String expectedMsg = String.format("Pool is restricted to physical systems: '%s'.", hostPoolId);
if (SubscriptionManagerTasks.isVersion(servertasks.statusVersion, ">=", "2.3.1-1")) {
// commit 0d5fefcfa8c1c2485921d2dee6633879b1e06931 Correct incorrect punctuation in user messages
expectedMsg = String.format("Pool is restricted to physical systems: \"%s\".", hostPoolId);
}
Assert.assertEquals(result.getStdout().trim(), expectedMsg, "Stdout from an attempt to subscribe a virtual system to physical_only pool: " + hostPool);
Assert.assertEquals(result.getStderr(), "", "Stderr from an attempt to subscribe a virtual system to physical_only pool: " + hostPool);
Assert.assertEquals(result.getExitCode(), Integer.valueOf(1), "Exitcode from an attempt to subscribe a virtual system to physical_only pool: " + hostPool);
}
// assert that the guestPoolId is available
SubscriptionPool guestPool = SubscriptionPool.findFirstInstanceWithMatchingFieldFromList("poolId", guestPoolId, availablePools);
Assert.assertNotNull(guestPool, "A guest pool derived from the virtualization-aware subscription id '" + subscriptionId + "' is available on a guest system: " + guestPool);
// attempt to subscribe to the guestPoolId
clienttasks.subscribeToSubscriptionPool(guestPool);
}
use of com.redhat.qe.tools.SSHCommandResult in project rhsm-qe by RedHatQE.
the class StatusTests method testStatusWhileRegisteredWithoutEntitlements.
@// update=true, // uncomment to make TestDefinition changes update Polarion testcases through the polarize testcase importer
TestDefinition(projectID = { Project.RHEL6, Project.RedHatEnterpriseLinux7 }, testCaseID = { "RHEL6-19969", "RHEL7-51008" }, 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 without entitlements", groups = { "Tier1Tests" }, enabled = true)
public // @ImplementsNitrateTest(caseId=)
void testStatusWhileRegisteredWithoutEntitlements() {
int numberOfInstalledProducts = clienttasks.getCurrentProductCertFiles().size();
SSHCommandResult statusResult;
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);
List<InstalledProduct> installedProducts = clienttasks.getCurrentlyInstalledProducts();
statusResult = clienttasks.status(null, null, null, null, null);
// [root@jsefler-5 ~]# subscription-manager status
// +-------------------------------------------+
// System Status Details
// +-------------------------------------------+
// Overall Status: Invalid
//
// Awesome OS Modifier Bits:
// - Not covered by a valid subscription.
// assert the overall status
String expectedStatus;
if (numberOfInstalledProducts == 0) {
// translation for "valid"
expectedStatus = "Overall Status: Current";
} else {
// translation for "invalid"
expectedStatus = "Overall Status: Invalid";
}
Assert.assertTrue(statusResult.getStdout().contains(expectedStatus), "Expecting '" + expectedStatus + "' when registered without entitlements and '" + numberOfInstalledProducts + "' installed products.");
// assert the individual installed product status details
for (InstalledProduct installedProduct : installedProducts) {
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(statusResult.getStdout(), statusDetail.replaceAll("\\(", "\\\\(").replaceAll("\\)", "\\\\)") + "(\\n- .*)*?\\n- " + statusDetail.replaceAll("\\(", "\\\\(").replaceAll("\\)", "\\\\)")), "Status detail '" + statusDetail + "' of installed product '" + installedProduct.productName + "' should not appear in duplicate.");
}
}
if (installedProducts.isEmpty()) {
Assert.assertTrue(statusResult.getStdout().trim().endsWith(expectedStatus), "There should be no report of installed product details when there are no installed products; only expected '" + expectedStatus + "'.");
}
}
use of com.redhat.qe.tools.SSHCommandResult 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.");
}
}
}
}
Aggregations