use of rhsm.data.InstalledProduct in project rhsm-qe by RedHatQE.
the class HighAvailabilityTests method testProductDatabaseIsInSyncWithInstalledProducts.
@// update=true // uncomment to make TestDefinition changes update Polarion testcases through the polarize testcase importer
TestDefinition(projectID = { Project.RHEL6, Project.RedHatEnterpriseLinux7 }, testCaseID = { "RHEL6-20071", "RHEL7-55180" }, 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 = "verify product database and installed products are in sync", groups = { "Tier1Tests" }, priority = 12, dependsOnMethods = {}, enabled = true)
public // @ImplementsNitrateTest(caseId=)
void testProductDatabaseIsInSyncWithInstalledProducts() throws JSONException {
// get the installed products and product database map
List<InstalledProduct> installedProducts = clienttasks.getCurrentlyInstalledProducts();
Map<String, List<String>> productIdRepoMap = clienttasks.getProductIdToReposMap();
// List<ProductCert> installedProductCerts = clienttasks.getCurrentProductCerts(); // VALID BEFORE Bugs 1080007 1080012 - [RFE] Include default product certificate in redhat-release
List<ProductCert> installedProductCerts = clienttasks.getProductCerts(clienttasks.productCertDir);
// assert that product database and installed products are in sync
int installedProductCertCount = 0;
for (ProductCert installedProductCert : installedProductCerts) {
// skip productCerts from TESTDATA
if (installedProductCert.file.getName().endsWith("_.pem")) {
log.info("Skipping assertion that product cert '" + installedProductCert.file + "' (manually installed from generated candlepin TESTDATA) is accounted for in the product database '" + clienttasks.productIdJsonFile + "'.");
continue;
}
// TEMPORARY WORKAROUND
if (installedProductCert.productId.equals("135") || /* Red Hat Enterprise Linux 6 Server HTB */
installedProductCert.productId.equals("155")) /* Red Hat Enterprise Linux 6 Workstation HTB */
{
List<ProductCert> installedProductDefaultCerts = clienttasks.getProductCerts(clienttasks.productCertDefaultDir);
if (ProductCert.findFirstInstanceWithMatchingFieldFromList("productId", installedProductCert.productId, installedProductDefaultCerts) != null) {
boolean invokeWorkaroundWhileBugIsOpen = true;
// Bug 1318584 - /etc/pki/product-default/*.pem missing in certain variants
String bugId = "1318584";
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) {
// only skip when the installed HTB product came from the /etc/pki/product-default location due to bug 1318584
log.warning("Skipping assertion that Database '" + clienttasks.productIdJsonFile + "' maps installed product id '" + installedProductCert.productId + "' while bug '" + bugId + "' is open.");
continue;
}
}
}
// END OF WORKAROUND
installedProductCertCount++;
Assert.assertTrue(productIdRepoMap.containsKey(installedProductCert.productId), "Database '" + clienttasks.productIdJsonFile + "' contains installed product id: " + installedProductCert.productId);
log.info("Database '" + clienttasks.productIdJsonFile + "' maps installed product id '" + installedProductCert.productId + "' to repo '" + productIdRepoMap.get(installedProductCert.productId) + "'.");
}
for (String productId : productIdRepoMap.keySet()) {
Assert.assertNotNull(InstalledProduct.findFirstInstanceWithMatchingFieldFromList("productId", productId, installedProducts), "Database '" + clienttasks.productIdJsonFile + "' product id '" + productId + "' is among the installed products.");
}
Assert.assertEquals(productIdRepoMap.keySet().size(), installedProductCertCount, "The product id database size matches the number of installed products (excluding TESTDATA products).");
}
use of rhsm.data.InstalledProduct in project rhsm-qe by RedHatQE.
the class HighAvailabilityTests method testYumRemoveFirstHighAvailabilityPackageAndAssertInstalledProductCerts.
@// update=true // uncomment to make TestDefinition changes update Polarion testcases through the polarize testcase importer
TestDefinition(projectID = { Project.RHEL6, Project.RedHatEnterpriseLinux7 }, testCaseID = { "RHEL6-20079", "RHEL7-55188" }, 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 = "yum remove first High Availability package cman and assert installed products", groups = { "Tier1Tests", "blockedByBug-859197" }, priority = 70, dependsOnMethods = { "testYumInstallFirstHighAvailabilityPackageAndAssertInstalledProductCerts" }, // dependsOnMethods={"testYumRemoveSecondHighAvailabilityPackageAndAssertInstalledProductCerts"},
enabled = true)
public // @ImplementsNitrateTest(caseId=)
void testYumRemoveFirstHighAvailabilityPackageAndAssertInstalledProductCerts() {
ProductCert haProductCert = ProductCert.findFirstInstanceWithMatchingFieldFromList("productId", haProductId, clienttasks.getCurrentProductCerts());
// assemble all of the provided tags from the haProductCert
List<String> haProductCertProvidedTags = Arrays.asList(haProductCert.productNamespace.providedTags.split("\\s*,\\s*"));
boolean haProductCertProvidesATagStartingWithRhel = false;
for (String tag : haProductCertProvidedTags) {
if (tag.toLowerCase().startsWith("rhel")) {
log.info("Found HA ProductCert tag '" + tag + "' that begins with rhel*.");
haProductCertProvidesATagStartingWithRhel = true;
}
}
// remove the final package installed from the ha repo
clienttasks.yumRemovePackage(haPackage1);
// get the currently installed products
List<InstalledProduct> installedProducts = clienttasks.getCurrentlyInstalledProducts();
// verify High Availability product id is uninstalled
// but it should only be uninstalled if it does not provide an rhel* tags as stated in https://bugzilla.redhat.com/show_bug.cgi?id=859197#c15
InstalledProduct haInstalledProduct = InstalledProduct.findFirstInstanceWithMatchingFieldFromList("productId", haProductId, installedProducts);
/* valid before https://bugzilla.redhat.com/show_bug.cgi?id=859197#c15
if (Integer.valueOf(clienttasks.redhatReleaseX) > 5) Assert.assertNull(haInstalledProduct, "The High Availability product id '"+haProductId+"' should no longer be installed after successful removal of High Availability package '"+haPackage1+"' (because no High Availability packages should be installed).");
else Assert.assertNotNull(haInstalledProduct, "The High Availability product id '"+haProductId+"' should no longer be installed after successful removal of High Availability package '"+haPackage1+"' (because no High Availability packages should be installed); HOWEVER on RHEL5 the productId plugin does NOT remove product certs. This is a known issue.");
*/
if (haProductCertProvidesATagStartingWithRhel) {
Assert.assertNotNull(haInstalledProduct, "The High Availability product id '" + haProductId + "' should remain installed despite successful removal of the final High Availability package '" + haPackage1 + "' (because the High Availability product cert provides a tag that starts with rhel* even when the last High Availability package installed was removed).");
} else {
Assert.assertNull(haInstalledProduct, "The High Availability product id '" + haProductId + "' should no longer be installed after successful removal of High Availability package '" + haPackage1 + "' (because no High Availability packages should be installed AND because none of its provided tags start with rhel*).");
}
// verify RHEL product server id 69 remains installed
InstalledProduct serverInstalledProduct = InstalledProduct.findFirstInstanceWithMatchingFieldFromList("productId", serverProductId, installedProducts);
Assert.assertNotNull(serverInstalledProduct, "The RHEL Server product id '" + serverProductId + "' should remain installed after successful removal of High Availability package '" + haPackage1 + "'.");
}
use of rhsm.data.InstalledProduct in project rhsm-qe by RedHatQE.
the class HighAvailabilityTests method testYumRemoveSecondHighAvailabilityPackageAndAssertInstalledProductCerts.
@// update=true // uncomment to make TestDefinition changes update Polarion testcases through the polarize testcase importer
TestDefinition(projectID = { Project.RHEL6, Project.RedHatEnterpriseLinux7 }, testCaseID = { "RHEL6-20078", "RHEL7-55187" }, 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 = "yum remove second High Availability package cman and assert installed products", groups = { "Tier1Tests" }, priority = 60, dependsOnMethods = { "testYumInstallSecondHighAvailabilityPackageAndAssertInstalledProductCerts" }, enabled = true)
public // @ImplementsNitrateTest(caseId=)
void testYumRemoveSecondHighAvailabilityPackageAndAssertInstalledProductCerts() {
clienttasks.yumRemovePackage(haPackage2);
// get the currently installed products
List<InstalledProduct> installedProducts = clienttasks.getCurrentlyInstalledProducts();
// verify High Availability product id remains installed and Subscribed
InstalledProduct haInstalledProduct = InstalledProduct.findFirstInstanceWithMatchingFieldFromList("productId", haProductId, installedProducts);
Assert.assertNotNull(haInstalledProduct, "The High Availability product id '" + haProductId + "' should remain installed after successful removal of High Availability package '" + haPackage2 + "' (because package " + haPackage1 + " is still installed).");
Assert.assertEquals(haInstalledProduct.status, "Subscribed", "The status of the installed High Availability product cert.");
// verify RHEL product server id 69 is installed
InstalledProduct serverInstalledProduct = InstalledProduct.findFirstInstanceWithMatchingFieldFromList("productId", serverProductId, installedProducts);
Assert.assertNotNull(serverInstalledProduct, "The RHEL Server product id '" + serverProductId + "' should remain installed after successful removal of High Availability package '" + haPackage2 + "'.");
}
use of rhsm.data.InstalledProduct in project rhsm-qe by RedHatQE.
the class HighAvailabilityTests method testHighAvailabilityIsNotInstalled.
// Test methods ***********************************************************************
@// update=true // uncomment to make TestDefinition changes update Polarion testcases through the polarize testcase importer
TestDefinition(projectID = { Project.RHEL6, Project.RedHatEnterpriseLinux7 }, testCaseID = { "RHEL6-20070", "RHEL7-55179" }, 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 = "make sure there are no High Availability packages installed", groups = { "Tier1Tests", "blockedByBug-904193" }, priority = 10, dependsOnMethods = {}, enabled = true)
public // @ImplementsNitrateTest(caseId=)
void testHighAvailabilityIsNotInstalled() {
// yum clean all to ensure the yum database is reset
clienttasks.yumClean("all");
// verify no High Availability packages are installed
boolean haPackagesInstalled = false;
for (String pkg : /*sm_haPackages*/
getHighAvailabilityPackages(clienttasks.redhatReleaseXY, clienttasks.arch)) {
if (clienttasks.isPackageInstalled(pkg)) {
haPackagesInstalled = true;
log.warning("Did not expect High Availability package '" + pkg + "' to be instaled.");
}
}
Assert.assertTrue(!haPackagesInstalled, "There should NOT be any packages from HighAvialability installed on a fresh install of RHEL '" + clienttasks.releasever + "'.");
// get the currently installed products
List<InstalledProduct> installedProducts = clienttasks.getCurrentlyInstalledProducts();
// verify High Availability product id is not installed
InstalledProduct haInstalledProduct = InstalledProduct.findFirstInstanceWithMatchingFieldFromList("productId", haProductId, installedProducts);
Assert.assertNull(haInstalledProduct, "The High Availability product id '" + haProductId + "' should NOT be installed.");
// verify RHEL product server id 69 is installed
InstalledProduct serverInstalledProduct = InstalledProduct.findFirstInstanceWithMatchingFieldFromList("productId", serverProductId, installedProducts);
Assert.assertNotNull(serverInstalledProduct, "The RHEL Server product id '" + serverProductId + "' should be installed.");
}
use of rhsm.data.InstalledProduct in project rhsm-qe by RedHatQE.
the class InstanceBasedTests method testAutoSubscribingInstanceBasedSubscriptions.
/**
* @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-36687", "RHEL7-51532" }, 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 = "verify auto subscribing of Instance-Based subscriptions", groups = { "Tier2Tests", "AutoSubscribingInstanceBasedSubscription" }, enabled = true)
public void testAutoSubscribingInstanceBasedSubscriptions() throws JSONException, Exception {
clienttasks.register_(sm_clientUsername, sm_clientPassword, sm_clientOrg, null, null, null, null, false, null, null, (String) null, null, null, null, true, null, null, null, null, null);
// to avoid unmapped_guests_only pools
if (Boolean.valueOf(clienttasks.getFactValue("virt.is_guest")))
clienttasks.mapSystemAsAGuestOfItself();
clienttasks.subscribe_(true, null, (String) null, null, null, null, null, null, null, null, null, null, null);
if (clienttasks.getFactValue("virt.is_guest").equalsIgnoreCase("false")) {
Integer sockets = 4;
factsMap.put("cpu.cpu_socket(s)", String.valueOf(sockets));
clienttasks.createFactsFileWithOverridingValues(factsMap);
clienttasks.facts(null, true, null, null, null, null);
clienttasks.subscribe(true, null, (String) null, null, null, null, null, null, null, null, null, null, null);
for (InstalledProduct installed : clienttasks.getCurrentlyInstalledProducts()) {
if (installed.productName.contains("Instance Server")) {
Assert.assertEquals(installed.status.trim(), "Subscribed");
}
}
for (ProductSubscription consumed : clienttasks.getCurrentlyConsumedProductSubscriptions()) {
if (consumed.productName.contains("Instance Based")) {
String SocketsCount = CandlepinTasks.getPoolProductAttributeValue(sm_clientUsername, sm_clientPassword, sm_serverUrl, consumed.poolId, "sockets");
sockets = sockets / Integer.parseInt(SocketsCount);
Assert.assertEquals(consumed.quantityUsed, sockets);
}
}
}
if (clienttasks.getFactValue("virt.is_guest").equals("True")) {
Integer sockets = 4;
factsMap.put("cpu.cpu_socket(s)", String.valueOf(sockets));
clienttasks.createFactsFileWithOverridingValues(factsMap);
clienttasks.facts(null, true, null, null, null, null);
clienttasks.subscribe(true, null, (String) null, null, null, null, null, null, null, null, null, null, null);
for (InstalledProduct installed : clienttasks.getCurrentlyInstalledProducts()) {
if (installed.productName.contains("Instance Server")) {
Assert.assertEquals(installed.status.trim(), "Subscribed");
}
}
for (ProductSubscription consumed : clienttasks.getCurrentlyConsumedProductSubscriptions()) {
if (consumed.productName.contains("Instance Based")) {
Integer quantity = 1;
Assert.assertEquals(consumed.quantityUsed, quantity);
}
}
}
}
Aggregations