use of com.github.redhatqe.polarize.metadata.TestDefinition in project rhsm-qe by RedHatQE.
the class ServiceLevelTests method testRegisterWithUnavailableServiceLevel.
@// update=true, // uncomment to make TestDefinition changes update Polarion testcases through the polarize testcase importer
TestDefinition(projectID = { Project.RHEL6, Project.RedHatEnterpriseLinux7 }, testCaseID = { "RHEL6-21863", "RHEL7-51725" }, 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 = "Tier3")
@Test(description = "subscription-manager: register to a Candlepin server using autosubscribe with an unavailable servicelevel", groups = { "Tier3Tests", "blockedByBug-795798", "blockedByBug-864508", "blockedByBug-864508", "blockedByBug-1221273" }, enabled = true)
public void testRegisterWithUnavailableServiceLevel() {
// attempt the registration
String unavailableServiceLevel = "FOO";
SSHCommandResult sshCommandResult = clienttasks.register_(sm_clientUsername, sm_clientPassword, sm_clientOrg, null, null, null, null, true, unavailableServiceLevel, null, (String) null, null, null, null, true, null, null, null, null, null);
String msg;
// valid before bug fix 795798 - Cannot set a service level for a consumer that is not available to its organization.
msg = "Cannot set a service level for a consumer that is not available to its organization.";
// valid before bug fix 864508 - Service level {0} is not available to consumers....
msg = String.format("Service level %s is not available to consumers of organization %s.", unavailableServiceLevel, sm_clientOrg);
msg = String.format("Service level '%s' is not available to consumers of organization %s.", unavailableServiceLevel, sm_clientOrg);
if (!clienttasks.workaroundForBug876764(sm_serverType))
msg = String.format("Service level '%s' is not available to units of organization %s.", unavailableServiceLevel, sm_clientOrg);
Integer expectedExitCode = new Integer(255);
// EX_SOFTWARE // post commit df95529a5edd0be456b3528b74344be283c4d258 bug 1119688
if (clienttasks.isPackageVersion("subscription-manager", ">=", "1.13.8-1"))
expectedExitCode = new Integer(70);
// post RHEL7.2 commit 84340a0acda9f070e3e0b733e4335059b5dc204e bug 1221273
if (clienttasks.isPackageVersion("subscription-manager", ">=", "1.15.9-5"))
expectedExitCode = new Integer(1);
Assert.assertEquals(sshCommandResult.getExitCode(), expectedExitCode);
if (clienttasks.isPackageVersion("subscription-manager", ">=", "1.16.3-1")) {
// post commit 7795df84edcb4f4fef08085548f6c2a23f86ceb4 bug 1262919: Added convenience function for printing to stderr
Assert.assertEquals(sshCommandResult.getStderr().trim(), msg, "Stderr message from an attempt to register with autosubscribe and an unavailable servicelevel.");
} else if (clienttasks.isPackageVersion("subscription-manager", ">=", "1.15.9-5")) {
// post RHEL7.2 commit 84340a0acda9f070e3e0b733e4335059b5dc204e bug 1221273
Assert.assertTrue(sshCommandResult.getStdout().trim().contains(msg), "Stdout message contains: " + msg);
Assert.assertEquals(sshCommandResult.getStderr().trim(), "", "Stderr message from an attempt to register with autosubscribe and an unavailable servicelevel.");
} else if (clienttasks.isPackageVersion("subscription-manager", ">=", "1.13.9-1")) {
// post commit a695ef2d1da882c5f851fde90a24f957b70a63ad
Assert.assertEquals(sshCommandResult.getStderr().trim(), msg, "Stderr message from an attempt to register with autosubscribe and an unavailable servicelevel.");
} else {
Assert.assertTrue(sshCommandResult.getStdout().trim().contains(msg), "Stdout message contains: " + msg);
Assert.assertEquals(sshCommandResult.getStderr().trim(), "", "Stderr message from an attempt to register with autosubscribe and an unavailable servicelevel.");
}
// despite a failed attempt to set a service level, we should still be registered
Assert.assertNotNull(clienttasks.getCurrentConsumerId(), "Despite a failed attempt to set a service level during register with autosubscribe, we should still be registered");
// since the autosubscribe was aborted, we should not be consuming and entitlements
Assert.assertTrue(clienttasks.getCurrentEntitlementCerts().isEmpty(), "Due to a failed attempt to set a service level during register with autosubscribe, we should not be consuming any entitlements.");
}
use of com.github.redhatqe.polarize.metadata.TestDefinition in project rhsm-qe by RedHatQE.
the class ServiceLevelTests method testSetDefaultServiceLevelForOrgAndRegister.
@// update=true, // uncomment to make TestDefinition changes update Polarion testcases through the polarize testcase importer
TestDefinition(projectID = { Project.RHEL6, Project.RedHatEnterpriseLinux7 }, testCaseID = { "RHEL6-21869", "RHEL7-51714" }, level = DefTypes.Level.COMPONENT, component = "subscription-manager", testtype = @TestType(testtype = DefTypes.TestTypes.FUNCTIONAL, subtype1 = DefTypes.Subtypes.RELIABILITY, subtype2 = DefTypes.Subtypes.EMPTY), posneg = PosNeg.POSITIVE, importance = DefTypes.Importance.HIGH, automation = DefTypes.Automation.AUTOMATED, tags = "Tier3")
@Test(description = "Using curl, set the default service level for an org and then register using org credentials to verify consumer's service level", groups = { "Tier3Tests", "SetDefaultServiceLevelForOrgAndRegister_Test" }, // dataProvider="getAllAvailableServiceLevelData", // 06/05/2014 takes too long; rarely reveals a bug
dataProvider = "getRandomSubsetOfAllAvailableServiceLevelData", enabled = true)
public // @ImplementsNitrateTest(caseId=)
void testSetDefaultServiceLevelForOrgAndRegister(Object bugzilla, String defaultServiceLevel) throws JSONException, Exception {
// update the defaultServiceLevel on the Org
if (orgForSetDefaultServiceLevelForOrgAndRegister_Test == null)
orgForSetDefaultServiceLevelForOrgAndRegister_Test = clienttasks.getCurrentlyRegisteredOwnerKey();
JSONObject jsonOrg = CandlepinTasks.setAttributeForOrg(sm_clientUsername, sm_clientPassword, sm_serverUrl, orgForSetDefaultServiceLevelForOrgAndRegister_Test, "defaultServiceLevel", defaultServiceLevel);
Assert.assertEquals(jsonOrg.get("defaultServiceLevel"), defaultServiceLevel, "The defaultServiceLevel update to org '" + orgForSetDefaultServiceLevelForOrgAndRegister_Test + "' appears successful on the candlepin server.");
// register and assert the consumer's service level is set to the new org default
clienttasks.register(sm_clientUsername, sm_clientPassword, sm_clientOrg, /*will either be null or equal to orgForSetDefaultServiceLevelForOrgAndRegister_Test*/
null, null, null, null, null, null, null, (String) null, null, null, null, true, null, null, null, null, null);
Assert.assertEquals(clienttasks.getCurrentServiceLevel(), defaultServiceLevel, "Immediately upon registering, the consumer's service level preference was set to the org's default.");
}
use of com.github.redhatqe.polarize.metadata.TestDefinition in project rhsm-qe by RedHatQE.
the class ServiceLevelTests method testUnsetDefaultServiceLevelForOrgAndRegister.
@// update=true, // uncomment to make TestDefinition changes update Polarion testcases through the polarize testcase importer
TestDefinition(projectID = { Project.RHEL6, Project.RedHatEnterpriseLinux7 }, testCaseID = { "RHEL6-21880", "RHEL7-51732" }, level = DefTypes.Level.COMPONENT, component = "subscription-manager", testtype = @TestType(testtype = DefTypes.TestTypes.FUNCTIONAL, subtype1 = DefTypes.Subtypes.RELIABILITY, subtype2 = DefTypes.Subtypes.EMPTY), posneg = PosNeg.POSITIVE, importance = DefTypes.Importance.HIGH, automation = DefTypes.Automation.AUTOMATED, tags = "Tier3")
@Test(description = "Using curl, unset the default service level for an org and then register using org credentials to verify consumer's service level is not set", groups = { "Tier3Tests" }, dependsOnMethods = { "testSetDefaultServiceLevelForOrgAndRegister" }, enabled = true)
public // @ImplementsNitrateTest(caseId=)
void testUnsetDefaultServiceLevelForOrgAndRegister() throws JSONException, Exception {
// update the defaultServiceLevel on the Org (setting to "" will nullify the attribute on the org; setting to JSONObject.NULL does not work)
JSONObject jsonOrg = CandlepinTasks.setAttributeForOrg(sm_clientUsername, sm_clientPassword, sm_serverUrl, orgForSetDefaultServiceLevelForOrgAndRegister_Test, "defaultServiceLevel", "");
Assert.assertEquals(jsonOrg.get("defaultServiceLevel"), JSONObject.NULL, "The defaultServiceLevel update to the org appears successful on the candlepin server.");
// register and assert the consumer's service level is not set
clienttasks.register(sm_clientUsername, sm_clientPassword, orgForSetDefaultServiceLevelForOrgAndRegister_Test, null, null, null, null, null, null, null, (String) null, null, null, null, true, null, null, null, null, null);
Assert.assertEquals(clienttasks.getCurrentServiceLevel(), "", "Immediately upon registering, the consumer's service level preference was set to the org's default (which was unset).");
}
use of com.github.redhatqe.polarize.metadata.TestDefinition in project rhsm-qe by RedHatQE.
the class ServiceLevelTests method testAutoSubscribeWithServiceLevelIsCaseInsensitive.
@// update=true, // uncomment to make TestDefinition changes update Polarion testcases through the polarize testcase importer
TestDefinition(projectID = { Project.RHEL6, Project.RedHatEnterpriseLinux7 }, testCaseID = { "RHEL6-19994", "RHEL7-51026" }, 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: autosubscribe while specifying an valid service level; assert the installed product status is independent of the specified SerViceLeVEL case.", groups = { "Tier1Tests", "blockedByBug-818319", "blockedByBug-859652" }, // dataProvider="getAllAvailableServiceLevelData", // 06/05/2014 takes too long; rarely reveals a bug
dataProvider = "getRandomSubsetOfAllAvailableServiceLevelData", enabled = true)
// 157226 //157225
@ImplementsNitrateTest(caseId = 157227)
public void testAutoSubscribeWithServiceLevelIsCaseInsensitive(Object bugzilla, String serviceLevel) throws JSONException, Exception {
// TEMPORARY WORKAROUND FOR BUG
if (sm_serverType.equals(CandlepinType.hosted)) {
String bugId = "818319";
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("This test is blocked by Bugzilla https://bugzilla.redhat.com/show_bug.cgi?id=" + bugId);
}
}
// system was already registered by dataProvider="getSubscribeWithAutoAndServiceLevelData"
if (clienttasks.getCurrentConsumerId() == 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);
}
// start fresh by returning all entitlements
clienttasks.unsubscribeFromAllOfTheCurrentlyConsumedProductSubscriptions();
// autosubscribe specifying a valid service level and get the installed product status
List<InstalledProduct> installedProductsAfterAutosubscribingWithServiceLevel = InstalledProduct.parse(clienttasks.subscribe(true, serviceLevel, (String) null, (String) null, (String) null, null, null, null, null, null, null, null, null).getStdout());
// unsubscribe from all entitlements
clienttasks.unsubscribeFromAllOfTheCurrentlyConsumedProductSubscriptions();
// autosubscribe specifying a mixed case service level and get the installed product status
String mixedCaseServiceLevel = randomizeCaseOfCharactersInString(serviceLevel);
List<InstalledProduct> installedProductsAfterAutosubscribingWithMixedCaseServiceLevel = InstalledProduct.parse(clienttasks.subscribe(true, mixedCaseServiceLevel, (String) null, (String) null, (String) null, null, null, null, null, null, null, null, null).getStdout());
// assert that the two lists are identical (independent of the serviceLevel case specified during autosubscribe)
Assert.assertEquals(installedProductsAfterAutosubscribingWithMixedCaseServiceLevel.size(), clienttasks.getCurrentProductIds().size(), "The subscribe output displayed the same number of installed product status's as the current number of installed product certs.");
Assert.assertTrue(installedProductsAfterAutosubscribingWithServiceLevel.containsAll(installedProductsAfterAutosubscribingWithMixedCaseServiceLevel) && installedProductsAfterAutosubscribingWithMixedCaseServiceLevel.containsAll(installedProductsAfterAutosubscribingWithServiceLevel), "Autosubscribe with serviceLevel '" + mixedCaseServiceLevel + "' yielded the same installed product status as autosubscribe with serviceLevel '" + serviceLevel + "'.");
// get the current exempt service levels
List<String> exemptServiceLevels = CandlepinTasks.getServiceLevelsForOrgKey(sm_clientUsername, sm_clientPassword, sm_serverUrl, clienttasks.getCurrentlyRegisteredOwnerKey(), true);
List<String> exemptServiceLevelsInUpperCase = new ArrayList<String>();
for (String exemptServiceLevel : exemptServiceLevels) exemptServiceLevelsInUpperCase.add(exemptServiceLevel.toUpperCase());
// assert that each of the consumed ProductSubscriptions match the specified service level
List<ProductSubscription> consumedProductSubscriptions = clienttasks.getCurrentlyConsumedProductSubscriptions();
if (consumedProductSubscriptions.isEmpty())
log.warning("No entitlements were granted after autosubscribing with service level '" + mixedCaseServiceLevel + "'.");
for (ProductSubscription productSubscription : consumedProductSubscriptions) {
// tolerate ProductSubscriptions with a null/"" serviceLevel. (result of candlepin Bug 1223560)
if (SubscriptionManagerTasks.isVersion(servertasks.statusVersion, ">=", /*TODO ">" is technically correct*/
"2.0.2-1")) {
// commit 9cefb6e23baefcc4ee2e14423f205edd37eecf22 // Bug 1223560 - Service levels on an activation key prevent custom products from attaching at registration if auto-attach enabled
if (productSubscription.serviceLevel == null || productSubscription.serviceLevel.isEmpty()) {
log.warning("After autosubscribe with service level '" + mixedCaseServiceLevel + "', this consumed ProductSubscription provides no service level '" + productSubscription.serviceLevel + "'. (New behavior modification from Bug 1223560)");
continue;
}
}
// tolerate ProductSubscriptions with exemptServiceLevels
if (/*sm_*/
exemptServiceLevelsInUpperCase.contains(productSubscription.serviceLevel.toUpperCase())) {
log.warning("After autosubscribe with service level '" + mixedCaseServiceLevel + "', this consumed ProductSubscription provides an exempt service level '" + productSubscription.serviceLevel + "'.");
continue;
}
Assert.assertTrue(productSubscription.serviceLevel.equalsIgnoreCase(mixedCaseServiceLevel), "After autosubscribe with service level '" + mixedCaseServiceLevel + "', this consumed ProductSubscription provides a service level '" + productSubscription.serviceLevel + "' that is a case insensitive match to '" + mixedCaseServiceLevel + "'.");
}
}
use of com.github.redhatqe.polarize.metadata.TestDefinition in project rhsm-qe by RedHatQE.
the class ServiceLevelTests method testRegisterWithServiceLevelIsCaseInsensitive.
@// update=true, // uncomment to make TestDefinition changes update Polarion testcases through the polarize testcase importer
TestDefinition(projectID = { Project.RHEL6, Project.RedHatEnterpriseLinux7 }, testCaseID = { "RHEL6-19995", "RHEL7-51028" }, 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: register with autosubscribe while specifying an valid random case SeRviCEleVel; assert the installed product status is independent of the specified service level case.", groups = { "Tier1Tests", "blockedByBug-859652", "blockedByBug-859652", "blockedByBug-919700" }, // dataProvider="getAllAvailableServiceLevelData", // 06/05/2014 takes too long; rarely reveals a bug
dataProvider = "getRandomSubsetOfAllAvailableServiceLevelData", enabled = true)
public // @ImplementsNitrateTest(caseId=)
void testRegisterWithServiceLevelIsCaseInsensitive(Object bugzilla, String serviceLevel) {
// TEMPORARY WORKAROUND FOR BUG
if (sm_serverType.equals(CandlepinType.hosted)) {
String bugId = "818319";
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("Hosted candlepin server '" + sm_serverHostname + "' does not yet support this test execution.");
}
}
// END OF WORKAROUND
// register with autosubscribe specifying a valid service level and get the installed product status
List<InstalledProduct> installedProductsAfterAutosubscribedRegisterWithServiceLevel = InstalledProduct.parse(clienttasks.register(sm_clientUsername, sm_clientPassword, sm_clientOrg, null, null, null, null, true, serviceLevel, null, (String) null, null, null, null, true, null, null, null, null, null).getStdout());
// register with autosubscribe specifying a mixed case service level and get the installed product status
String mixedCaseServiceLevel = randomizeCaseOfCharactersInString(serviceLevel);
List<InstalledProduct> installedProductsAfterAutosubscribedRegisterWithMixedCaseServiceLevel = InstalledProduct.parse(clienttasks.register(sm_clientUsername, sm_clientPassword, sm_clientOrg, null, null, null, null, true, mixedCaseServiceLevel, null, (String) null, null, null, null, true, null, null, null, null, null).getStdout());
// assert that the two lists are identical (independent of the serviceLevel case specified during registration)
Assert.assertEquals(installedProductsAfterAutosubscribedRegisterWithMixedCaseServiceLevel.size(), clienttasks.getCurrentProductIds().size(), "The registration output displayed the same number of installed product status's as the number of installed product certs.");
Assert.assertTrue(installedProductsAfterAutosubscribedRegisterWithServiceLevel.containsAll(installedProductsAfterAutosubscribedRegisterWithMixedCaseServiceLevel) && installedProductsAfterAutosubscribedRegisterWithMixedCaseServiceLevel.containsAll(installedProductsAfterAutosubscribedRegisterWithServiceLevel), "Autosubscribed registration with serviceLevel '" + mixedCaseServiceLevel + "' yielded the same installed product status as autosubscribed registration with serviceLevel '" + serviceLevel + "'.");
// assert that each of the consumed ProductSubscriptions match the specified service level
List<ProductSubscription> consumedProductSubscriptions = clienttasks.getCurrentlyConsumedProductSubscriptions();
if (consumedProductSubscriptions.isEmpty())
log.warning("No entitlements were granted after registering with autosubscribe and service level '" + mixedCaseServiceLevel + "'.");
for (ProductSubscription productSubscription : consumedProductSubscriptions) {
// tolerate ProductSubscriptions with a null/"" serviceLevel. (result of candlepin Bug 1223560)
if (SubscriptionManagerTasks.isVersion(servertasks.statusVersion, ">=", /*TODO ">" is technically correct*/
"2.0.2-1")) {
// commit 9cefb6e23baefcc4ee2e14423f205edd37eecf22 // Bug 1223560 - Service levels on an activation key prevent custom products from attaching at registration if auto-attach enabled
if (productSubscription.serviceLevel == null || productSubscription.serviceLevel.isEmpty()) {
log.warning("After autosubscribed registration with service level '" + mixedCaseServiceLevel + "', this consumed ProductSubscription provides no service level '" + productSubscription.serviceLevel + "'. (New behavior modification from Bug 1223560)");
continue;
}
}
// tolerate exemptServiceLevels
if (sm_exemptServiceLevelsInUpperCase.contains(productSubscription.serviceLevel.toUpperCase())) {
log.warning("After autosubscribed registration with service level '" + mixedCaseServiceLevel + "', this consumed ProductSubscription provides an exempt service level '" + productSubscription.serviceLevel + "'.");
continue;
}
Assert.assertTrue(productSubscription.serviceLevel.equalsIgnoreCase(mixedCaseServiceLevel), "After autosubscribed registration with service level '" + mixedCaseServiceLevel + "', this consumed ProductSubscription provides a service level '" + productSubscription.serviceLevel + "' that is a case insensitive match to '" + mixedCaseServiceLevel + "'.");
}
}
Aggregations