use of com.redhat.qe.auto.tcms.ImplementsNitrateTest in project rhsm-qe by RedHatQE.
the class ServiceLevelTests method testServiceLevelShowAfterRegisteringWithoutServiceLevel_DEPRECATED.
@Test(description = "subscription-manager: service-level --show (after registering without a service level)", groups = { "Tier3Tests" }, // assertions in this test are already a subset of ServiceLevelShowAvailable_Test(...)
enabled = false)
@Deprecated
@ImplementsNitrateTest(caseId = 157213)
public void testServiceLevelShowAfterRegisteringWithoutServiceLevel_DEPRECATED() throws JSONException, Exception {
SSHCommandResult result;
// register with no service-level
String consumerId = clienttasks.getCurrentConsumerId(clienttasks.register(sm_clientUsername, sm_clientPassword, sm_clientOrg, null, null, null, null, null, null, null, (List<String>) null, null, null, null, true, null, null, null, null, null));
// get the current consumer object and assert that the serviceLevel persisted
JSONObject jsonConsumer = new JSONObject(CandlepinTasks.getResourceUsingRESTfulAPI(sm_clientUsername, sm_clientPassword, sm_serverUrl, "/consumers/" + consumerId));
Assert.assertEquals(jsonConsumer.get("serviceLevel"), JSONObject.NULL, "The call to register without a servicelevel leaves the current consumer object serviceLevel attribute value null.");
result = clienttasks.service_level(true, false, null, null, null, null, null, null, null, null, null, null, null);
Assert.assertEquals(result.getStdout().trim(), "Current service level:", "When the system has been registered without a service level, the current service level should be null.");
}
use of com.redhat.qe.auto.tcms.ImplementsNitrateTest 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.redhat.qe.auto.tcms.ImplementsNitrateTest 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.redhat.qe.auto.tcms.ImplementsNitrateTest 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 + "'.");
}
}
use of com.redhat.qe.auto.tcms.ImplementsNitrateTest in project rhsm-qe by RedHatQE.
the class ServiceLevelTests method testServiceLevelSetWithUnavailableServiceLevel.
@// update=true, // uncomment to make TestDefinition changes update Polarion testcases through the polarize testcase importer
TestDefinition(projectID = { Project.RHEL6, Project.RedHatEnterpriseLinux7 }, testCaseID = { "RHEL6-21873", "RHEL7-51728" }, 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: service-level --set (with unavailable serviceLevel)", groups = { "Tier3Tests", "blockedByBug-864508" }, enabled = true)
public // @ImplementsNitrateTest(caseId=)
void testServiceLevelSetWithUnavailableServiceLevel() throws JSONException, Exception {
// test while registered
if (clienttasks.getCurrentConsumerId() == null)
clienttasks.register(sm_clientUsername, sm_clientPassword, sm_clientOrg);
// current org (in case sm_clientOrg is null)
String org = clienttasks.getCurrentlyRegisteredOwnerKey();
String unavailableSericeLevel = "FOO";
SSHCommandResult result = clienttasks.service_level_(null, null, unavailableSericeLevel, null, null, null, null, null, null, null, null, null, null);
// valid before bug fix 864508
String expectedStderr = String.format("Service level %s is not available to consumers of organization %s.", unavailableSericeLevel, org);
expectedStderr = String.format("Service level '%s' is not available to consumers of organization %s.", unavailableSericeLevel, org);
if (!clienttasks.workaroundForBug876764(sm_serverType))
expectedStderr = String.format("Service level '%s' is not available to units of organization %s.", unavailableSericeLevel, org);
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);
Assert.assertEquals(result.getExitCode(), expectedExitCode, "ExitCode from service-level --set with unavailable serviceLevel");
Assert.assertEquals(result.getStderr().trim(), expectedStderr, "Stderr from service-level --set with unavailable serviceLevel");
Assert.assertEquals(result.getStdout().trim(), "", "Stdout from service-level --set with unavailable serviceLevel");
}
Aggregations