use of rhsm.data.ProductCert in project rhsm-qe by RedHatQE.
the class PluginTests method testEnabledProductIdInstallTestPluginHooksAreCalled.
@// update=true // uncomment to make TestDefinition changes update Polarion testcases through the polarize testcase importer
TestDefinition(projectID = { Project.RHEL6, Project.RedHatEnterpriseLinux7 }, testCaseID = { "RHEL6-20060", "RHEL7-55177" }, 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 = "execute subscription-manager modules and verify the expected ProductIdInstallTestPlugin hooks are called", groups = { "Tier1Tests", "blockedByBug-859197", "blockedByBug-922871", /*, "blockedByBug-922882"*/
"blockedByBug-1512948" }, priority = 630, enabled = true)
public // @ImplementsNitrateTest(caseId=)
void testEnabledProductIdInstallTestPluginHooksAreCalled() {
if (clienttasks.getCurrentProductCertFiles().isEmpty())
throw new SkipException("This test will install a layered RHEL product which requires a base RHEL product cert to be installed. Skipping this test because no RHEL product is installed.");
truncateRhsmLog();
// get the current rhsm logging level; INFO or DEBUG
String rhsmLogLevel = null;
if (clienttasks.isPackageVersion("subscription-manager", ">=", "1.17.10-1")) {
// RHEL7.3 commit d84b15f42c2e4521e130b939039960c0846b849c 1334916: Move logging configuration to rhsm.conf
rhsmLogLevel = clienttasks.getConfFileParameter(clienttasks.rhsmConfFile, "logging", "default_log_level");
} else if (clienttasks.isPackageVersion("subscription-manager", ">=", "1.14.2-1")) {
// commit 66aafd77dc629b921379f0e121421c1c21c0b787 Move to fileConfig based logging.
rhsmLogLevel = clienttasks.getConfFileParameter(clienttasks.rhsmLoggingConfFile, "handler_rhsm_log", "level");
} else {
// default
rhsmLogLevel = "DEBUG";
}
// register
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));
// mark the rhsm.log file
String logMarker = System.currentTimeMillis() + " Testing verifyEnabledProductIdInstallTestPluginHooksAreCalled_Test...";
RemoteFileTasks.markFile(client, clienttasks.rhsmLogFile, logMarker);
// do a yum transaction and assert that the product_id_install hooks are NOT yet called
clienttasks.getYumRepolist("all --enableplugin=product-id");
// sleep(5000); // give the plugin hooks a chance to be called; I think this is an async process
// get the tail of the marked rhsm.log file
String logTail = RemoteFileTasks.getTailFromMarkedFile(client, clienttasks.rhsmLogFile, logMarker, "Running p").trim();
// assert the pre/post_product_id_install_hooks are NOT called
List<String> notExpectedLogInfo = Arrays.asList("Running pre_product_id_install_hook", "Running post_product_id_install_hook", "");
Assert.assertTrue(!logTail.replaceAll("\n", "").matches(".*" + joinListToString(notExpectedLogInfo, ".*") + ".*"), "The '" + clienttasks.rhsmLogFile + "' DOES NOT report log messages (becasue no product id should have been installed): " + notExpectedLogInfo);
// now login with the HighAvailability credentials and install a package and assert the pre/post_product_id_install_hooks are called
if (sm_haUsername.equals(""))
throw new SkipException("Skipping this test when no value was given for the High Availability username.");
// Red Hat Enterprise Linux High Availability (for RHEL Server)
String haProductId = "83";
// Red Hat Enterprise Linux High Availability (for IBM z Systems)
if (clienttasks.arch.startsWith("s390"))
haProductId = "300";
// register to an account that offers High Availability subscriptions
consumerId = clienttasks.getCurrentConsumerId(clienttasks.register(sm_haUsername, sm_haPassword, sm_haOrg, null, null, null, null, null, null, null, (String) null, null, null, null, true, null, null, null, null, null));
// make sure that there are no ha packages and no productId installed
List<String> haPackages = HighAvailabilityTests.getHighAvailabilityPackages(clienttasks.redhatReleaseXY, clienttasks.arch);
for (String haPackage : haPackages) {
if (clienttasks.isPackageInstalled(haPackage))
clienttasks.yumRemovePackage(haPackage);
}
InstalledProduct haInstalledProduct = InstalledProduct.findFirstInstanceWithMatchingFieldFromList("productId", haProductId, clienttasks.getCurrentlyInstalledProducts());
if (haInstalledProduct != null) {
ProductCert haInstalledProductCert = ProductCert.findFirstInstanceWithMatchingFieldFromList("productId", haProductId, clienttasks.getCurrentProductCerts());
log.warning("Manually removing installed High Availability product cert and restoring '" + clienttasks.productIdJsonFile + "' (you are probably running a RHEL5 client)...");
client.runCommandAndWait("rm -f " + haInstalledProductCert.file.getPath());
restoreProductIdJsonFileAfterClass();
haInstalledProduct = InstalledProduct.findFirstInstanceWithMatchingFieldFromList("productId", haProductId, clienttasks.getCurrentlyInstalledProducts());
}
Assert.assertNull(haInstalledProduct, "The High Availability product id '" + haProductId + "' should NOT be installed after successful removal of all High Availability packages.");
// Subscribe to the High Availability subscription SKU
List<SubscriptionPool> availableSubscriptionPools = clienttasks.getCurrentlyAvailableSubscriptionPools();
String haSku = HighAvailabilityTests.getHighAvailabilitySku(clienttasks.arch);
SubscriptionPool haPool = SubscriptionPool.findFirstInstanceWithMatchingFieldFromList("productId", haSku, availableSubscriptionPools);
if (clienttasks.variant.equals("Server") && getArchesOfferringHighAvailabilityContent().contains(clienttasks.arch)) {
Assert.assertNotNull(haPool, "A subscription pool for High Availability SKU '" + haSku + "' is available.");
clienttasks.subscribe(null, null, haPool.poolId, null, null, null, null, null, null, null, null, null, null);
} else {
throw new SkipException("Not expecting High Availability subscription SKU '" + haSku + "' to offer content on a RHEL '" + clienttasks.redhatReleaseX + "' '" + clienttasks.variant + "' system with arch '" + clienttasks.arch + "'.");
}
// NOT ANYMORE, WE NOW NEED TO ENABLE THE ADDON REPO (A GOOD CHANGE BY REL-ENG DURING THE RHEL7.4 TEST PHASE, AND APPLIED TO ALL RELEASES)
if (/*clienttasks.redhatReleaseX.equals("7") && */
clienttasks.arch.equals("x86_64")) {
clienttasks.repos(null, null, null, "rhel-ha-for-rhel-" + clienttasks.redhatReleaseX + "-server-rpms", null, null, null, null, null);
}
// INFO: rhel-ha-for-rhel-7-for-system-z-rpms/7Server/s390x is NOT enabled by default
if (clienttasks.redhatReleaseX.equals("7") && clienttasks.arch.equals("s390x")) {
clienttasks.repos(null, null, null, "rhel-ha-for-rhel-7-for-system-z-rpms", null, null, null, null, null);
}
// mark the rhsm.log file
logMarker = System.currentTimeMillis() + " Testing verifyEnabledProductIdInstallTestPluginHooksAreCalled_Test...";
RemoteFileTasks.markFile(client, clienttasks.rhsmLogFile, logMarker);
// do a yum install of an ha package
// WARNING! Package ccs also belongs to Resilient Storage which may cause productId 90 to also be installed from one of the beaker repos, therefore --disablerepo=beaker*
// yum -y install ccs --disablerepo=beaker-*
clienttasks.yumInstallPackage(haPackages.get(0), "--disablerepo=beaker-*");
// sleep(5000); // give the plugin hooks a chance to be called; I think this is an async process
// get the tail of the marked rhsm.log file
logTail = RemoteFileTasks.getTailFromMarkedFile(client, clienttasks.rhsmLogFile, logMarker, "Running p").trim();
// assert the pre/post_product_id_install_hooks are called
List<String> expectedLogInfo = new ArrayList<String>();
if (rhsmLogLevel.equals("DEBUG"))
expectedLogInfo.add("Running pre_product_id_install_hook in product_id_install_test.ProductIdInstallTestPlugin");
if (rhsmLogLevel.equals("DEBUG") || rhsmLogLevel.equals("INFO"))
expectedLogInfo.add("Running pre_product_id_install_hook: yum product-id plugin is about to install a product cert");
if (rhsmLogLevel.equals("DEBUG"))
expectedLogInfo.add("Running post_product_id_install_hook in product_id_install_test.ProductIdInstallTestPlugin");
if (rhsmLogLevel.equals("DEBUG") || rhsmLogLevel.equals("INFO"))
expectedLogInfo.add("Running post_product_id_install_hook: yum product-id plugin just installed a product cert");
// if (rhsmLogLevel.equals("DEBUG")||rhsmLogLevel.equals("INFO")) expectedLogInfo.add("Running post_product_id_install_hook: 1 product_ids were just installed"); // probably correct, but not necessary to verify post_product_id_install_hook was called
if (rhsmLogLevel.equals("DEBUG") || rhsmLogLevel.equals("INFO"))
expectedLogInfo.add("Running post_product_id_install_hook: product_id " + haProductId + " was just installed");
// Product Name: Red Hat Enterprise Linux High Availability (for RHEL Server)
// Product ID: 83
Assert.assertTrue(logTail.replaceAll("\n", "").matches(".*" + joinListToString(expectedLogInfo, ".*") + ".*"), "The '" + clienttasks.rhsmLogFile + "' reports log messages: " + expectedLogInfo);
}
use of rhsm.data.ProductCert in project rhsm-qe by RedHatQE.
the class ListTests method testListAvailableWithMatchInstalled.
@// update=true // uncomment to make TestDefinition changes update Polarion testcases through the polarize testcase importer
TestDefinition(projectID = { Project.RHEL6, Project.RedHatEnterpriseLinux7 }, testCaseID = { "RHEL6-36554", "RHEL7-51332" }, 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 = "subscription-manager: subcription manager list with --match-installed option", groups = { "Tier2Tests", "blockedByBug-654501" }, enabled = true)
public // @ImplementsNitrateTest(caseId=)
void testListAvailableWithMatchInstalled() throws JSONException, Exception {
if (clienttasks.isPackageVersion("subscription-manager", "<", "1.10.3-1"))
throw new SkipException("Installed package '" + clienttasks.installedPackageVersionMap.get("subscription-manager") + "' is blockedByBug https://bugzilla.redhat.com/show_bug.cgi?id=654501 which is fixed in subscription-manager-1.10.3-1.");
clienttasks.register(sm_clientUsername, sm_clientPassword, sm_clientOrg, null, null, null, null, null, null, null, (String) null, null, null, null, false, null, null, null, null, null);
clienttasks.autoheal(null, null, true, null, null, null, null);
// assemble a list of currently installed product ids
List<ProductCert> installedProductCerts = clienttasks.getCurrentProductCerts();
List<String> installedProductIds = new ArrayList<String>();
for (ProductCert productCert : installedProductCerts) installedProductIds.add(productCert.productId);
// get the available subscription pools
List<SubscriptionPool> availableSubscriptionPools = SubscriptionPool.parse(clienttasks.list(null, true, null, null, null, null, false, null, null, null, null, null, null, null).getStdout());
List<SubscriptionPool> availableSubscriptionPoolsMatchingInstalled = SubscriptionPool.parse(clienttasks.list(null, true, null, null, null, null, true, null, null, null, null, null, null, null).getStdout());
// loop through the list of available subscription pools with match-installed and assert they really do provide at least one product that is installed.
for (SubscriptionPool subscriptionPool : availableSubscriptionPoolsMatchingInstalled) {
ProductCert matchedInstalledProductCert = null;
for (String providedProductId : CandlepinTasks.getPoolProvidedProductIds(sm_clientUsername, sm_clientPassword, sm_serverUrl, subscriptionPool.poolId)) {
matchedInstalledProductCert = ProductCert.findFirstInstanceWithMatchingFieldFromList("productId", providedProductId, installedProductCerts);
if (matchedInstalledProductCert != null)
break;
}
if (matchedInstalledProductCert != null)
Assert.assertTrue(matchedInstalledProductCert != null, "Available subscription pool '" + subscriptionPool.subscriptionName + "' provides=" + subscriptionPool.provides + " includes product id '" + matchedInstalledProductCert.productId + "' which was found among the product ids of the currently installed product certs. " + installedProductIds);
else
Assert.fail("Subscription-manager list available with match-installed option erroneously reported SubscriptionPool '" + subscriptionPool.subscriptionName + "' provides=" + subscriptionPool.provides + " which does NOT provide a product whose id was found among the currently installed product certs. " + installedProductIds);
}
// loop through the list of available subscription without match-installed and make sure those that provide an installed product id are included in the filtered list
for (SubscriptionPool subscriptionPool : availableSubscriptionPools) {
boolean providesAnInstalledProductId = false;
for (String providedProductId : CandlepinTasks.getPoolProvidedProductIds(sm_clientUsername, sm_clientPassword, sm_serverUrl, subscriptionPool.poolId)) {
if (installedProductIds.contains(providedProductId))
providesAnInstalledProductId = true;
}
if (providesAnInstalledProductId)
Assert.assertTrue(availableSubscriptionPoolsMatchingInstalled.contains(subscriptionPool), "The list of available subscriptions with match-installed option includes '" + subscriptionPool.subscriptionName + "' provides=" + subscriptionPool.provides);
else
Assert.assertTrue(!availableSubscriptionPoolsMatchingInstalled.contains(subscriptionPool), "The list of available subscriptions with match-installed option does NOT include '" + subscriptionPool.subscriptionName + "' provides=" + subscriptionPool.provides);
}
}
use of rhsm.data.ProductCert in project rhsm-qe by RedHatQE.
the class ListTests method testListInstalledWithProductDefault.
@// update=true // uncomment to make TestDefinition changes update Polarion testcases through the polarize testcase importer
TestDefinition(projectID = { Project.RHEL6, Project.RedHatEnterpriseLinux7 }, testCaseID = { "RHEL6-19966", "RHEL7-33101" }, 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")
@// see description in https://github.com/candlepin/subscription-manager/pull/1009
Test(// see description in https://github.com/candlepin/subscription-manager/pull/1009
description = "subscription-manager: list installed should include product certs in /etc/pki/product-default", // subscription-manager 1123029 - [RFE] Use default product certificates when they are present COMPLEMENT TO REL-ENG RFE 1080012 - [RFE] Include default product certificate in redhat-release
groups = { "Tier1Tests", "ListInstalledWithProductDefault_Test", "blockedByBug-1123029" /*1080012*/
}, priority = 150, enabled = true)
public // @ImplementsNitrateTest(caseId=)
void testListInstalledWithProductDefault() {
if (clienttasks.isPackageVersion("subscription-manager", "<", "1.12.14-1"))
throw new SkipException("The /etc/pki/product-default feature is not implemented in this version of subscription-manager.");
// strategy...
// copy a random selection of product certs from subscription-manager-migration-data into /etc/pki/product-default
// make sure that some of the product certs copied include product ids already installed in /etc/pki/product
// assert that list --installed includes all the product certs but those in /etc/pki/product take precedence over /etc/pki/product-default
// assert the existance of /etc/pki/product-default
Assert.assertTrue(RemoteFileTasks.testExists(client, clienttasks.productCertDefaultDir), "Expecting directory '" + clienttasks.productCertDefaultDir + "' to exist.");
// get the original product certs that are currently installed in /etc/pki/product-default
originalDefaultProductCerts = clienttasks.getProductCerts(clienttasks.productCertDefaultDir);
// get the product certs that are currently installed in /etc/pki/product
List<ProductCert> productCerts = clienttasks.getProductCerts(clienttasks.productCertDir);
// copy migration-data product certs to /etc/pki/product-default (including productCerts whose product id matches /etc/pki/product cert and does not already exist in /etc/pki/product-default)
List<File> migrationProductCertsFiles = clienttasks.getProductCertFiles("/usr/share/rhsm/product/RHEL" + "-" + clienttasks.redhatReleaseX);
Set<String> defaultProductCertProductIds = new HashSet<String>();
for (ProductCert defaultProductCert : originalDefaultProductCerts) defaultProductCertProductIds.add(defaultProductCert.productId);
String migrationProductCertFilesToCopy = "";
for (File migrationProductCertFile : migrationProductCertsFiles) {
String migrationProductCertProductId = MigrationDataTests.getProductIdFromProductCertFilename(migrationProductCertFile.getPath());
// if this migrationProductCertProductId is already among the defaultProductCertProductIds, skip it - do not copy another since it does not make sense to have multiple product certs with the same productId in the same directory
if (defaultProductCertProductIds.contains(migrationProductCertProductId)) {
continue;
}
// if this migrationProductCertProductId is installed in /etc/pki/product, copy it to /etc/pki/product-default
if (ProductCert.findFirstInstanceWithMatchingFieldFromList("productId", migrationProductCertProductId, productCerts) != null) {
// TOO MUCH LOGGING client.runCommandAndWait("cp -n "+migrationProductCertFile+" "+clienttasks.productCertDefaultDir);
migrationProductCertFilesToCopy += migrationProductCertFile + " ";
defaultProductCertProductIds.add(migrationProductCertProductId);
continue;
}
// randomly skip 75% of these copies to reduce logging noise
if (getRandomListItem(Arrays.asList(new Integer[] { 1 /*,2,3,4*/
})).equals(1)) {
// TOO MUCH LOGGING client.runCommandAndWait("cp -n "+migrationProductCertFile+" "+clienttasks.productCertDefaultDir);
migrationProductCertFilesToCopy += migrationProductCertFile + " ";
defaultProductCertProductIds.add(migrationProductCertProductId);
}
}
if (!migrationProductCertFilesToCopy.isEmpty())
client.runCommandAndWait("cp -n " + migrationProductCertFilesToCopy + " " + clienttasks.productCertDefaultDir);
// get the product certs that are currently installed in /etc/pki/product-default
List<ProductCert> defaultProductCerts = clienttasks.getProductCerts(clienttasks.productCertDefaultDir);
// get the currently InstalledProducts
List<InstalledProduct> installedProducts = clienttasks.getCurrentlyInstalledProducts();
// etc/pki/product are included in the currently InstalledProducts
for (ProductCert productCert : productCerts) {
List<InstalledProduct> installedProductsMatchingProductCertId = InstalledProduct.findAllInstancesWithMatchingFieldFromList("productId", productCert.productId, installedProducts);
Assert.assertEquals(installedProductsMatchingProductCertId.size(), 1, "The list of Installed Products contains exactly 1 entry with a productId='" + productCert.productId + "' from '" + clienttasks.productCertDir + "'.");
InstalledProduct installedProductMatchingProductCertId = installedProductsMatchingProductCertId.get(0);
Assert.assertEquals(installedProductMatchingProductCertId.productName, productCert.productNamespace.name, "The list of Installed Products includes '" + productCert.productNamespace.name + "' from '" + clienttasks.productCertDir + "'.");
Assert.assertEquals(installedProductMatchingProductCertId.version, productCert.productNamespace.version, "The list of Installed Products includes '" + productCert.productNamespace.name + "' version '" + productCert.productNamespace.version + "' from '" + clienttasks.productCertDir + "'.");
}
// etc/pki/product-default are included in the currently InstalledProducts (unless it's productId is already installed in /etc/pki/product which takes precedence over /etc/pki/product-default).
for (ProductCert defaultProductCert : defaultProductCerts) {
List<InstalledProduct> installedProductsMatchingProductCertId = InstalledProduct.findAllInstancesWithMatchingFieldFromList("productId", defaultProductCert.productId, installedProducts);
Assert.assertEquals(installedProductsMatchingProductCertId.size(), 1, "The list of Installed Products contains exactly 1 entry with a productId='" + defaultProductCert.productId + "' from '" + clienttasks.productCertDefaultDir + "'.");
InstalledProduct installedProductMatchingProductCertId = installedProductsMatchingProductCertId.get(0);
ProductCert precedentProductCert = ProductCert.findFirstInstanceWithMatchingFieldFromList("productId", defaultProductCert.productId, productCerts);
if (precedentProductCert != null) {
// verify the precedentProductCert overrides the defaultProductCert
Assert.assertEquals(installedProductMatchingProductCertId.productName, precedentProductCert.productNamespace.name, "The list of Installed Products includes '" + precedentProductCert.productNamespace.name + "' from '" + clienttasks.productCertDir + "' since it takes precedence over '" + defaultProductCert + "' from '" + clienttasks.productCertDefaultDir + "'.");
Assert.assertEquals(installedProductMatchingProductCertId.version, precedentProductCert.productNamespace.version, "The list of Installed Products includes '" + precedentProductCert.productNamespace.name + "' version '" + precedentProductCert.productNamespace.version + "' from '" + clienttasks.productCertDir + "' since it takes precedence over '" + defaultProductCert + "' from '" + clienttasks.productCertDefaultDir + "'.");
Assert.assertEquals(installedProductMatchingProductCertId.arch, precedentProductCert.productNamespace.arch, "The list of Installed Products includes '" + precedentProductCert.productNamespace.name + "' arch '" + precedentProductCert.productNamespace.arch + "' from '" + clienttasks.productCertDir + "' since it takes precedence over '" + defaultProductCert + "' from '" + clienttasks.productCertDefaultDir + "'.");
} else {
// verify that the defaultProductCert is included in list of Installed Products
Assert.assertEquals(installedProductMatchingProductCertId.productName, defaultProductCert.productNamespace.name, "The list of Installed Products includes '" + defaultProductCert.productNamespace.name + "' from '" + clienttasks.productCertDefaultDir + "' since there is no product cert with ID '" + defaultProductCert.productId + "' in '" + clienttasks.productCertDir + "' that takes precedence.");
Assert.assertEquals(installedProductMatchingProductCertId.version, defaultProductCert.productNamespace.version, "The list of Installed Products includes '" + defaultProductCert.productNamespace.name + "' version '" + defaultProductCert.productNamespace.version + "' from '" + clienttasks.productCertDefaultDir + "' since there is no product cert with ID '" + defaultProductCert.productId + "' in '" + clienttasks.productCertDir + "' that takes precedence.");
Assert.assertEquals(installedProductMatchingProductCertId.arch, defaultProductCert.productNamespace.arch, "The list of Installed Products includes '" + defaultProductCert.productNamespace.name + "' arch '" + defaultProductCert.productNamespace.arch + "' from '" + clienttasks.productCertDefaultDir + "' since there is no product cert with ID '" + defaultProductCert.productId + "' in '" + clienttasks.productCertDir + "' that takes precedence.");
}
}
}
use of rhsm.data.ProductCert in project rhsm-qe by RedHatQE.
the class MigrationDataTests method testChannelCertMappingFileSupportsRhnChannelFromProductCerts.
@// update=true, // uncomment to make TestDefinition changes update Polarion testcases through the polarize testcase importer
TestDefinition(projectID = { Project.RHEL6, Project.RedHatEnterpriseLinux7 }, testCaseID = { "RHEL6-21884", "RHEL7-51739" }, 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 that all of the required RHN Channels in the product-certs.json file are accounted for in channel-cert-mapping.txt", groups = { "Tier3Tests", "blockedByBug-1025338", "blockedByBug-1080072", "blockedByBug-1241221" }, dependsOnMethods = { "testChannelCertMapping" }, dataProvider = "RhnChannelFromProductCertsData", // Starting in RHEL65, we are moving away from product-baseline.json and replacing it with product-certs.json
enabled = true)
public // @ImplementsNitrateTest(caseId=)
void testChannelCertMappingFileSupportsRhnChannelFromProductCerts(Object bugzilla, String productCertsRhnChannel, File productCertsProductFile) throws JSONException {
// See Bug 1011992 - High Touch Beta channel mappings should be excluded from channel-cert-mapping.txt https://bugzilla.redhat.com/show_bug.cgi?id=1011992
if (productCertsRhnChannel.matches(".+-htb(-.*|$)")) {
log.warning("(degregor 5/4/2012) We intentionally exclude HTB channels from the migration script. It's not a supported use case.");
Assert.assertTrue(!channelsToProductCertFilenamesMap.containsKey(productCertsRhnChannel), "CDN Product Certs RHN Channel '" + productCertsRhnChannel + "' is NOT accounted for in the subscription-manager-migration-data file '" + channelCertMappingFilename + "' since it is a High Touch Beta channel.");
return;
}
// assert that the subscription-manager-migration-data file has a mapping for this RHN Channel found in the CDN Product Certs
Assert.assertTrue(channelsToProductCertFilenamesMap.containsKey(productCertsRhnChannel), "CDN Product Certs RHN Channel '" + productCertsRhnChannel + "' is accounted for in the subscription-manager-migration-data file '" + channelCertMappingFilename + "'.");
// now assert that the subscription-manager-migration-data mapping for the RHN Channel is to the same product cert file as mapped in the CDN Product Certs
if (!channelsToProductCertFilenamesMap.get(productCertsRhnChannel).equals(productCertsProductFile.getName())) {
ProductCert migrationProductCert = clienttasks.getProductCertFromProductCertFile(new File(baseProductsDir + "/" + channelsToProductCertFilenamesMap.get(productCertsRhnChannel)));
ProductCert rhnDefinitionsProductCert = clienttasks.getProductCertFromProductCertFile(new File(clienttasks.rhnDefinitionsDir + "/product_ids" + productCertsProductFile));
log.warning("The subscription-manager-migration-data file '" + channelCertMappingFilename + "' maps RHN Channel '" + productCertsRhnChannel + "' to '" + channelsToProductCertFilenamesMap.get(productCertsRhnChannel) + "' which is different than the rhnDefinitions product-certs.json mapping to '" + productCertsProductFile + "'. Comparing contents for effective equality...");
log.info("Migration product cert '" + migrationProductCert.file + "': " + migrationProductCert.productNamespace);
log.info("CDN Product Cert '" + rhnDefinitionsProductCert.file + "': " + rhnDefinitionsProductCert.productNamespace);
log.info("Expecting those to be effectively equal. If not, then a release-engineering bug is likely.");
Assert.assertEquals(migrationProductCert.productNamespace.name, rhnDefinitionsProductCert.productNamespace.name, "Comparing productNamespace.name between '" + rhnDefinitionsProductCert.file + "' and '" + migrationProductCert.file + "'");
Assert.assertEquals(migrationProductCert.productNamespace.id, rhnDefinitionsProductCert.productNamespace.id, "Comparing productNamespace.id between '" + rhnDefinitionsProductCert.file + "' and '" + migrationProductCert.file + "'");
Assert.assertEquals(migrationProductCert.productNamespace.arch, rhnDefinitionsProductCert.productNamespace.arch, "Comparing productNamespace.arch between '" + rhnDefinitionsProductCert.file + "' and '" + migrationProductCert.file + "'");
Assert.assertTrue(areTagsEquivalent(migrationProductCert.productNamespace.providedTags, rhnDefinitionsProductCert.productNamespace.providedTags), "The productNamespace.providedTags between '" + rhnDefinitionsProductCert.file + "' '" + rhnDefinitionsProductCert.productNamespace.providedTags + "' and '" + migrationProductCert.file + "' '" + migrationProductCert.productNamespace.providedTags + "' are equivalent.");
// TEMPORARY WORKAROUND
if (clienttasks.redhatReleaseXY.equals("7.4") && rhnDefinitionsProductCert.productNamespace.version.startsWith(clienttasks.redhatReleaseXY) && !migrationProductCert.productNamespace.version.equals(rhnDefinitionsProductCert.productNamespace.version)) {
boolean invokeWorkaroundWhileBugIsOpen = true;
// Bug 1436441 - subscription-manager-migration-data for RHEL7.4 needs RHEL7.4 product certs (not RHEL7.3 certs)
String bugId = "1436441";
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("Skipping assertion that the product cert version provided by subscription-manager-migration-data mapped to RHN channel " + productCertsRhnChannel + " matches the upstream mapping from product-certs.json while bug " + bugId + " is open.");
}
}
// END OF WORKAROUND
Assert.assertEquals(migrationProductCert.productNamespace.version, rhnDefinitionsProductCert.productNamespace.version, "Comparing productNamespace.version between '" + rhnDefinitionsProductCert.file + "' and '" + migrationProductCert.file + "'");
} else {
Assert.assertEquals(channelsToProductCertFilenamesMap.get(productCertsRhnChannel), productCertsProductFile.getName(), "The subscription-manager-migration-data file '" + channelCertMappingFilename + "' maps RHN Channel '" + productCertsRhnChannel + "' to the same product cert file as dictated in the CDN Product Certs.");
}
}
use of rhsm.data.ProductCert in project rhsm-qe by RedHatQE.
the class MigrationDataTests method getRhnRhelChannelsFromChannelMappingDataAsListOfLists.
public List<List<Object>> getRhnRhelChannelsFromChannelMappingDataAsListOfLists() throws JSONException {
List<List<Object>> ll = new ArrayList<List<Object>>();
if (clienttasks == null)
return ll;
for (String rhnChannel : channelsToProductCertFilenamesMap.keySet()) {
ProductCert rhnRhelProductCert = null;
if (channelsToProductCertFilenamesMap.get(rhnChannel).equalsIgnoreCase("none"))
rhnRhelProductCert = clienttasks.getProductCertFromProductCertFile(new File(baseProductsDir + "/" + channelsToProductCertFilenamesMap.get(rhnChannel)));
// get all of the provided tags from the rhnRhelProductCert
List<String> rhnRhelProductProvidedTags = new ArrayList<String>();
if (rhnRhelProductCert != null) {
if (rhnRhelProductCert.productNamespace.providedTags != null) {
for (String providedTag : rhnRhelProductCert.productNamespace.providedTags.split("\\s*,\\s*")) {
rhnRhelProductProvidedTags.add(providedTag);
}
}
}
// consider skipping channels that do NOT provide the base release rhel-X tag
if (!rhnRhelProductProvidedTags.contains("rhel-" + clienttasks.redhatReleaseX)) {
// rhel-x86_64-workstation-6-debuginfo
if (!rhnChannel.startsWith("rhel-"))
continue;
if (!rhnChannel.endsWith("-" + clienttasks.redhatReleaseX) && !rhnChannel.contains("-" + clienttasks.redhatReleaseX + "-"))
continue;
// rhel-x86_64-server-6-osop-1-rhc
if (rhnChannel.contains("-ose-"))
continue;
if (rhnChannel.contains("-osop-"))
continue;
// rhel-x86_64-server-6-ost-3
if (rhnChannel.contains("-ost-"))
continue;
// rhel-i386-server-6-mrg-messaging-2
if (rhnChannel.contains("-mrg-messaging-"))
continue;
// rhel-x86_64-server-6-mrg-realtime-2
if (rhnChannel.contains("-mrg-realtime-"))
continue;
// rhel-x86_64-server-6-mrg-grid-execute-2-debuginfo
if (rhnChannel.contains("-mrg-grid-"))
continue;
// rhel-x86_64-server-6-mrg-management-2
if (rhnChannel.contains("-mrg-management-"))
continue;
// rhel-x86_64-server-6-rhscl-1
if (rhnChannel.contains("-rhscl-"))
continue;
// rhel-x86_64-rhev-mgmt-agent-6
if (rhnChannel.contains("-rhevm-"))
continue;
if (rhnChannel.contains("-rhevh-") || rhnChannel.endsWith("-rhevh"))
continue;
if (rhnChannel.contains("-rhev-mgmt-"))
continue;
// rhel-x86_64-server-6-rhs-2.0
if (rhnChannel.contains("-rhs-"))
continue;
// rhel-i386-server-dts2-5
if (rhnChannel.contains("-dts-"))
continue;
if (rhnChannel.contains("-dts2-"))
continue;
// rhel-x86_64-server-hts-6
if (rhnChannel.contains("-hts-"))
continue;
// rhel-x86_64-server-6-cert-beta
if (rhnChannel.endsWith("-server-6-cert-beta"))
continue;
if (rhnChannel.endsWith("-server-6-cert"))
continue;
// rhel-x86_64-server-7-cert-beta
if (rhnChannel.endsWith("-server-7-cert-beta"))
continue;
if (rhnChannel.endsWith("-server-7-cert"))
continue;
// rhel-x86_64-server-5-rhdirserv-8
if (rhnChannel.contains("-rhdirserv-"))
continue;
// rhel-i386-server-sjis-6
if (rhnChannel.contains("-sjis-"))
continue;
// rhel-x86_64-server-eucjp-6
if (rhnChannel.contains("-eucjp-"))
continue;
// rhel-x86_64-server-6-cf-se-1
if (rhnChannel.contains("-cf-ce-"))
continue;
if (rhnChannel.contains("-cf-me-"))
continue;
if (rhnChannel.contains("-cf-se-"))
continue;
// rhel-x86_64-server-6-ovs-supplemental
if (rhnChannel.contains("-ovs-"))
continue;
// rhel-x86_64-server-hpn-6
if (rhnChannel.contains("-hpn-"))
continue;
// rhel-x86_64-server-sap-6
if (rhnChannel.contains("-sap-"))
continue;
// rhel-ppc64-server-bluegene-6
if (rhnChannel.contains("-bluegene-"))
continue;
// rhel-ppc64-server-p7ih-6
if (rhnChannel.contains("-p7ih-"))
continue;
// rhel-ppc-server-cluster-storage-5
if (rhnChannel.contains("-cluster-storage-"))
continue;
// rhel-x86_64-server-6-rh-gluster-3-samba
if (rhnChannel.contains("-rh-gluster-"))
continue;
// rhel-ppc-server-cluster-5
if (rhnChannel.contains("-cluster-"))
continue;
// rhel-x86_64-server-5-rhcmsys-8
if (rhnChannel.contains("-rhcmsys-"))
continue;
}
// bugzillas
Set<String> bugIds = new HashSet<String>();
// Bug 1078527 - channel-cert-mapping for ComputeNode rhel-7 product certs are missing and wrong
if (rhnChannel.equals("rhel-x86_64-hpc-node-fastrack-7") || rhnChannel.equals("rhel-x86_64-hpc-node-fastrack-7-debuginfo") || rhnChannel.equals("rhel-x86_64-hpc-node-rh-common-7-debuginfo") || rhnChannel.equals("rhel-x86_64-hpc-node-7-debuginfo")) {
bugIds.add("1078527");
}
// Bug 1105279 - rhn channel rhel-x86_64-server-scalefs-5 maps to a version 5.10 product cert - should be 5.1
if (rhnChannel.equals("rhel-x86_64-server-scalefs-5") || rhnChannel.equals("rhel-x86_64-server-scalefs-5-beta")) {
bugIds.add("1105279");
}
// Bug 1176260 - the RHN RHEL Channels 'rhel-<ARCH>-<VARIANT>-7-thirdparty-oracle-java-beta' map to a '7.0' version cert; should be '7.1 Beta'
if (rhnChannel.equals("rhel-x86_64-client-7-thirdparty-oracle-java-beta") || rhnChannel.equals("rhel-x86_64-hpc-node-7-thirdparty-oracle-java-beta") || rhnChannel.equals("rhel-x86_64-server-7-thirdparty-oracle-java-beta") || rhnChannel.equals("rhel-x86_64-workstation-7-thirdparty-oracle-java-beta")) {
if (clienttasks.redhatReleaseXY.equals("7.1"))
bugIds.add("1176260");
}
// Bug 1263432 - the RHN RHEL Channels 'rhel-x86_64-<VARIANT>-7-thirdparty-oracle-java-beta' map to a '7.1' version cert; should be '7.2 Beta'
if (rhnChannel.equals("rhel-x86_64-client-7-thirdparty-oracle-java-beta") || rhnChannel.equals("rhel-x86_64-hpc-node-7-thirdparty-oracle-java-beta") || rhnChannel.equals("rhel-x86_64-server-7-thirdparty-oracle-java-beta") || rhnChannel.equals("rhel-x86_64-workstation-7-thirdparty-oracle-java-beta")) {
if (clienttasks.redhatReleaseXY.equals("7.2"))
bugIds.add("1263432");
}
// Bug 1320647 - rhn channels 'rhel-ARCH-workstation-6-thirdparty-oracle-java-beta' should maps to the Beta product cert, not the GA cert.
if (rhnChannel.equals("rhel-i386-workstation-6-thirdparty-oracle-java-beta") || rhnChannel.equals("rhel-x86_64-workstation-6-thirdparty-oracle-java-beta")) {
if (clienttasks.redhatReleaseXY.equals("6.8"))
bugIds.add("1320647");
}
// Bug 1349584 - RHN RHEL Channels 'rhel-x86_64-<VARIANT>-7-thirdparty-oracle-java' map to a '7.2' version cert; should be '7.3'
if (rhnChannel.equals("rhel-x86_64-client-7-thirdparty-oracle-java") || rhnChannel.equals("rhel-x86_64-hpc-node-7-thirdparty-oracle-java") || rhnChannel.equals("rhel-x86_64-server-7-thirdparty-oracle-java") || rhnChannel.equals("rhel-x86_64-workstation-7-thirdparty-oracle-java")) {
if (clienttasks.redhatReleaseXY.equals("7.3"))
bugIds.add("1349584");
}
// Bug 1349592 - RHN RHEL Channels 'rhel-x86_64-<VARIANT>-7-thirdparty-oracle-java-beta' map to a '7.2' version cert; should be '7.3 Beta'
if (rhnChannel.equals("rhel-x86_64-client-7-thirdparty-oracle-java-beta") || rhnChannel.equals("rhel-x86_64-hpc-node-7-thirdparty-oracle-java-beta") || rhnChannel.equals("rhel-x86_64-server-7-thirdparty-oracle-java-beta") || rhnChannel.equals("rhel-x86_64-workstation-7-thirdparty-oracle-java-beta")) {
if (clienttasks.redhatReleaseXY.equals("7.3"))
bugIds.add("1349592");
}
// Bug 1464236 - RHN RHEL Channels 'rhel-x86_64-<VARIANT>-7-thirdparty-oracle-java' map to a '7.3' version cert; should be '7.4'
if (rhnChannel.equals("rhel-x86_64-client-7-thirdparty-oracle-java") || rhnChannel.equals("rhel-x86_64-hpc-node-7-thirdparty-oracle-java") || rhnChannel.equals("rhel-x86_64-server-7-thirdparty-oracle-java") || rhnChannel.equals("rhel-x86_64-workstation-7-thirdparty-oracle-java")) {
if (clienttasks.redhatReleaseXY.equals("7.3"))
bugIds.add("1464236");
}
// Bug 1549766 - Numerous RHN RHEL Channels map to a RHEL '7.4' version certificate instead of the latest '7.5' version
if (rhnChannel.equals("rhel-ppc64-server-extras-7") || rhnChannel.equals("rhel-ppc64-server-extras-7-debuginfo") || rhnChannel.equals("rhel-ppc64-server-fastrack-7") || rhnChannel.equals("rhel-ppc64-server-fastrack-7-debuginfo") || rhnChannel.equals("rhel-ppc64-server-optional-7") || rhnChannel.equals("rhel-ppc64-server-optional-7-debuginfo") || rhnChannel.equals("rhel-ppc64-server-optional-fastrack-7") || rhnChannel.equals("rhel-ppc64-server-optional-fastrack-7-debuginfo") || rhnChannel.equals("rhel-ppc64-server-rh-common-7") || rhnChannel.equals("rhel-ppc64-server-rh-common-7-debuginfo") || rhnChannel.equals("rhel-ppc64-server-supplementary-7") || rhnChannel.equals("rhel-ppc64-server-supplementary-7-debuginfo") || rhnChannel.equals("rhel-s390x-server-extras-7") || rhnChannel.equals("rhel-s390x-server-extras-7-debuginfo") || rhnChannel.equals("rhel-s390x-server-fastrack-7") || rhnChannel.equals("rhel-s390x-server-fastrack-7-debuginfo") || rhnChannel.equals("rhel-s390x-server-optional-7") || rhnChannel.equals("rhel-s390x-server-optional-7-debuginfo") || rhnChannel.equals("rhel-s390x-server-optional-fastrack-7") || rhnChannel.equals("rhel-s390x-server-optional-fastrack-7-debuginfo") || rhnChannel.equals("rhel-s390x-server-rh-common-7") || rhnChannel.equals("rhel-s390x-server-rh-common-7-debuginfo") || rhnChannel.equals("rhel-s390x-server-supplementary-7") || rhnChannel.equals("rhel-s390x-server-supplementary-7-debuginfo") || rhnChannel.equals("rhel-x86_64-client-extras-7") || rhnChannel.equals("rhel-x86_64-client-extras-7-debuginfo") || rhnChannel.equals("rhel-x86_64-client-fastrack-7") || rhnChannel.equals("rhel-x86_64-client-fastrack-7-debuginfo") || rhnChannel.equals("rhel-x86_64-client-optional-7") || rhnChannel.equals("rhel-x86_64-client-optional-7-debuginfo") || rhnChannel.equals("rhel-x86_64-client-optional-fastrack-7") || rhnChannel.equals("rhel-x86_64-client-optional-fastrack-7-debuginfo") || rhnChannel.equals("rhel-x86_64-client-rh-common-7") || rhnChannel.equals("rhel-x86_64-client-rh-common-7-debuginfo") || rhnChannel.equals("rhel-x86_64-client-supplementary-7") || rhnChannel.equals("rhel-x86_64-client-supplementary-7-debuginfo") || rhnChannel.equals("rhel-x86_64-hpc-node-extras-7") || rhnChannel.equals("rhel-x86_64-hpc-node-extras-7-debuginfo") || rhnChannel.equals("rhel-x86_64-hpc-node-fastrack-7") || rhnChannel.equals("rhel-x86_64-hpc-node-fastrack-7-debuginfo") || rhnChannel.equals("rhel-x86_64-hpc-node-optional-7") || rhnChannel.equals("rhel-x86_64-hpc-node-optional-7-debuginfo") || rhnChannel.equals("rhel-x86_64-hpc-node-optional-fastrack-7") || rhnChannel.equals("rhel-x86_64-hpc-node-optional-fastrack-7-debuginfo") || rhnChannel.equals("rhel-x86_64-hpc-node-rh-common-7") || rhnChannel.equals("rhel-x86_64-hpc-node-rh-common-7-debuginfo") || rhnChannel.equals("rhel-x86_64-hpc-node-supplementary-7") || rhnChannel.equals("rhel-x86_64-hpc-node-supplementary-7-debuginfo") || rhnChannel.equals("rhel-x86_64-server-extras-7") || rhnChannel.equals("rhel-x86_64-server-extras-7-debuginfo") || rhnChannel.equals("rhel-x86_64-server-fastrack-7") || rhnChannel.equals("rhel-x86_64-server-fastrack-7-debuginfo") || rhnChannel.equals("rhel-x86_64-server-ha-fastrack-7") || rhnChannel.equals("rhel-x86_64-server-ha-fastrack-7-debuginfo") || rhnChannel.equals("rhel-x86_64-server-optional-7") || rhnChannel.equals("rhel-x86_64-server-optional-7-debuginfo") || rhnChannel.equals("rhel-x86_64-server-optional-fastrack-7") || rhnChannel.equals("rhel-x86_64-server-optional-fastrack-7-debuginfo") || rhnChannel.equals("rhel-x86_64-server-rh-common-7") || rhnChannel.equals("rhel-x86_64-server-rh-common-7-debuginfo") || rhnChannel.equals("rhel-x86_64-server-rs-fastrack-7") || rhnChannel.equals("rhel-x86_64-server-rs-fastrack-7-debuginfo") || rhnChannel.equals("rhel-x86_64-server-supplementary-7") || rhnChannel.equals("rhel-x86_64-server-supplementary-7-debuginfo") || rhnChannel.equals("rhel-x86_64-server-v2vwin-7") || rhnChannel.equals("rhel-x86_64-server-v2vwin-7-debuginfo") || rhnChannel.equals("rhel-x86_64-workstation-extras-7") || rhnChannel.equals("rhel-x86_64-workstation-extras-7-debuginfo") || rhnChannel.equals("rhel-x86_64-workstation-fastrack-7") || rhnChannel.equals("rhel-x86_64-workstation-fastrack-7-debuginfo") || rhnChannel.equals("rhel-x86_64-workstation-optional-7") || rhnChannel.equals("rhel-x86_64-workstation-optional-7-debuginfo") || rhnChannel.equals("rhel-x86_64-workstation-optional-fastrack-7") || rhnChannel.equals("rhel-x86_64-workstation-optional-fastrack-7-debuginfo") || rhnChannel.equals("rhel-x86_64-workstation-rh-common-7") || rhnChannel.equals("rhel-x86_64-workstation-rh-common-7-debuginfo") || rhnChannel.equals("rhel-x86_64-workstation-supplementary-7") || rhnChannel.equals("rhel-x86_64-workstation-supplementary-7-debuginfo") || rhnChannel.equals("")) {
if (clienttasks.redhatReleaseXY.equals("7.5"))
bugIds.add("1549766");
}
// Object bugzilla, String productBaselineRhnChannel, String productBaselineProductId
BlockedByBzBug blockedByBzBug = new BlockedByBzBug(bugIds.toArray(new String[] {}));
ll.add(Arrays.asList(new Object[] { blockedByBzBug, rhnChannel }));
}
return ll;
}
Aggregations