use of com.redhat.qe.auto.tcms.ImplementsNitrateTest in project rhsm-qe by RedHatQE.
the class ListTests method testListInstalledWithWildcardMatches.
@// update=true // uncomment to make TestDefinition changes update Polarion testcases through the polarize testcase importer
TestDefinition(projectID = { Project.RHEL6, Project.RedHatEnterpriseLinux7 }, testCaseID = { "RHEL6-36559", "RHEL7-51339" }, 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 --installed with wildcard --matches on Product Name, Product ID. Note: wildcard match means * matches zero or more char and ? matches one char and is case insensitive.", groups = { "Tier2Tests", "blockedByBug-1146125" }, enabled = true)
public // @ImplementsNitrateTest(caseId=)
void testListInstalledWithWildcardMatches() 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.");
String matchesString;
List<InstalledProduct> actualInstalledProductMatches;
// register if necessary
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);
// attach one of all the currently available subscriptions (attaching only one so that some installed products might remain noncompliant)
// assemble a list of all the available SubscriptionPool ids
List<String> poolIds = new ArrayList<String>();
List<SubscriptionPool> subscriptionPools = clienttasks.getCurrentlyAvailableSubscriptionPools();
for (SubscriptionPool pool : subscriptionPools) poolIds.add(pool.poolId);
if (!poolIds.isEmpty())
clienttasks.subscribe(null, null, poolIds, null, null, "1", null, null, null, null, null, null, null);
// get all the installed products
List<InstalledProduct> installedProducts = InstalledProduct.parse(clienttasks.list(null, null, null, true, null, null, null, null, null, null, null, null, null, null).getStdout());
// randomly choose one of the installed products
InstalledProduct randomInstalledProduct = getRandomListItem(installedProducts);
// [root@jsefler-os7 ~]# subscription-manager list --installed
// Product Name: Red Hat Enterprise Linux Server
// Product ID: 69
// Version: 7.0
// Arch: x86_64
// Status: Not Subscribed
// Status Details: Not supported by a valid subscription.
// Starts:
// Ends:
// Test 1: test wildcard --matches on Product Name:
matchesString = randomInstalledProduct.productName;
// drop first word
matchesString = matchesString.replaceFirst("^\\S+\\s+", "*");
actualInstalledProductMatches = InstalledProduct.parse(clienttasks.list(null, null, null, true, null, null, null, null, matchesString, null, null, null, null, null).getStdout());
assertActualResultOfListInstalledWithMatches(matchesString, actualInstalledProductMatches, installedProducts);
// also test case insensitivity
matchesString = randomizeCaseOfCharactersInString(matchesString);
// and drop last word
matchesString = matchesString.replaceFirst("\\s+\\S+$", "*");
actualInstalledProductMatches = InstalledProduct.parse(clienttasks.list(null, null, null, true, null, null, null, null, matchesString, null, null, null, null, null).getStdout());
assertActualResultOfListInstalledWithMatches(matchesString, actualInstalledProductMatches, installedProducts);
// Test 2: test wildcard --matches on Product ID:
matchesString = randomInstalledProduct.productId;
int i = randomGenerator.nextInt(matchesString.length());
matchesString = matchesString.replaceAll(String.valueOf(matchesString.charAt(i)), "?");
actualInstalledProductMatches = InstalledProduct.parse(clienttasks.list(null, null, null, true, null, null, null, null, matchesString, null, null, null, null, null).getStdout());
assertActualResultOfListInstalledWithMatches(matchesString, actualInstalledProductMatches, installedProducts);
// also test case insensitivity
/* not necessary since productId is an integer
matchesString = randomizeCaseOfCharactersInString(matchesString);
actualInstalledProductMatches = InstalledProduct.parse(clienttasks.list(null, null, null, true, null, null, null, null, matchesString, null, null, null).getStdout());
assertActualResultOfListInstalledWithMatches(matchesString,actualInstalledProductMatches,installedProducts);
*/
}
use of com.redhat.qe.auto.tcms.ImplementsNitrateTest in project rhsm-qe by RedHatQE.
the class ListTests method testListAndListInstalledAreTheSame.
@// update=true // uncomment to make TestDefinition changes update Polarion testcases through the polarize testcase importer
TestDefinition(projectID = { Project.RHEL6, Project.RedHatEnterpriseLinux7 }, testCaseID = { "RHEL6-37702", "RHEL7-51347" }, 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: ensure list [--installed] produce the same results", groups = { "Tier2Tests" }, enabled = true)
public // @ImplementsNitrateTest(caseId=)
void testListAndListInstalledAreTheSame() throws JSONException, Exception {
clienttasks.unregister(null, null, null, null);
clienttasks.register(sm_clientUsername, sm_clientPassword, sm_clientOrg, null, null, null, null, null, null, null, (String) null, null, null, null, null, false, null, null, null, null);
// assert same results when no subscribed to anything...
log.info("assert list [--installed] produce same results when not subscribed to anything...");
SSHCommandResult listResult = clienttasks.list_(null, null, null, null, null, null, null, null, null, null, null, null, null, null);
SSHCommandResult listInstalledResult = clienttasks.list_(null, null, null, Boolean.TRUE, null, null, null, null, null, null, null, null, null, null);
Assert.assertEquals(listResult.getStdout(), listInstalledResult.getStdout(), "'list' and 'list --installed' produce the same stdOut results.");
Assert.assertEquals(listResult.getStderr(), listInstalledResult.getStderr(), "'list' and 'list --installed' produce the same stdErr results.");
Assert.assertEquals(listResult.getExitCode(), listInstalledResult.getExitCode(), "'list' and 'list --installed' produce the same exitCode results.");
// assert same results when subscribed to something...
log.info("assert list [--installed] produce same results when subscribed to something...");
List<SubscriptionPool> pools = clienttasks.getCurrentlyAvailableSubscriptionPools();
// randomly pick a pool
SubscriptionPool pool = pools.get(randomGenerator.nextInt(pools.size()));
clienttasks.subscribeToSubscriptionPool_(pool);
listResult = clienttasks.list_(null, null, null, null, null, null, null, null, null, null, null, null, null, null);
listInstalledResult = clienttasks.list_(null, null, null, Boolean.TRUE, null, null, null, null, null, null, null, null, null, null);
Assert.assertEquals(listResult.getStdout(), listInstalledResult.getStdout(), "'list' and 'list --installed' produce the same stdOut results.");
Assert.assertEquals(listResult.getStderr(), listInstalledResult.getStderr(), "'list' and 'list --installed' produce the same stdErr results.");
Assert.assertEquals(listResult.getExitCode(), listInstalledResult.getExitCode(), "'list' and 'list --installed' produce the same exitCode results.");
}
use of com.redhat.qe.auto.tcms.ImplementsNitrateTest in project rhsm-qe by RedHatQE.
the class ListTests method testListConsumedWithMatchesNothing.
@// update=true // uncomment to make TestDefinition changes update Polarion testcases through the polarize testcase importer
TestDefinition(projectID = { Project.RHEL6, Project.RedHatEnterpriseLinux7 }, testCaseID = { "RHEL6-36560", "RHEL7-51340" }, 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 with --matches='nothing'", groups = { "Tier2Tests", "blockedByBug-1146125", "blockedByBug-1493711" }, enabled = true)
public // @ImplementsNitrateTest(caseId=)
void testListConsumedWithMatchesNothing() 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.");
String matchesString = "nothing";
// register if necessary
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);
}
// attach any random pool
List<SubscriptionPool> pools = clienttasks.getCurrentlyAvailableSubscriptionPools();
if (pools.isEmpty())
throw new SkipException("Cannot randomly pick a pool for subscribing when there are no available pools for testing.");
// randomly pick a pool
SubscriptionPool pool = pools.get(randomGenerator.nextInt(pools.size()));
clienttasks.subscribe_(null, null, pool.poolId, null, null, null, null, null, null, null, null, null, null);
// test
SSHCommandResult result = clienttasks.list(null, null, true, null, null, null, null, null, matchesString, null, null, null, null, null);
String 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 expression \"%s\".", matchesString);
Assert.assertEquals(result.getExitCode(), new Integer(0), "Exitcode expected from calling list --consumed --matches with no expected matches.");
Assert.assertEquals(result.getStdout().trim(), expectedStdout, "Stdout expected from calling list --available --consumed with no expected matches.");
Assert.assertEquals(result.getStderr().trim(), "", "Stderr expected from calling list --consumed --matches with no expected matches.");
}
use of com.redhat.qe.auto.tcms.ImplementsNitrateTest in project rhsm-qe by RedHatQE.
the class ListTests method testAttemptListAvailableWithoutBeingRegistered.
@// update=true // uncomment to make TestDefinition changes update Polarion testcases through the polarize testcase importer
TestDefinition(projectID = { Project.RHEL6, Project.RedHatEnterpriseLinux7 }, testCaseID = { "RHEL6-37699", "RHEL7-51323" }, 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 = "subscription-manager: subcription manager list available should require being registered", groups = { "Tier2Tests" }, enabled = true)
public // @ImplementsNitrateTest(caseId=)
void testAttemptListAvailableWithoutBeingRegistered() {
SSHCommandResult listResult;
clienttasks.unregister(null, null, null, null);
listResult = clienttasks.list_(null, true, null, null, null, null, null, null, null, null, null, null, null, null);
if (clienttasks.isPackageVersion("subscription-manager", ">=", "1.13.8-1")) {
// post commit df95529a5edd0be456b3528b74344be283c4d258 bug 1119688
Assert.assertEquals(listResult.getExitCode(), Integer.valueOf(1), "The exit code from the list --available command indicates a problem.");
Assert.assertEquals(listResult.getStderr().trim(), clienttasks.msg_ConsumerNotRegistered, "stderr while attempting to list --available subscriptions should indicate registration is required");
Assert.assertEquals(listResult.getStdout().trim(), "", "stdout while attempting to list --available subscriptions when not registered");
} else {
// Assert.assertEquals(listResult.getExitCode(), Integer.valueOf(1), "The exit code from the list available command indicates a problem.");
// Assert.assertEquals(listResult.getStdout().trim(), "Error: You need to register this system by running `register` command before using this option.","Attempting to list available subscriptions should require registration.");
// results changed after bug fix 749332
Assert.assertEquals(listResult.getExitCode(), Integer.valueOf(255), "The exit code from the list available command indicates a problem.");
Assert.assertEquals(listResult.getStdout().trim(), clienttasks.msg_ConsumerNotRegistered, "Attempting to list --available subscriptions should require registration.");
}
listResult = clienttasks.list_(true, true, null, null, null, null, null, null, null, null, null, null, null, null);
if (clienttasks.isPackageVersion("subscription-manager", ">=", "1.13.8-1")) {
// post commit df95529a5edd0be456b3528b74344be283c4d258 bug 1119688
Assert.assertEquals(listResult.getExitCode(), Integer.valueOf(1), "The exit code from the list --all --available command indicates a problem.");
Assert.assertEquals(listResult.getStderr().trim(), clienttasks.msg_ConsumerNotRegistered, "stderr while attempting to list --all --available subscriptions should indicate registration is required");
Assert.assertEquals(listResult.getStdout().trim(), "", "stdout while attempting to list --all --available subscriptions when not registered");
} else {
// Assert.assertEquals(listResult.getExitCode(), Integer.valueOf(1), "The exit code from the list all available command indicates a problem.");
// Assert.assertEquals(listResult.getStdout().trim(), "Error: You need to register this system by running `register` command before using this option.","Attempting to list all available subscriptions should require registration.");
// results changed after bug fix 749332
Assert.assertEquals(listResult.getExitCode(), Integer.valueOf(255), "The exit code from the list all available command indicates a problem.");
Assert.assertEquals(listResult.getStdout().trim(), clienttasks.msg_ConsumerNotRegistered, "Attempting to list --all --available subscriptions should require registration.");
}
}
use of com.redhat.qe.auto.tcms.ImplementsNitrateTest in project rhsm-qe by RedHatQE.
the class ListTests method testListConsumedMatchesProductsListedInTheEntitlementCerts.
@// update=true // uncomment to make TestDefinition changes update Polarion testcases through the polarize testcase importer
TestDefinition(projectID = { Project.RHEL6, Project.RedHatEnterpriseLinux7 }, testCaseID = { "RHEL6-27117", "RHEL7-51343" }, 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: list of consumed entitlements should display the provided product marketing names", groups = { "Tier2Tests", "blockedByBug-878986", "blockedByBug-976924" }, dataProvider = "getAllEntitlementCertsData", // this new test implementation was implemented due to change in list of consumed product subscriptions (from many to one) - see bug 806986
enabled = true)
@ImplementsNitrateTest(caseId = 48092, fromPlan = 2481)
public void testListConsumedMatchesProductsListedInTheEntitlementCerts(EntitlementCert entitlementCert) {
// find the consumed product subscription corresponding to this entitlement cert and assert there is only one found
List<ProductSubscription> allConsumedProductSubscriptions = clienttasks.getCurrentlyConsumedProductSubscriptions();
List<ProductSubscription> productSubscriptions = ProductSubscription.findAllInstancesWithMatchingFieldFromList("serialNumber", entitlementCert.serialNumber, allConsumedProductSubscriptions);
Assert.assertEquals(productSubscriptions.size(), 1, "Found a single consumed product subscription with a matching serialNumber from this entitlementCert: " + entitlementCert);
ProductSubscription productSubscription = productSubscriptions.get(0);
List<String> providedProductNames = new ArrayList<String>();
for (ProductNamespace productNamespace : entitlementCert.productNamespaces) providedProductNames.add(productNamespace.name);
// TEMPORARY WORKAROUND FOR BUG
if (entitlementCert.orderNamespace.supportLevel == null || entitlementCert.orderNamespace.supportType == null) {
String bugId = "842170";
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) {
throw new SkipException("While bug " + bugId + " is open, skipping assertion of consumed product subscription in list for entitlement's with a null support level/type.");
}
}
// when the entitlement OID value parsed was null, it should effectively be reported as "" (Reference related bugs 842170 847354)
if (entitlementCert.orderNamespace.supportLevel == null)
entitlementCert.orderNamespace.supportLevel = "";
if (entitlementCert.orderNamespace.supportType == null)
entitlementCert.orderNamespace.supportType = "";
// Subscription Name: Awesome OS Server Bundled (2 Sockets, Standard Support)
// Provides: Clustering Bits
// Awesome OS Server Bits
// Shared Storage Bits
// Management Bits
// Large File Support Bits
// Load Balancing Bits
// SKU: awesomeos-server-2-socket-std
// Contract: 36
// Account: 12331131231
// Serial Number: 6683485045354827351
// Active: True
// Quantity Used: 1
// Service Level: Standard
// Service Type: L1-L3
// Starts: 07/20/2012
// Ends: 07/20/2013
Calendar now = Calendar.getInstance();
// TEMPORARY WORKAROUND FOR BUG
boolean invokeWorkaroundWhileBugIsOpen = true;
try {
String bugId = "883486";
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) {
log.warning("The workaround while this bug is open is to compensate the expected entitlement start/end dates for daylight savings.");
// adjust the expected entitlement dates for daylight savings time (changed by https://github.com/candlepin/subscription-manager/pull/385)
// now.get(Calendar.DST_OFFSET) will equal 0 in the winter StandardTime; will equal 1000*60*60 in the summer DaylightSavingsTime (when the local time zone observes DST)
entitlementCert.orderNamespace.startDate.add(Calendar.MILLISECOND, now.get(Calendar.DST_OFFSET) - entitlementCert.orderNamespace.startDate.get(Calendar.DST_OFFSET));
entitlementCert.orderNamespace.endDate.add(Calendar.MILLISECOND, now.get(Calendar.DST_OFFSET) - entitlementCert.orderNamespace.endDate.get(Calendar.DST_OFFSET));
}
// END OF WORKAROUND
// assert all of the product subscription's fields match the entitlement cert
Assert.assertEquals(productSubscription.productName, entitlementCert.orderNamespace.productName, "productName from ProductSubscription in list --consumed matches productName from OrderNamespace in this entitlementCert");
Assert.assertTrue(productSubscription.provides.containsAll(providedProductNames) && providedProductNames.containsAll(productSubscription.provides), "The consumed product subscription provides all the expected products " + providedProductNames + " from the provided ProductNamespaces in the entitlementCert.");
Assert.assertEquals(productSubscription.productId, entitlementCert.orderNamespace.productId, "productId from ProductSubscription in list --consumed matches productId from OrderNamespace in this entitlementCert");
Assert.assertEquals(productSubscription.contractNumber, entitlementCert.orderNamespace.contractNumber, "contractNumber from ProductSubscription in list --consumed matches contractNumber from OrderNamespace in this entitlementCert");
Assert.assertEquals(productSubscription.accountNumber, entitlementCert.orderNamespace.accountNumber, "accountNumber from ProductSubscription in list --consumed matches accountNumber from OrderNamespace in this entitlementCert");
if (now.after(entitlementCert.orderNamespace.startDate) && now.before(entitlementCert.orderNamespace.endDate)) {
Assert.assertTrue(productSubscription.isActive, "isActive is True when the current time (" + EntitlementCert.formatDateString(now) + ") is between the start/end dates in this entitlementCert");
} else {
Assert.assertFalse(productSubscription.isActive, "isActive is False when the current time (" + EntitlementCert.formatDateString(now) + ") is NOT between the start/end dates in this entitlementCert");
}
Assert.assertEquals(productSubscription.quantityUsed.toString(), entitlementCert.orderNamespace.quantityUsed, "quantityUsed from ProductSubscription in list --consumed matches quantityUsed from OrderNamespace in this entitlementCert");
Assert.assertEquals(productSubscription.serviceLevel, entitlementCert.orderNamespace.supportLevel, "serviceLevel from ProductSubscription in list --consumed matches supportLevel from OrderNamespace in this entitlementCert");
Assert.assertEquals(productSubscription.serviceType, entitlementCert.orderNamespace.supportType, "serviceType from ProductSubscription in list --consumed matches serviceType from OrderNamespace in this entitlementCert");
Assert.assertEquals(ProductSubscription.formatDateString(productSubscription.startDate), ProductSubscription.formatDateString(entitlementCert.orderNamespace.startDate), "startDate from ProductSubscription in list --consumed matches startDate from OrderNamespace (" + OrderNamespace.formatDateString(entitlementCert.orderNamespace.startDate) + ") after conversion from GMT in EntitlementCert to local time.");
Assert.assertEquals(ProductSubscription.formatDateString(productSubscription.endDate), ProductSubscription.formatDateString(entitlementCert.orderNamespace.endDate), "endDate from ProductSubscription in list --consumed matches endDate from OrderNamespace (" + OrderNamespace.formatDateString(entitlementCert.orderNamespace.endDate) + ") after conversion from GMT in EntitlementCert to local time.");
}
Aggregations