use of rhsm.data.ProductSubscription in project rhsm-qe by RedHatQE.
the class BugzillaTests method testUnsubscribeFromMultipleEntitlements.
/**
* @author skallesh
* @throws Exception
* @throws JSONException
*/
@// update=true, // uncomment to make TestDefinition changes update Polarion testcases through the polarize testcase importer
TestDefinition(projectID = { Project.RHEL6, Project.RedHatEnterpriseLinux7 }, testCaseID = { "RHEL6-21930", "RHEL7-51792" }, 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 = "Verify unsubscribe from multiple subscriptions", groups = { "Tier3Tests", "UnsubscribeFromMultipleEntitlementsTest", "blockedByBug-867766", "blockedByBug-906550" }, enabled = true)
@ImplementsNitrateTest(caseId = 50230)
public void testUnsubscribeFromMultipleEntitlements() throws JSONException, Exception {
int count = 0;
List<BigInteger> serialnums = new ArrayList<BigInteger>();
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.unsubscribe(true, (BigInteger) null, null, null, null, null, null);
for (SubscriptionPool pool : clienttasks.getCurrentlyAvailableSubscriptionPools()) {
if ((count <= 2)) {
if (CandlepinTasks.isPoolAModifier(sm_clientUsername, sm_clientPassword, pool.poolId, sm_serverUrl))
// skip modifier pools
continue;
count++;
clienttasks.subscribe(null, null, pool.poolId, null, null, null, null, null, null, null, null, null, null);
}
}
for (ProductSubscription consumed : clienttasks.getCurrentlyConsumedProductSubscriptions()) {
serialnums.add(consumed.serialNumber);
}
// serialnums.get(i);
BigInteger serialOne = serialnums.get(randomGenerator.nextInt(serialnums.size()));
serialnums.remove(serialOne);
// serialnums.get(j);
BigInteger serialTwo = serialnums.get(randomGenerator.nextInt(serialnums.size()));
String result = unsubscribeFromMultipleEntitlementsUsingSerialNumber(serialOne, serialTwo).getStdout();
String expected = "";
expected += "Serial numbers successfully removed at the server:" + "\n";
expected += " " + serialOne + "\n";
expected += " " + serialTwo + "\n";
expected += "2 local certificates have been deleted.";
if (SubscriptionManagerTasks.isVersion(servertasks.statusVersion, ">=", "2.0.16-1")) {
expected = "The entitlement server successfully removed these serial numbers:" + "\n";
expected += " " + serialOne + "\n";
expected += " " + serialTwo + "\n";
expected += "2 local certificates have been deleted.";
}
if (SubscriptionManagerTasks.isVersion(servertasks.statusVersion, ">=", "2.2.0-1")) {
expected = "2 local certificates have been deleted." + "\n";
expected += "The entitlement server successfully removed these serial numbers:" + "\n";
expected += " " + serialOne + "\n";
expected += " " + serialTwo;
}
Assert.assertEquals(result.trim(), expected);
}
use of rhsm.data.ProductSubscription in project rhsm-qe by RedHatQE.
the class BugzillaTests method testUnsubscribeFromInvalidMultipleEntitlements.
/**
* @author skallesh
* @throws Exception
* @throws JSONException
*/
@// update=true, // uncomment to make TestDefinition changes update Polarion testcases through the polarize testcase importer
TestDefinition(projectID = { Project.RHEL6, Project.RedHatEnterpriseLinux7 }, testCaseID = { "RHEL6-22312", "RHEL7-51791" }, 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 = "Verify unsubscribe from multiple invalid serial numbers", groups = { "Tier3Tests", "blockedByBug-1268491", "UnsubscribeFromInvalidMultipleEntitlements" }, enabled = true)
@ImplementsNitrateTest(caseId = 50230)
public void testUnsubscribeFromInvalidMultipleEntitlements() throws JSONException, Exception {
List<BigInteger> serialnums = new ArrayList<BigInteger>();
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.unsubscribe_(true, (BigInteger) null, null, null, null, null, null);
clienttasks.subscribeToTheCurrentlyAvailableSubscriptionPoolsCollectively();
if (clienttasks.getCurrentlyConsumedProductSubscriptions().isEmpty())
throw new SkipException("Sufficient pools are not available");
for (ProductSubscription consumed : clienttasks.getCurrentlyConsumedProductSubscriptions()) {
serialnums.add(consumed.serialNumber);
}
int i = randomGenerator.nextInt(serialnums.size());
int j = randomGenerator.nextInt(serialnums.size());
/*
* irrelevant for this test case if (i == j) { j =
* randomGenerator.nextInt(serialnums.size()); }
*/
BigInteger serialOne = serialnums.get(i);
BigInteger serialTwo = serialnums.get(j);
String result = unsubscribeFromMultipleEntitlementsUsingSerialNumber(serialOne.multiply(serialTwo), serialTwo.multiply(serialOne)).getStdout();
String expected = "";
expected += "Serial numbers unsuccessfully removed at the server:" + "\n";
expected += " " + serialOne.multiply(serialTwo) + " is not a valid value for serial" + "\n";
expected += " " + serialTwo.multiply(serialOne) + " is not a valid value for serial";
if (SubscriptionManagerTasks.isVersion(servertasks.statusVersion, ">=", "2.0.10-1")) {
expected = "Serial numbers unsuccessfully removed at the server:" + "\n";
expected += " " + serialOne.multiply(serialTwo);
}
if (SubscriptionManagerTasks.isVersion(servertasks.statusVersion, ">=", "2.0.16-1")) {
expected = "The entitlement server failed to remove these serial numbers:" + "\n";
expected += " " + serialOne.multiply(serialTwo);
}
Assert.assertEquals(result.trim(), expected);
}
use of rhsm.data.ProductSubscription in project rhsm-qe by RedHatQE.
the class BugzillaTests method testHealingForFutureSubscription.
/**
* @author skallesh
* @throws Exception
* @throws JSONException
*/
@// update=true, // uncomment to make TestDefinition changes update Polarion testcases through the polarize testcase importer
TestDefinition(projectID = { Project.RHEL6, Project.RedHatEnterpriseLinux7 }, testCaseID = { "RHEL6-21954", "RHEL7-51816" }, 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 = "verify healing of installed products without taking future subscriptions into consideration", groups = { "Tier3Tests", "VerifyHealingForFutureSubscription", "blockedByBug-907638", "blockedByBug-1440180", "blockedByBug-1555582" }, enabled = true)
public void testHealingForFutureSubscription() throws JSONException, Exception {
String productId = 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.run_rhsmcertd_worker(true);
String consumerId = clienttasks.getCurrentConsumerId();
ownerKey = CandlepinTasks.getOwnerKeyOfConsumerId(sm_serverAdminUsername, sm_serverAdminPassword, sm_serverUrl, consumerId);
clienttasks.unsubscribeFromTheCurrentlyConsumedSerialsCollectively();
// disabling autoheal
clienttasks.autoheal(null, null, true, null, null, null, null);
String futurePool = createTestPool(60 * 24 * 365, 60 * 24 * (365 * 2), true);
clienttasks.subscribe(null, null, futurePool, null, null, null, null, null, null, null, null, null, null);
ProductSubscription futureConsumedProductSubscription = ProductSubscription.findFirstInstanceWithMatchingFieldFromList("poolId", futurePool, clienttasks.getCurrentlyConsumedProductSubscriptions());
String expectedFutureConsumedProductSubscriptionStatusDetails = "Subscription has not begun";
Assert.assertTrue(futureConsumedProductSubscription.statusDetails.contains(expectedFutureConsumedProductSubscriptionStatusDetails), "The status details of the future consumed subscription states '" + expectedFutureConsumedProductSubscriptionStatusDetails + "'.");
List<String> providedProductIdsOfFutureConsumedProductSubscription = CandlepinTasks.getPoolProvidedProductIds(sm_clientUsername, sm_clientPassword, sm_serverUrl, futurePool);
List<InstalledProduct> installedProducts = clienttasks.getCurrentlyInstalledProducts();
for (String providedProductId : providedProductIdsOfFutureConsumedProductSubscription) {
InstalledProduct installedProduct = InstalledProduct.findFirstInstanceWithMatchingFieldFromList("productId", providedProductId, installedProducts);
if (installedProduct != null) {
Assert.assertEquals(installedProduct.status, "Future Subscription", "Status of an installed product provided by a future consumed subscription.");
productId = installedProduct.productId;
}
}
if (productId == null)
throw new SkipException("None of the provided products from consumed future subscription '" + futureConsumedProductSubscription + "' are installed for testing.");
// enabling
clienttasks.autoheal(null, true, null, null, null, null, null);
// autoheal
clienttasks.run_rhsmcertd_worker(true);
boolean assertedFutureSubscriptionIsNowSubscribed = false;
InstalledProduct installedProductAfterAutoHealing = InstalledProduct.findFirstInstanceWithMatchingFieldFromList("productId", productId, clienttasks.getCurrentlyInstalledProducts());
List<String> installedProductArches = new ArrayList<String>(// Note:
Arrays.asList(installedProductAfterAutoHealing.arch.trim().split(" *, *")));
// values
if (installedProductArches.contains("x86")) {
installedProductArches.addAll(Arrays.asList("i386", "i486", "i586", "i686"));
}
// microprocessors, expand the x86 alias
if (installedProductArches.contains(clienttasks.arch) || installedProductArches.contains("ALL")) {
Assert.assertEquals(installedProductAfterAutoHealing.status.trim(), "Subscribed", "Previously installed product '" + installedProductAfterAutoHealing.productName + "' covered by a Future Subscription should now be covered by a current subscription after auto-healing.");
assertedFutureSubscriptionIsNowSubscribed = true;
} else {
Assert.assertEquals(installedProductAfterAutoHealing.status.trim(), "Future Subscription", "Mismatching arch installed product '" + installedProductAfterAutoHealing.productName + "' (arch='" + installedProductAfterAutoHealing.arch + "') covered by a Future Subscription should remain unchanged after auto-healing.");
}
Assert.assertTrue(assertedFutureSubscriptionIsNowSubscribed, "Verified at least one previously installed product covered by a Future Subscription is now covered by a current subscription after auto-healing.");
}
use of rhsm.data.ProductSubscription in project rhsm-qe by RedHatQE.
the class BugzillaTests method testAutohealFailForSLA.
/**
* @author skallesh
* @throws JSONException
* @throws Exception
*/
@// update=true, // uncomment to make TestDefinition changes update Polarion testcases through the polarize testcase importer
TestDefinition(projectID = { Project.RHEL6, Project.RedHatEnterpriseLinux7 }, testCaseID = { "RHEL6-21935", "RHEL7-51797" }, 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 = "Auto-heal for a system with preference Premium for a product with SLA Standard should fail", groups = { "Tier3Tests", "AutoHealFailForSLA" }, enabled = true)
public void testAutohealFailForSLA() throws JSONException, Exception {
List<ProductCert> productCerts = clienttasks.getCurrentProductCerts();
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);
/*List<String> availableServiceLevelData = clienttasks.getCurrentlyAvailableServiceLevels();
String availableService = availableServiceLevelData
.get(randomGenerator.nextInt(availableServiceLevelData.size()));*/
clienttasks.service_level(null, null, "Standard", null, null, null, null, null, null, null, null, null, null);
clienttasks.unsubscribe(true, (BigInteger) null, null, null, null, null, null);
clienttasks.subscribe(true, null, (String) null, null, null, null, null, null, null, null, null, null, null);
ProductCert productCert = ProductCert.findFirstInstanceWithMatchingFieldFromList("productId", "32060", productCerts);
configureTmpProductCertDirWithInstalledProductCerts(Arrays.asList(productCert));
clienttasks.unsubscribe(true, (BigInteger) null, null, null, null, null, null);
clienttasks.service_level(null, null, "Premium", null, null, null, null, null, null, null, null, null, null);
clienttasks.run_rhsmcertd_worker(true);
List<ProductSubscription> consumed = clienttasks.getCurrentlyConsumedProductSubscriptions();
Assert.assertTrue((consumed.isEmpty()), "autoheal has failed");
}
use of rhsm.data.ProductSubscription in project rhsm-qe by RedHatQE.
the class BugzillaTests method testSubscriptionOfBestProductWithUnattendedRegistration.
/**
* @author skallesh
* @throws Exception
* @throws JSONException
*/
@SuppressWarnings("deprecation")
@Test(description = "verify that system should not be compliant for an expired subscription", groups = { "Tier3Tests", "VerifySubscriptionOf" }, enabled = false)
public // @ImplementsNitrateTest(caseId=71208)
void testSubscriptionOfBestProductWithUnattendedRegistration() throws JSONException, Exception {
Map<String, String> attributes = new HashMap<String, String>();
List<String[]> listOfSectionNameValues = new ArrayList<String[]>();
listOfSectionNameValues.add(new String[] { "rhsmcertd", "autoAttachInterval".toLowerCase(), "1440" });
clienttasks.config(null, null, true, listOfSectionNameValues);
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);
CandlepinTasks.deleteSubscriptionsAndRefreshPoolsUsingRESTfulAPI(sm_serverAdminUsername, sm_serverAdminPassword, sm_serverUrl, sm_clientOrg, "multi-stackable");
CandlepinTasks.refreshPoolsUsingRESTfulAPI(sm_serverAdminUsername, sm_serverAdminPassword, sm_serverUrl, ownerKey);
String resourcePath = "/products/multi-stackable";
if (SubscriptionManagerTasks.isVersion(servertasks.statusVersion, ">=", "2.0.0"))
resourcePath = "/owners/" + sm_clientOrg + resourcePath;
CandlepinTasks.deleteResourceUsingRESTfulAPI(sm_serverAdminUsername, sm_serverAdminPassword, sm_serverUrl, resourcePath);
String consumerId = clienttasks.getCurrentConsumerId();
ownerKey = CandlepinTasks.getOwnerKeyOfConsumerId(sm_serverAdminUsername, sm_serverAdminPassword, sm_serverUrl, consumerId);
Calendar cal = new GregorianCalendar();
Date todaysDate = cal.getTime();
cal.set(Calendar.HOUR_OF_DAY, 0);
cal.set(Calendar.MINUTE, 0);
// avoid times in the middle of the day
cal.set(Calendar.SECOND, 0);
cal.add(Calendar.YEAR, 1);
cal.add(Calendar.DATE, 10);
// one year and ten days from tomorrow
Date futureDate = cal.getTime();
attributes.put("sockets", "0");
attributes.put("arch", "ALL");
attributes.put("type", "MKT");
attributes.put("multi-entitlement", "yes");
attributes.put("stacking_id", "726409");
List<String> providedProducts = new ArrayList<String>();
providedProducts.add("100000000000002");
CandlepinTasks.createProductUsingRESTfulAPI(sm_serverAdminUsername, sm_serverAdminPassword, sm_serverUrl, sm_clientOrg, "Multi-Stackable for 100000000000002", "multi-stackable", 1, attributes, null);
String requestBody = CandlepinTasks.createSubscriptionRequestBody(sm_serverUrl, 20, todaysDate, futureDate, "multi-stackable", Integer.valueOf(getRandInt()), Integer.valueOf(getRandInt()), providedProducts, null).toString();
CandlepinTasks.postResourceUsingRESTfulAPI(sm_serverAdminUsername, sm_serverAdminPassword, sm_serverUrl, "/owners/" + ownerKey + "/subscriptions", requestBody);
JSONObject jobDetail = CandlepinTasks.refreshPoolsUsingRESTfulAPI(sm_serverAdminUsername, sm_serverAdminPassword, sm_serverUrl, ownerKey);
jobDetail = CandlepinTasks.waitForJobDetailStateUsingRESTfulAPI(sm_serverAdminUsername, sm_serverAdminPassword, sm_serverUrl, jobDetail, "FINISHED", 5 * 1000, 1);
clienttasks.unsubscribeFromAllOfTheCurrentlyConsumedProductSubscriptions();
sleep(3 * 60 * 1000);
int sockets = 16;
Map<String, String> factsMap = new HashMap<String, String>();
factsMap.put("lscpu.cpu_socket(s)", String.valueOf(sockets));
factsMap.put("cpu.cpu_socket(s)", String.valueOf(sockets));
clienttasks.createFactsFileWithOverridingValues(factsMap);
clienttasks.register(sm_clientUsername, sm_clientPassword, sm_clientOrg, null, null, null, null, true, null, null, (String) null, null, null, null, true, null, null, null, null, null);
InstalledProduct installedProduct = InstalledProduct.findFirstInstanceWithMatchingFieldFromList("productId", "100000000000002", clienttasks.getCurrentlyInstalledProducts());
if (installedProduct.productId.equals("100000000000002"))
Assert.assertEquals(installedProduct.status, "Subscribed");
for (ProductSubscription consumed : clienttasks.getCurrentlyConsumedProductSubscriptions()) {
Assert.assertEquals(consumed.productName, "Multi-Stackable for 100000000000002");
}
}
Aggregations