use of com.redhat.qe.auto.tcms.ImplementsNitrateTest in project rhsm-qe by RedHatQE.
the class ListTests method testListConsumedWithServicelevel.
@// update=true // uncomment to make TestDefinition changes update Polarion testcases through the polarize testcase importer
TestDefinition(projectID = { Project.RHEL6, Project.RedHatEnterpriseLinux7 }, testCaseID = { "RHEL6-27116", "RHEL7-51336" }, 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: subcription manager list consumed should filter by servicelevel when this option is passed.", groups = { "Tier2Tests", "blockedByBug-800933", "blockedByBug-800999" }, dataProvider = "getConsumedWithServicelevelData", enabled = true)
public // @ImplementsNitrateTest(caseId=)
void testListConsumedWithServicelevel(Object bugzilla, String servicelevel) throws Exception {
SSHCommandResult listResult;
List<ProductSubscription> expectedProductSubscriptions, filteredProductSubscriptions;
// list consumed (without service level)
listResult = clienttasks.list_(false, false, true, null, null, null, null, null, null, null, null, null, null, null);
List<ProductSubscription> allConsumedProductSubscriptions = clienttasks.getCurrentlyConsumedProductSubscriptions();
// determine the subset of expected pools with a matching servicelevel
// CASE SENSITIVE expectedProductSubscriptions = ProductSubscription.findAllInstancesWithMatchingFieldFromList("serviceLevel", servicelevel, allConsumedProductSubscriptions);
expectedProductSubscriptions = ProductSubscription.findAllInstancesWithCaseInsensitiveMatchingFieldFromList("serviceLevel", servicelevel, allConsumedProductSubscriptions);
// list consumed filtered by servicelevel
listResult = clienttasks.list_(false, false, true, null, servicelevel, null, null, null, null, null, null, null, null, null);
Assert.assertEquals(listResult.getExitCode(), Integer.valueOf(0), "The exit code from the list --consumed --servicelevel command indicates a success.");
// assert results
filteredProductSubscriptions = ProductSubscription.parse(listResult.getStdout());
Assert.assertTrue(filteredProductSubscriptions.containsAll(expectedProductSubscriptions), "The actual list of --consumed --servicelevel=\"" + servicelevel + "\" ProductSubscriptions contains all of the expected ProductSubscriptions (the expected list contains only consumptions with ServiceLevel=\"" + servicelevel + "\")");
Assert.assertTrue(expectedProductSubscriptions.containsAll(filteredProductSubscriptions), "The expected list of ProductSubscriptions contains all of the actual ProductSubscriptions returned by list --consumed --servicelevel=\"" + servicelevel + "\".");
String expectedStdout = "No consumed subscription pools to list";
// commit be815d04d1722dd8fd40a23c0a7847e97e689f89
if (clienttasks.isPackageVersion("subscription-manager", ">=", "1.13.6-1"))
expectedStdout = "No consumed subscription pools matching the specified criteria were found.";
// commit 2884e33acb35ab4e336fe12dc23de7ab26cc0572 // Bug 1159348 - list --matched should show the filter string when warning about empty matches
if (clienttasks.isPackageVersion("subscription-manager", ">=", "1.13.12-1"))
expectedStdout = String.format("No consumed subscription pools were found matching the service level \"%s\".", servicelevel);
if (expectedProductSubscriptions.isEmpty())
Assert.assertEquals(listResult.getStdout().trim(), expectedStdout, "Expected stdout message when no consumed subscriptions remain after list is filtered by --servicelevel=\"" + servicelevel + "\".");
}
use of com.redhat.qe.auto.tcms.ImplementsNitrateTest in project rhsm-qe by RedHatQE.
the class ListTests method testListAvailableWithNoOverlap.
@// update=true // uncomment to make TestDefinition changes update Polarion testcases through the polarize testcase importer
TestDefinition(projectID = { Project.RHEL6, Project.RedHatEnterpriseLinux7 }, testCaseID = { "RHEL6-36565", "RHEL7-51349" }, 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: subcription manager list all with --match-installed option", groups = { "Tier2Tests", "blockedByBug-654501", "blockedByBug-1022622", /*rhel7*/
"blockedByBug-1114717", /*rhel6*/
"blockedByBug-1493711" }, enabled = true)
public // @ImplementsNitrateTest(caseId=)
void testListAvailableWithNoOverlap() throws JSONException, Exception {
clienttasks.register(sm_clientUsername, sm_clientPassword, sm_clientOrg, null, null, null, null, null, null, null, (String) null, null, null, null, false, null, null, null, null, null);
clienttasks.autoheal(null, null, true, null, null, null, null);
// assemble a list of currently installed product ids
List<ProductCert> installedProductCerts = clienttasks.getCurrentProductCerts();
List<String> installedProductIds = new ArrayList<String>();
for (ProductCert productCert : installedProductCerts) installedProductIds.add(productCert.productId);
// get the available subscription pools
List<SubscriptionPool> availableSubscriptionPools = SubscriptionPool.parse(clienttasks.list(null, true, null, null, null, null, null, false, null, null, null, null, null, null).getStdout());
// randomly attach a positive subset of available subscriptions
List<SubscriptionPool> randomAvailableSubscriptionPools = getRandomSubsetOfList(availableSubscriptionPools, randomGenerator.nextInt(availableSubscriptionPools.size() - 1) + 1);
List<String> poolIds = new ArrayList<String>();
for (SubscriptionPool subscriptionPool : randomAvailableSubscriptionPools) poolIds.add(subscriptionPool.poolId);
if (false) {
// debugTesting will cause test to fail due to bugzilla https://bugzilla.redhat.com/show_bug.cgi?id=1022622#c0
poolIds.clear();
poolIds.add(SubscriptionPool.findFirstInstanceWithMatchingFieldFromList("subscriptionName", "Awesome OS Server Basic", availableSubscriptionPools).poolId);
poolIds.add(SubscriptionPool.findFirstInstanceWithMatchingFieldFromList("subscriptionName", "Awesome OS for All Arch (excpt for x86_64 content)", availableSubscriptionPools).poolId);
poolIds.add(SubscriptionPool.findFirstInstanceWithMatchingFieldFromList("subscriptionName", "Awesome OS with unlimited virtual guests", availableSubscriptionPools).poolId);
poolIds.add(SubscriptionPool.findFirstInstanceWithMatchingFieldFromList("subscriptionName", "Multi-Attribute Stackable (2 GB, 2 Cores)", availableSubscriptionPools).poolId);
poolIds.add(SubscriptionPool.findFirstInstanceWithMatchingFieldFromList("subscriptionName", "Awesome OS Server Basic (data center)", availableSubscriptionPools).poolId);
poolIds.add(SubscriptionPool.findFirstInstanceWithMatchingFieldFromList("subscriptionName", "Multi-Attribute Stackable (2 sockets)", availableSubscriptionPools).poolId);
poolIds.add(SubscriptionPool.findFirstInstanceWithMatchingFieldFromList("subscriptionName", "Awesome OS for systems with no sockets", availableSubscriptionPools).poolId);
poolIds.add(SubscriptionPool.findFirstInstanceWithMatchingFieldFromList("subscriptionName", "Awesome OS Server Basic (multi-entitlement)", availableSubscriptionPools).poolId);
poolIds.add(SubscriptionPool.findFirstInstanceWithMatchingFieldFromList("subscriptionName", "Awesome OS Modifier", availableSubscriptionPools).poolId);
}
clienttasks.subscribe(null, null, poolIds, null, null, "1", null, null, null, null, null, null, null);
List<InstalledProduct> installedProducts = InstalledProduct.parse(clienttasks.list(null, null, null, true, null, null, null, null, null, null, null, null, null, null).getStdout());
List<SubscriptionPool> availableSubscriptionPoolsWithoutOverlap = SubscriptionPool.parse(clienttasks.list(null, true, null, null, null, null, null, true, null, null, null, null, null, null).getStdout());
// loop through the list of available subscription pools without overlap and assert that at least one of pool's provided products is not fully subscribed.
for (SubscriptionPool subscriptionPool : availableSubscriptionPoolsWithoutOverlap) {
boolean noOverlapFound = false;
List<String> providedProductIds = CandlepinTasks.getPoolProvidedProductIds(sm_clientUsername, sm_clientPassword, sm_serverUrl, subscriptionPool.poolId);
if (providedProductIds.isEmpty()) {
Assert.assertTrue(providedProductIds.isEmpty(), "Subscription '" + subscriptionPool.subscriptionName + "' provides=" + subscriptionPool.provides + " reported in the list available with no-overlap provides no products and therefore does not overlap an already covered product.");
noOverlapFound = true;
}
for (String providedProductId : providedProductIds) {
InstalledProduct installedProduct = InstalledProduct.findFirstInstanceWithMatchingFieldFromList("productId", providedProductId, installedProducts);
if (installedProduct != null) {
if (!installedProduct.status.equalsIgnoreCase("Subscribed")) {
Assert.assertTrue(!installedProduct.status.equalsIgnoreCase("Subscribed"), "Subscription '" + subscriptionPool.subscriptionName + "' provides=" + subscriptionPool.provides + " reported in the list available with no-overlap provides product id '" + providedProductId + "' which is installed with status '" + installedProduct.status + "' and therefore does not overlap an already covered product.");
noOverlapFound = true;
} else {
log.warning("Subscription '" + subscriptionPool.subscriptionName + "' provides=" + subscriptionPool.provides + " reported in the list available with no-overlap provides product id '" + providedProductId + "' which is installed with status '" + installedProduct.status + "'.");
}
} else {
Assert.assertTrue(installedProduct == null, "Subscription '" + subscriptionPool.subscriptionName + "' provides=" + subscriptionPool.provides + " reported in the list available with no-overlap provides product id '" + providedProductId + "' which is not installed and therefore does not overlap an already covered product.");
noOverlapFound = true;
}
}
Assert.assertTrue(noOverlapFound, "Subscription '" + subscriptionPool.subscriptionName + "' provides=" + subscriptionPool.provides + " that is reported in the list available with no-overlap provides at least one product that is not fully Subscribed.");
}
// the remainder of this --no-overlap test has been fixed in subscription-manager-1.12.6-1 and newer; otherwise skip it.
if (clienttasks.isPackageVersion("subscription-manager", "<", "1.12.6-1"))
throw new SkipException("The installed version of subscription-manager does not contain the fix for https://bugzilla.redhat.com/show_bug.cgi?id=1022622#c3");
// assert that availableSubscriptionPools that are not filtered out of the availableSubscriptionPoolsWithoutOverlap provide products that are all fully Subscribed
availableSubscriptionPools = SubscriptionPool.parse(clienttasks.list(null, true, null, null, null, null, null, false, null, null, null, null, null, null).getStdout());
for (SubscriptionPool availableSubscriptionPool : availableSubscriptionPools) {
if (!availableSubscriptionPoolsWithoutOverlap.contains(availableSubscriptionPool)) {
for (String providedProductId : CandlepinTasks.getPoolProvidedProductIds(sm_clientUsername, sm_clientPassword, sm_serverUrl, availableSubscriptionPool.poolId)) {
InstalledProduct installedProduct = InstalledProduct.findFirstInstanceWithMatchingFieldFromList("productId", providedProductId, installedProducts);
if (installedProduct != null) {
Assert.assertEquals(installedProduct.status, "Subscribed", "Subscription '" + availableSubscriptionPool.subscriptionName + "' provides=" + availableSubscriptionPool.provides + " is excluded from the list available with no-overlap. It provides product id '" + providedProductId + "' which is installed and covered by an active subscription.");
} else {
// skip the providedProductId when not installed
}
}
}
}
}
use of com.redhat.qe.auto.tcms.ImplementsNitrateTest in project rhsm-qe by RedHatQE.
the class ListTests method testListAvailableWithWildcardMatches.
@// update=true // uncomment to make TestDefinition changes update Polarion testcases through the polarize testcase importer
TestDefinition(projectID = { Project.RHEL6, Project.RedHatEnterpriseLinux7 }, testCaseID = { "RHEL6-19965", "RHEL7-33095" }, 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 = "subscription-manager: subcription manager list --available with wildcard --matches on Subscription Name, Provided Product Name, Contract Number, SKU, Service Level, Provided Product ID. Note: wildcard match means * matches zero or more char and ? matches one char and is case insensitive.", groups = { "Tier1Tests", "blockedByBug-1146125", "blockedByBug-1301696", "blockedByBug-1493711" }, enabled = true)
public // @ImplementsNitrateTest(caseId=)
void testListAvailableWithWildcardMatches() throws JSONException, Exception {
if (clienttasks.isPackageVersion("subscription-manager", "<", "1.13.6-1"))
throw new SkipException("The list --matches function was not implemented in this version of subscription-manager.");
// candlepin commit e5b6c24f2322b79a7ea8bb1e8c85a8cb86733471
if (SubscriptionManagerTasks.isVersion(servertasks.statusVersion, "<", "0.9.33-1"))
throw new SkipException("Candlepin support for list --available --matches function was not implemented in server version '" + servertasks.statusVersion + "'.");
String matchesString;
List<SubscriptionPool> expectedPools, actualSubscriptionPoolMatches;
Boolean all = getRandomBoolean();
Boolean matchInstalled = getRandomBoolean();
Boolean noOverlap = getRandomBoolean();
// /*debugTesting*/ all=true; noOverlap=true; matchInstalled=false; // Bug 1301696 - getting unexpected hits on TESTDATA from subscription-manager list --available --matches=*os*
// /*debugTesting*/ all=true; noOverlap=false; matchInstalled=false;
log.info("Testing with all=" + all);
log.info("Testing with matchInstalled=" + matchInstalled);
log.info("Testing with noOverlap=" + noOverlap);
if (clienttasks.getCurrentlyRegisteredOwnerKey() == null) {
clienttasks.register(sm_clientUsername, sm_clientPassword, sm_clientOrg, null, null, null, null, null, null, null, (String) null, null, null, null, true, null, null, null, null, null);
clienttasks.autoheal(null, null, true, null, null, null, null);
} else
clienttasks.unsubscribe_(true, (BigInteger) null, null, null, null, null, null);
// get all the available subscription pools
SSHCommandResult listResult = clienttasks.list(all, true, null, null, null, null, matchInstalled, noOverlap, null, null, null, null, null, null);
if (matchInstalled && clienttasks.getCurrentlyInstalledProducts().isEmpty()) {
String skipCase = "No available subscription pools to list";
Assert.assertEquals(listResult.getStdout().trim(), skipCase);
throw new SkipException("Skipping this test when: " + skipCase);
}
List<SubscriptionPool> availableSubscriptionPools = SubscriptionPool.parse(listResult.getStdout());
// randomly choose an available pool
SubscriptionPool randomAvailablePool = getRandomListItem(availableSubscriptionPools);
// /*debugTesting*/ randomAvailablePool = SubscriptionPool.findFirstInstanceWithMatchingFieldFromList("productId", "awesomeos-ostree", availableSubscriptionPools); // Bug 1301696 - getting unexpected hits on TESTDATA from subscription-manager list --available --matches=*os*
// /*debugTesting*/ randomAvailablePool = SubscriptionPool.findFirstInstanceWithMatchingFieldFromList("productId", "RH0380468", availableSubscriptionPools); // Bug 1301696 - getting unexpected hits on TESTDATA from subscription-manager list --available --matches=*os*
log.info("Testing with randomAvailablePool=" + randomAvailablePool);
// +-------------------------------------------+
// Available Subscriptions
// +-------------------------------------------+
// Subscription Name: Awesome OS OSTree
// Provides: Awesome OS OStree Bits
// SKU: awesomeos-ostree
// Contract: 3
// Pool ID: 2c90af8b49435579014943591343172c
// Available: 10
// Suggested: 1
// Service Level:
// Service Type:
// Subscription Type: Standard
// Ends: 10/23/2015
// System Type: Physical
// Test 1: test wildcard --matches on Subscription Name:
matchesString = randomAvailablePool.subscriptionName;
// drop first word
matchesString = matchesString.replaceFirst("^\\S+\\s+", "*");
actualSubscriptionPoolMatches = SubscriptionPool.parse(clienttasks.list(all, true, null, null, null, null, matchInstalled, noOverlap, matchesString, null, null, null, null, null).getStdout());
assertActualResultOfListAvailableWithMatches(matchesString, actualSubscriptionPoolMatches, availableSubscriptionPools);
// also test case insensitivity
matchesString = randomizeCaseOfCharactersInString(matchesString);
// and drop last word
matchesString = matchesString.replaceFirst("\\s+\\S+$", "*");
actualSubscriptionPoolMatches = SubscriptionPool.parse(clienttasks.list(all, true, null, null, null, null, matchInstalled, noOverlap, matchesString, null, null, null, null, null).getStdout());
assertActualResultOfListAvailableWithMatches(matchesString, actualSubscriptionPoolMatches, availableSubscriptionPools);
// Test 2: test wildcard --matches on Provides:
if (!randomAvailablePool.provides.isEmpty()) {
matchesString = getRandomListItem(randomAvailablePool.provides);
// drop last word
matchesString = matchesString.replaceFirst("\\s+\\S+$", "*");
actualSubscriptionPoolMatches = SubscriptionPool.parse(clienttasks.list(all, true, null, null, null, null, matchInstalled, noOverlap, matchesString, null, null, null, null, null).getStdout());
assertActualResultOfListAvailableWithMatches(matchesString, actualSubscriptionPoolMatches, availableSubscriptionPools);
// also test case insensitivity
matchesString = randomizeCaseOfCharactersInString(matchesString);
// and drop first word
matchesString = matchesString.replaceFirst("^\\S+\\s+", "*");
actualSubscriptionPoolMatches = SubscriptionPool.parse(clienttasks.list(all, true, null, null, null, null, matchInstalled, noOverlap, matchesString, null, null, null, null, null).getStdout());
assertActualResultOfListAvailableWithMatches(matchesString, actualSubscriptionPoolMatches, availableSubscriptionPools);
} else
log.warning("Skipping list --available --matches test on a Provides item since the provides list is empty on our random available subscription: " + randomAvailablePool);
// Test 3: test wildcard --matches on SKU:
matchesString = randomAvailablePool.productId;
// drop first char
matchesString = matchesString.replaceFirst("^.", "?");
actualSubscriptionPoolMatches = SubscriptionPool.parse(clienttasks.list(all, true, null, null, null, null, matchInstalled, noOverlap, matchesString, null, null, null, null, null).getStdout());
assertActualResultOfListAvailableWithMatches(matchesString, actualSubscriptionPoolMatches, availableSubscriptionPools);
// also test case insensitivity
matchesString = randomizeCaseOfCharactersInString(matchesString);
// and drop last char
matchesString = matchesString.replaceFirst(".$", "?");
actualSubscriptionPoolMatches = SubscriptionPool.parse(clienttasks.list(all, true, null, null, null, null, matchInstalled, noOverlap, matchesString, null, null, null, null, null).getStdout());
assertActualResultOfListAvailableWithMatches(matchesString, actualSubscriptionPoolMatches, availableSubscriptionPools);
// Test 4: test wildcard --matches on Contract:
if (randomAvailablePool.contract != null && !randomAvailablePool.contract.isEmpty()) {
matchesString = randomAvailablePool.contract;
// drop the last char and replace it with a '?' wildcard
matchesString = matchesString.replaceFirst(".$", "?");
actualSubscriptionPoolMatches = SubscriptionPool.parse(clienttasks.list(all, true, null, null, null, null, matchInstalled, noOverlap, matchesString, null, null, null, null, null).getStdout());
assertActualResultOfListAvailableWithMatches(matchesString, actualSubscriptionPoolMatches, availableSubscriptionPools);
// also test case insensitivity
matchesString = randomizeCaseOfCharactersInString(matchesString);
// also drop the first char and replace it with a '?' wildcard
matchesString = matchesString.replaceFirst("^.", "?");
actualSubscriptionPoolMatches = SubscriptionPool.parse(clienttasks.list(all, true, null, null, null, null, matchInstalled, noOverlap, matchesString, null, null, null, null, null).getStdout());
assertActualResultOfListAvailableWithMatches(matchesString, actualSubscriptionPoolMatches, availableSubscriptionPools);
} else
log.warning("Skipping list --available --matches test on a Contract item since it is null or empty on our random available subscription: " + randomAvailablePool);
// Test 5: test wildcard --matches on Service Level:
if (randomAvailablePool.serviceLevel != null && !randomAvailablePool.serviceLevel.isEmpty()) {
matchesString = randomAvailablePool.serviceLevel;
// drop first char
matchesString = matchesString.replaceFirst("^.", "*");
// drop last char
matchesString = matchesString.replaceFirst(".$", "?");
actualSubscriptionPoolMatches = SubscriptionPool.parse(clienttasks.list(all, true, null, null, null, null, matchInstalled, noOverlap, matchesString, null, null, null, null, null).getStdout());
assertActualResultOfListAvailableWithMatches(matchesString, actualSubscriptionPoolMatches, availableSubscriptionPools);
// also test case insensitivity
matchesString = randomizeCaseOfCharactersInString(matchesString);
actualSubscriptionPoolMatches = SubscriptionPool.parse(clienttasks.list(all, true, null, null, null, null, matchInstalled, noOverlap, matchesString, null, null, null, null, null).getStdout());
assertActualResultOfListAvailableWithMatches(matchesString, actualSubscriptionPoolMatches, availableSubscriptionPools);
} else
log.warning("Skipping list --available --matches test on a Service Level item since it is null or empty on our random available subscription: " + randomAvailablePool);
// Test 6: test wildcard --matches on Provided ProductId:
if (!randomAvailablePool.provides.isEmpty()) {
matchesString = getRandomListItem(CandlepinTasks.getPoolProvidedProductIds(sm_clientUsername, sm_clientPassword, sm_serverUrl, randomAvailablePool.poolId));
int i = randomGenerator.nextInt(matchesString.length());
matchesString = matchesString.replaceAll(String.valueOf(matchesString.charAt(i)), "?");
actualSubscriptionPoolMatches = SubscriptionPool.parse(clienttasks.list(all, true, null, null, null, null, matchInstalled, noOverlap, matchesString, null, null, null, null, null).getStdout());
assertActualResultOfListAvailableWithMatches(matchesString, actualSubscriptionPoolMatches, availableSubscriptionPools);
} else
log.warning("Skipping list --available --matches test on a Provides ProductId item since the provides list is empty on our random available subscription: " + randomAvailablePool);
// TODO Test 7: test exact --matches on a Content Name provided by a Provided ProductId
// see ListAvailableWithExactMatches_Test()
// TODO Test 8: test exact --matches on a Content Label provided by a Provided ProductId
// see ListAvailableWithExactMatches_Test()
}
use of com.redhat.qe.auto.tcms.ImplementsNitrateTest in project rhsm-qe by RedHatQE.
the class ListTests method testCatCertContainingUTF8Character.
@// update=true // uncomment to make TestDefinition changes update Polarion testcases through the polarize testcase importer
TestDefinition(projectID = { Project.RHEL6, Project.RedHatEnterpriseLinux7 }, testCaseID = { "RHEL6-37705", "RHEL7-51353" }, 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 = "rct: cat-cert an entitlement containing UTF-8 character(s)", groups = { "Tier2Tests", "SubscriptionContainingUTF8CharacterTests", "blockedByBug-890296", "blockedByBug-1048325" }, dependsOnMethods = { "testAttachSubscriptionContainingUTF8Character" }, priority = 130, enabled = true)
public // @ImplementsNitrateTest(caseId=)
void testCatCertContainingUTF8Character() throws JSONException, Exception {
// TEMPORARY WORKAROUND FOR BUG
// Bug 890296 - 'ascii' codec can't encode character u'\u2013'.
String bugId = "890296";
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) {
// must cleanup utf8-subscription-sku to avoid contaminating other tests; then skip this test
afterGroupForSubscriptionContainingUTF8CharacterTests();
throw new SkipException("Skipping test while bug '" + bugId + "' is open.");
}
// END OF WORKAROUND
List<File> entitlementCertFiles = clienttasks.getCurrentEntitlementCertFiles();
Assert.assertEquals(entitlementCertFiles.size(), 1, "Expecting only one entitlement cert being consumed.");
// [root@jsefler-6 ~]# rct cat-cert /etc/pki/entitlement/6487424643396210003.pem
// Traceback (most recent call last):
// File "/usr/bin/rct", line 44, in <module>
// sys.exit(abs(main() or 0))
// File "/usr/bin/rct", line 39, in main
// return RctCLI().main()
// File "/usr/share/rhsm/subscription_manager/cli.py", line 156, in main
// return cmd.main()
// File "/usr/share/rhsm/rct/commands.py", line 44, in main
// return_code = self._do_command()
// File "/usr/share/rhsm/rct/commands.py", line 92, in _do_command
// skip_products=self.options.no_products)
// File "/usr/share/rhsm/rct/printing.py", line 196, in printc
// printer.printc(cert)
// File "/usr/share/rhsm/rct/printing.py", line 105, in printc
// print self.cert_to_str(cert)
// File "/usr/share/rhsm/rct/printing.py", line 166, in cert_to_str
// order_printer.as_str(cert.order), "\n".join(s))
// File "/usr/share/rhsm/rct/printing.py", line 47, in as_str
// s.append("\t%s: %s" % (_("Name"), xstr(order.name)))
// File "/usr/share/rhsm/rct/printing.py", line 26, in xstr
// return str(value)
// UnicodeEncodeError: 'ascii' codec can't encode character u'\u2013' in position 32: ordinal not in range(128)
// [root@jsefler-6 ~]# echo $?
// 1
// SSHCommandResult sshCommandResult = clienttasks.runCommandWithLang(null/* null will cause command to be prefixed with PYTHONIOENCODING=ascii */, "rct cat-cert "+entitlementCertFiles.get(0)); // need for PYTHONIOENCODING=ascii workaround was eliminated by bug 1048325
SSHCommandResult sshCommandResult = client.runCommandAndWait("rct cat-cert " + entitlementCertFiles.get(0));
Assert.assertEquals(sshCommandResult.getExitCode(), Integer.valueOf(0), "ExitCode from an attempt to run rct cat-cert on an entitlement containing UTF-8 character(s)");
Assert.assertEquals(sshCommandResult.getStderr().trim(), "", "Stderr from an attempt to run rct cat-cert on an entitlement containing UTF-8 character(s)");
}
use of com.redhat.qe.auto.tcms.ImplementsNitrateTest in project rhsm-qe by RedHatQE.
the class ListTests method testHardwareMatchingSubscriptionsAreListedAsAvailable.
@// update=true // uncomment to make TestDefinition changes update Polarion testcases through the polarize testcase importer
TestDefinition(projectID = { Project.RHEL6, Project.RedHatEnterpriseLinux7 }, testCaseID = { "RHEL6-19963", "RHEL7-33104" }, 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 = "subscription-manager-cli: list available subscriptions - verify that among all the subscriptions available to this consumer, those that satisfy the system hardware are listed as available", groups = { "Tier1Tests", "blockedByBug-712502", "unsubscribeBeforeGroup" }, dataProvider = "getAvailableSystemSubscriptionPoolProductData", enabled = true)
@ImplementsNitrateTest(caseId = 41678)
public void testHardwareMatchingSubscriptionsAreListedAsAvailable(String productId, JSONArray bundledProductDataAsJSONArray) throws JSONException, Exception {
// /*debugTesting*/if (!productId.equals("awesomeos-virt-unlmtd-phys")) throw new SkipException("debugTesting productId="+productId);
// /*debugTesting*/if (!productId.equals("MCT3115")) throw new SkipException("debugTesting productId="+productId);
// implicitly registered in dataProvider; no need to register with force; saves time
// clienttasks.register(clientusername, clientpassword, null, null, null, null, true, null, null, null);
SubscriptionPool pool = SubscriptionPool.findFirstInstanceWithMatchingFieldFromList("productId", productId, clienttasks.getCurrentlyAvailableSubscriptionPools());
// special case...
if (pool == null) {
// when pool is null, another likely cause is that all of the available subscriptions from the pools are being consumed, let's check...
for (String poolId : CandlepinTasks.getPoolIdsForProductId(sm_clientUsername, sm_clientPassword, sm_serverUrl, clienttasks.getCurrentlyRegisteredOwnerKey(), productId)) {
int quantity = (Integer) CandlepinTasks.getPoolValue(sm_clientUsername, sm_clientPassword, sm_serverUrl, poolId, "quantity");
int consumed = (Integer) CandlepinTasks.getPoolValue(sm_clientUsername, sm_clientPassword, sm_serverUrl, poolId, "consumed");
if (consumed >= quantity) {
throw new SkipException("The total quantity '" + quantity + "' of subscriptions from poolId '" + poolId + "' for product '" + productId + "' are being consumed; hence this pool is appropriately not available despite a match in hardware");
}
}
// another possible cause is that the pool.productAttributes.arch list on the pool is older than the subscription.product.attributes.arch
SubscriptionPool poolFromAllAvailable = SubscriptionPool.findFirstInstanceWithMatchingFieldFromList("productId", productId, clienttasks.getCurrentlyAllAvailableSubscriptionPools());
if (poolFromAllAvailable != null) {
String poolArch = (String) CandlepinTasks.getPoolProductAttributeValue(sm_clientUsername, sm_clientPassword, sm_serverUrl, poolFromAllAvailable.poolId, "arch");
// Note: the arch attribute can be a comma separated list of values
List<String> poolArches = new ArrayList<String>();
// Note: the arch attribute can be a comma separated list of values
poolArches.addAll(Arrays.asList(poolArch.trim().split(" *, *")));
String subscriptionId = CandlepinTasks.getSubscriptionIdForPoolId(sm_clientUsername, sm_clientPassword, sm_serverUrl, poolFromAllAvailable.poolId);
JSONObject jsonSubscription = new JSONObject(CandlepinTasks.getResourceUsingRESTfulAPI(sm_serverAdminUsername, sm_serverAdminPassword, sm_serverUrl, "/subscriptions/" + subscriptionId));
String subscriptionArch = CandlepinTasks.getResourceAttributeValue(jsonSubscription.getJSONObject("product"), "arch");
// Note: the arch attribute can be a comma separated list of values
List<String> subscriptionArches = new ArrayList<String>();
// Note: the arch attribute can be a comma separated list of values
subscriptionArches.addAll(Arrays.asList(subscriptionArch.trim().split(" *, *")));
if (!poolArches.containsAll(subscriptionArches) || !subscriptionArches.containsAll(poolArches)) {
log.warning("There is an all available pool for product '" + productId + "' whose arch " + poolArches + " does not match its corresponding subscription arch " + subscriptionArches + ". Likely, there was an upstream SKU change by dev-ops that requires an org level pool refresh.");
}
}
}
Assert.assertNotNull(pool, "Expected SubscriptionPool with ProductId '" + productId + "' is listed as available for subscribing. (Look for warnings above to explain a failure. A pool refresh may also fix a failure.)");
}
Aggregations