use of rhsm.data.InstalledProduct in project rhsm-qe by RedHatQE.
the class BugzillaTests method testDistinctStackingEntires.
/**
* @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-21944", "RHEL7-51806" }, 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 if stacking entitlements reports as distinct entries in cli list --installed", groups = { "Tier3Tests", "VerifyDistinctStackingEntires", "blockedByBug-733327" }, enabled = true)
public void testDistinctStackingEntires() throws Exception {
String poolId = null;
String productIds = 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);
int sockets = 5;
int core = 2;
int ram = 10;
Map<String, String> factsMap = new HashMap<String, String>();
factsMap.put("cpu.cpu_socket(s)", String.valueOf(sockets));
factsMap.put("cpu.core(s)_per_socket", String.valueOf(core));
factsMap.put("memory.memtotal", String.valueOf(GBToKBConverter(ram)));
factsMap.put("virt.is_guest", String.valueOf(Boolean.FALSE));
clienttasks.createFactsFileWithOverridingValues(factsMap);
clienttasks.facts(null, true, null, null, null, null);
int quantity = 0;
String providedProductId = null;
for (SubscriptionPool pool : clienttasks.getCurrentlyAvailableSubscriptionPools()) {
if (pool.subscriptionType.equals("Stackable")) {
quantity = pool.suggested - 1;
if (!(pool.suggested == 1)) {
clienttasks.subscribe(null, null, pool.poolId, null, null, Integer.toString(quantity), null, null, null, null, null, null, null);
productIds = pool.productId;
providedProductId = pool.provides.get(randomGenerator.nextInt(pool.provides.size()));
if (!(providedProductId.isEmpty())) {
break;
}
}
}
}
InstalledProduct BeforeAttaching = InstalledProduct.findFirstInstanceWithMatchingFieldFromList("productName", providedProductId, clienttasks.getCurrentlyInstalledProducts());
Assert.assertEquals(BeforeAttaching.status, "Partially Subscribed", "Verified that installed product is partially subscribed");
List<SubscriptionPool> AvailableStackableSubscription = SubscriptionPool.findAllInstancesWithMatchingFieldFromList("productId", productIds, clienttasks.getAvailableSubscriptionsMatchingInstalledProducts());
System.out.println(AvailableStackableSubscription.size() + "size .............");
for (SubscriptionPool pools : AvailableStackableSubscription) {
clienttasks.subscribeToSubscriptionPool(pools);
}
InstalledProduct AfterAttaching = InstalledProduct.findFirstInstanceWithMatchingFieldFromList("productName", providedProductId, clienttasks.getCurrentlyInstalledProducts());
Assert.assertEquals(AfterAttaching.status, "Subscribed", "Verified that installed product" + AfterAttaching.productName + "is fully subscribed after attaching one more quantity of multi-entitleable stackable subscription");
}
use of rhsm.data.InstalledProduct 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.InstalledProduct in project rhsm-qe by RedHatQE.
the class BugzillaTests method testFutureSubscription.
/**
* @author skallesh
* @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-21953", "RHEL7-51815" }, 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 if future entitlements are disregarded by autosubscribe when determining what should be subscribed to satisfy compliance today", groups = { "Tier3Tests", "VerifyFutureSubscription_Test", "blockedByBug-746035", "blockedByBug-1440180", "blockedByBug-1555582" }, enabled = true)
public void testFutureSubscription() throws Exception {
clienttasks.register(sm_clientUsername, sm_clientPassword, sm_clientOrg, null, null, null, null, null, null, null, (String) null, null, null, null, true, false, null, null, null, null);
String consumerId = clienttasks.getCurrentConsumerId();
ownerKey = CandlepinTasks.getOwnerKeyOfConsumerId(sm_serverAdminUsername, sm_serverAdminPassword, sm_serverUrl, consumerId);
String futurePool = createTestPool(60 * 24 * 365, 60 * 24 * (365 * 2), true);
boolean assertedFutureSubscriptionIsNowSubscribed = false;
clienttasks.subscribe(null, null, futurePool, null, null, null, null, null, null, null, null, null, null);
InstalledProduct installedProductBeforeAutoAttach = InstalledProduct.findFirstInstanceWithCaseInsensitiveMatchingFieldFromList("status", "Future Subscription", clienttasks.getCurrentlyInstalledProducts());
Assert.assertNotNull(installedProductBeforeAutoAttach, "Found installed product that is covered by a inactive subscription");
clienttasks.subscribe(true, null, (String) null, null, null, null, null, null, null, null, null, null, null);
InstalledProduct installedProductAfterAutoAttach = InstalledProduct.findFirstInstanceWithCaseInsensitiveMatchingFieldFromList("productId", installedProductBeforeAutoAttach.productId, clienttasks.getCurrentlyInstalledProducts());
List<String> installedProductArches = new ArrayList<String>(Arrays.asList(installedProductAfterAutoAttach.arch.trim().split(" *, *")));
// Note: the arch can be a comma separated list of 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(installedProductAfterAutoAttach.status.trim(), "Subscribed", "Previously installed product '" + installedProductAfterAutoAttach.productName + "' covered by a Future Subscription should now be covered by a current subscription after auto-subscribing.");
assertedFutureSubscriptionIsNowSubscribed = true;
} else {
Assert.assertEquals(installedProductAfterAutoAttach.status.trim(), "Future Subscription", "Mismatching arch installed product '" + installedProductAfterAutoAttach.productName + "' (arch='" + installedProductAfterAutoAttach.arch + "') covered by a Future Subscription should remain unchanged after auto-subscribing.");
}
Assert.assertTrue(assertedFutureSubscriptionIsNowSubscribed, "Verified at least one previously installed product covered by a Future Subscription is now covered by a current subscription after auto-subscribing.");
}
use of rhsm.data.InstalledProduct 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");
}
}
use of rhsm.data.InstalledProduct in project rhsm-qe by RedHatQE.
the class BugzillaTests method testAutohealForExpiredSubscription.
/**
* @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-26776", "RHEL7-63526" }, 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 Expired subscription", groups = { "Tier3Tests", "AutohealForExpired", "blockedByBug-746088", "blockedByBug-907638", "blockedByBug-907400", "blockedByBug-1555582" }, enabled = true)
public void testAutohealForExpiredSubscription() throws JSONException, Exception {
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);
String consumerId = clienttasks.getCurrentConsumerId();
ownerKey = CandlepinTasks.getOwnerKeyOfConsumerId(sm_serverAdminUsername, sm_serverAdminPassword, sm_serverUrl, consumerId);
int endingMinutesFromNow = 1;
String expiringPoolId = createTestPool(-60 * 24, endingMinutesFromNow, false);
Calendar c1 = new GregorianCalendar();
clienttasks.subscribe(null, null, expiringPoolId, null, null, null, null, null, null, null, null, null, null);
Calendar c2 = new GregorianCalendar();
// wait for the pool to expire
// sleep(endingMinutesFromNow*60*1000);
// trying to reduce the wait time for the expiration by subtracting off
// some expensive test time
sleep(1 * 60 * 1000 - (c2.getTimeInMillis() - c1.getTimeInMillis()));
InstalledProduct productCertBeforeHealing = ProductCert.findFirstInstanceWithMatchingFieldFromList("status", "Expired", clienttasks.getCurrentlyInstalledProducts());
Assert.assertEquals(productCertBeforeHealing.status, "Expired");
clienttasks.run_rhsmcertd_worker(true);
InstalledProduct productCertAfterHealing = ProductCert.findFirstInstanceWithMatchingFieldFromList("productId", productCertBeforeHealing.productId, clienttasks.getCurrentlyInstalledProducts());
Assert.assertEquals(productCertAfterHealing.status, "Subscribed");
}
Aggregations