use of com.redhat.qe.auto.bugzilla.BugzillaAPIException in project rhsm-qe by RedHatQE.
the class ConfigTests method testSubscriptionManagerShouldNotAutomaticallyEnableYumPluginsWhenAutoEnableIsOff.
@// update=true, // uncomment to make TestDefinition changes update Polarion testcases through the polarize testcase importer
TestDefinition(projectID = { Project.RHEL6, Project.RedHatEnterpriseLinux7 }, testCaseID = { "RHEL6-47940", "RHEL7-99808" }, linkedWorkItems = { // role= DefTypes.Role.VERIFIES),
@LinkedItem(// RHEL7-95149 - RHSM-REQ : subscription-manager should automatically enable yum plugins
workitemId = "RHEL7-95149", project = Project.RedHatEnterpriseLinux7, role = DefTypes.Role.VERIFIES) }, 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 that the yum plugins for /etc/yum/pluginconf.d/product-id.conf and /etc/yum/pluginconf.d/subscription-manager.conf are NOT automatically enabled by various subscription-manager module commands when rhsm.auto_enable_yum_plugins is configured off.", groups = { "Tier3Tests", "blockedByBug-1319927", "testSubscriptionManagerShouldNotAutomaticallyEnableYumPluginsWhenAutoEnableIsOff" }, dataProvider = "getVariousModuleCommandsData", priority = 100, enabled = true)
public // @ImplementsNitrateTest(caseId=)
void testSubscriptionManagerShouldNotAutomaticallyEnableYumPluginsWhenAutoEnableIsOff(Object blockedByBug, String moduleCommand, Boolean moduleCommandRequiresRegistration) throws IOException {
resetDefaultConfigurationsForYumPluginsAndRhsmAutoEnableYumPlugins();
// decide to register with a random auto-attach option
if (moduleCommandRequiresRegistration) {
clienttasks.unregister(null, null, null, null);
clienttasks.register(sm_clientUsername, sm_clientPassword, sm_clientOrg, null, null, null, null, getRandomBoolean(), null, null, (String) null, null, null, null, null, false, null, null, null, null);
}
// turn off rhsm configuration for auto_enable_yum_plugins
clienttasks.config(false, false, true, new String[] { "rhsm", "auto_enable_yum_plugins", "0" });
// randomly disable one or both /etc/yum/pluginconf.d/product-id.conf and /etc/yum/pluginconf.d/subscription-manager.conf
if (getRandomBoolean()) {
clienttasks.updateConfFileParameter(clienttasks.yumPluginConfFileForProductId, "enabled", "0");
clienttasks.updateConfFileParameter(clienttasks.yumPluginConfFileForSubscriptionManager, "enabled", String.valueOf(getRandInt() % 2));
} else {
clienttasks.updateConfFileParameter(clienttasks.yumPluginConfFileForSubscriptionManager, "enabled", "false");
clienttasks.updateConfFileParameter(clienttasks.yumPluginConfFileForProductId, "enabled", "true");
// TEMPORARY WORKAROUND
boolean invokeWorkaroundWhileBugIsOpen = true;
// Bug 1489917 - disabling yum plugins using "false" (rather than "0") causes traceback: invalid literal for int() with base 10: 'false'
String bugId = "1489917";
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) {
clienttasks.updateConfFileParameter(clienttasks.yumPluginConfFileForSubscriptionManager, "enabled", "0");
clienttasks.updateConfFileParameter(clienttasks.yumPluginConfFileForProductId, "enabled", "1");
}
// END OF WORKAROUND
}
String yumPluginConfFileForProductIdEnabledString = clienttasks.getConfFileParameter(clienttasks.yumPluginConfFileForProductId, "enabled");
String yumPluginConfFileForSubscriptionManagerEnabledString = clienttasks.getConfFileParameter(clienttasks.yumPluginConfFileForSubscriptionManager, "enabled");
Boolean yumPluginConfFileForProductIdEnabled = Boolean.valueOf(yumPluginConfFileForProductIdEnabledString);
Boolean yumPluginConfFileForSubscriptionManagerEnabled = Boolean.valueOf(yumPluginConfFileForSubscriptionManagerEnabledString);
if (yumPluginConfFileForProductIdEnabledString.equals("1")) {
yumPluginConfFileForProductIdEnabled = true;
} else if (yumPluginConfFileForProductIdEnabledString.equals("0")) {
yumPluginConfFileForProductIdEnabled = false;
}
if (yumPluginConfFileForSubscriptionManagerEnabledString.equals("1")) {
yumPluginConfFileForSubscriptionManagerEnabled = true;
} else if (yumPluginConfFileForSubscriptionManagerEnabledString.equals("0")) {
yumPluginConfFileForSubscriptionManagerEnabled = false;
}
// run a subscription-manager moduleCommand
SSHCommandResult results = client.runCommandAndWait(moduleCommand);
// assert the results do NOT contain a WARNING message
// +"\n\n"+"The yum plugins: (PLUGINS) were automatically enabled for the benefit of Red Hat Subscription Management. If not desired, use \"subscription-manager config --rhsm.auto_enable_yum_plugins=0\" to block this behavior.";
String expectedWarningMsg = "WARNING";
Assert.assertTrue(!results.getStdout().contains(expectedWarningMsg), "The stdout from running '" + moduleCommand + "' does NOT contain the expected warning message '" + expectedWarningMsg + "' when at least one yum plugin is disabled and rhsm.auto_enable_yum_plugins is configured off.");
// assert that both plugins were untouched
Assert.assertEquals(clienttasks.getConfFileParameter(clienttasks.yumPluginConfFileForProductId, "enabled"), yumPluginConfFileForProductIdEnabledString, "Enablement of yum config file '" + clienttasks.yumPluginConfFileForProductId + "' should remain unchanged after running '" + moduleCommand + "' with rhsm.auto_enable_yum_plugins configured off.");
Assert.assertEquals(clienttasks.getConfFileParameter(clienttasks.yumPluginConfFileForSubscriptionManager, "enabled"), yumPluginConfFileForSubscriptionManagerEnabledString, "Enablement of yum config file '" + clienttasks.yumPluginConfFileForSubscriptionManager + "' should remain unchanged after running '" + moduleCommand + "' with rhsm.auto_enable_yum_plugins configured off.");
// assert that the yum plugins are/not loaded
// [root@jsefler-rhel7 ~]# yum repolist --disablerepo=*
// Loaded plugins: langpacks, product-id, search-disabled-repos, subscription-
// : manager
// This system is not registered with an entitlement server. You can use subscription-manager to register.
// repolist: 0
String plugin;
String command = "yum repolist --disablerepo=*";
results = client.runCommandAndWait(command);
// (first observed result)
String stdout = results.getStdout();
// join multiple lines of Loaded plugins (second observed result)
stdout = stdout.replaceAll("-\\n\\s+:\\s", "-");
// join multiple lines of Loaded plugins (third observed result)
stdout = stdout.replaceAll(",\\n\\s+:\\s", ", ");
plugin = "product-id";
if (yumPluginConfFileForProductIdEnabled) {
Assert.assertTrue(stdout.contains(plugin), "The stdout from running '" + command + "' indicated that plugin '" + plugin + "' was loaded.");
} else {
Assert.assertTrue(!stdout.contains(plugin), "The stdout from running '" + command + "' indicated that plugin '" + plugin + "' was NOT loaded.");
}
plugin = "subscription-manager";
if (yumPluginConfFileForSubscriptionManagerEnabled) {
Assert.assertTrue(stdout.contains(plugin), "The stdout from running '" + command + "' indicated that plugin '" + plugin + "' was loaded.");
} else {
Assert.assertTrue(!stdout.contains(plugin), "The stdout from running '" + command + "' indicated that plugin '" + plugin + "' was NOT loaded.");
}
}
use of com.redhat.qe.auto.bugzilla.BugzillaAPIException in project rhsm-qe by RedHatQE.
the class MigrationTests method testRhnMigrateClassicToRhsmWithActivationKey.
@// update=true // uncomment to make TestDefinition changes update Polarion testcases through the polarize testcase importer
TestDefinition(projectID = { Project.RHEL6, Project.RedHatEnterpriseLinux7 }, testCaseID = { "RHEL6-20109", "RHEL7-51742" }, 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 migration tool rhn-migrate-classic-to-rhsm with a valid activation-key (and a good org)", groups = { "Tier1Tests", "blockedByBug-1154375", "blockedByBug-1512948", "blockedByBug-1516832" }, enabled = true)
@ImplementsNitrateTest(caseId = 130765)
public void testRhnMigrateClassicToRhsmWithActivationKey() throws Exception {
if (clienttasks.isPackageVersion("subscription-manager", "<", "1.14.1-1"))
throw new SkipException("The --activation-key option was not implemented in this version of subscription-manager.");
// create a valid activation key
// randomly choose a valid available pool for this key
SubscriptionPool pool = getRandomListItem(availableSubscriptionPools);
// choose an activationKey name
String activationKeyName = String.format("activationKeyForOrg_%s_Pool_%s", clientOrgKey, pool.productId);
JSONObject jsonActivationKey = CandlepinTasks.createActivationKeyUsingRESTfulAPI(sm_clientUsername, sm_clientPassword, sm_serverUrl, clientOrgKey, activationKeyName, Arrays.asList(pool.poolId), null);
// register with the activation key
if (false) {
// debugTesting
clienttasks.register_(null, null, clientOrgKey, null, null, null, null, null, null, null, activationKeyName, null, null, null, true, null, null, null, null, null);
clienttasks.unregister_(null, null, null, null);
}
// TEMPORARY WORKAROUND FOR BUG
// Bug 1196416 - rhn-migrate-classic-to-rhsm with --activation-key option should not prompt for destination credentials
String bugId = "1196416";
boolean invokeWorkaroundWhileBugIsOpen = true;
try {
if (invokeWorkaroundWhileBugIsOpen && BzChecker.getInstance().isBugOpen(bugId)) {
log.fine("Invoking workaround for " + BzChecker.getInstance().getBugState(bugId).toString() + " Bugzilla " + bugId + ". (https://bugzilla.redhat.com/show_bug.cgi?id=" + bugId + ")");
SubscriptionManagerCLITestScript.addInvokedWorkaround(bugId);
} else {
invokeWorkaroundWhileBugIsOpen = false;
}
} catch (BugzillaAPIException be) {
/* ignore exception */
} catch (RuntimeException re) {
/* ignore exception */
}
if (invokeWorkaroundWhileBugIsOpen) {
testRhnMigrateClassicToRhsm(null, sm_rhnUsername, sm_rhnPassword, sm_rhnHostname, new ArrayList<String>(), "--activation-key=" + activationKeyName + " " + "--org=" + clientOrgKey, sm_rhnUsername, sm_rhnPassword, sm_clientUsername, sm_clientPassword, null, null, null);
} else
// call RhnMigrateClassicToRhsm_Test with rhsmUsername=null and rhsmPassword=null
// END OF WORKAROUND
// migrate from RHN Classic to RHSM using the activation key
testRhnMigrateClassicToRhsm(null, sm_rhnUsername, sm_rhnPassword, sm_rhnHostname, new ArrayList<String>(), "--activation-key=" + activationKeyName + " " + "--org=" + clientOrgKey, sm_rhnUsername, sm_rhnPassword, null, null, null, null, null);
// assert that the system is consuming the pool from the activation key.
List<ProductSubscription> consumedProductSubscriptions = clienttasks.getCurrentlyConsumedProductSubscriptions();
Assert.assertEquals(consumedProductSubscriptions.size(), 1, "Number of consumed subscriptions after migrating from RHN Classic to RHSM with activation key '" + activationKeyName + "'.");
Assert.assertEquals(consumedProductSubscriptions.get(0).poolId, pool.poolId, "The sole consumed subscription poolId after migrating from RHN Classic to RHSM with activation key '" + activationKeyName + "'.");
}
use of com.redhat.qe.auto.bugzilla.BugzillaAPIException in project rhsm-qe by RedHatQE.
the class MigrationTests method InstallNumMigrateToRhsmWithInstNumber.
protected SSHCommandResult InstallNumMigrateToRhsmWithInstNumber(String instNumber) throws JSONException {
if (!clienttasks.redhatReleaseX.equals("5"))
throw new SkipException("This test is applicable to RHEL5 only.");
if (clienttasks.isPackageVersion("subscription-manager-migration", ">", "1.11.3-4") && clienttasks.redhatReleaseX.equals("5")) {
throw new SkipException("Due to bug 1092754, the migration tool '" + installNumTool + "' has been removed from RHEL5.");
}
String command;
SSHCommandResult result;
// deleting the currently installed product certs
clienttasks.removeAllCerts(false, false, true);
clienttasks.removeAllFacts();
// get the product cert filenames that we should expect install-num-migrate-to-rhsm to copy
List<String> expectedMigrationProductCertFilenames = getExpectedMappedProductCertFilenamesCorrespondingToInstnumberUsingInstnumTool(instNumber);
// test --dryrun --instnumber ................................................
log.info("Testing with the dryrun option...");
command = installNumTool + " --dryrun --instnumber=" + instNumber;
result = RemoteFileTasks.runCommandAndAssert(client, command, 0);
// assert the dryrun
for (String expectedMigrationProductCertFilename : expectedMigrationProductCertFilenames) {
String pemFilename = MigrationDataTests.getPemFileNameFromProductCertFilename(expectedMigrationProductCertFilename);
// String expectedStdoutString = "Copying "+baseProductsDir+"/"+expectedMigrationProductCertFilename+" to "+clienttasks.productCertDir+"/"+pemFilename; // valid prior to Bug 853187 - String Update: install-num-migrate-to-rhsm output
String expectedStdoutString = "Installing " + baseProductsDir + "/" + expectedMigrationProductCertFilename + " to " + clienttasks.productCertDir + "/" + pemFilename;
Assert.assertTrue(result.getStdout().contains(expectedStdoutString), "The dryrun output from " + installNumTool + " contains the expected message: " + expectedStdoutString);
}
int numProductCertFilenamesToBeCopied = 0;
// for (int fromIndex=0; result.getStdout().indexOf("Copying", fromIndex)>=0&&fromIndex>-1; fromIndex=result.getStdout().indexOf("Copying", fromIndex+1)) numProductCertFilenamesToBeCopied++; // valid prior to Bug 853187 - String Update: install-num-migrate-to-rhsm output
for (int fromIndex = 0; result.getStdout().indexOf("Installing", fromIndex) >= 0 && fromIndex > -1; fromIndex = result.getStdout().indexOf("Installing", fromIndex + 1)) numProductCertFilenamesToBeCopied++;
Assert.assertEquals(numProductCertFilenamesToBeCopied, expectedMigrationProductCertFilenames.size(), "The number of product certs to be copied.");
Assert.assertEquals(clienttasks.getCurrentlyInstalledProducts().size(), 0, "A dryrun should NOT install any product certs.");
Map<String, String> factMap = clienttasks.getFacts();
// Note: this if block help reveal bug 840415 - Install-num migration throws traceback for invalid product cert location.
if (clienttasks.productCertDir.equals(nonDefaultProductCertDir)) {
client.runCommandAndWait("rm -rf " + clienttasks.productCertDir);
Assert.assertTrue(!RemoteFileTasks.testExists(client, clienttasks.productCertDir), "The configured rhsm.productCertDir does not exist.");
}
// TEMPORARY WORKAROUND FOR BUG
String bugId = "783278";
boolean invokeWorkaroundWhileBugIsOpen = true;
try {
if (invokeWorkaroundWhileBugIsOpen && BzChecker.getInstance().isBugOpen(bugId)) {
log.fine("Invoking workaround for " + BzChecker.getInstance().getBugState(bugId).toString() + " Bugzilla " + bugId + ". (https://bugzilla.redhat.com/show_bug.cgi?id=" + bugId + ")");
SubscriptionManagerCLITestScript.addInvokedWorkaround(bugId);
} else {
invokeWorkaroundWhileBugIsOpen = false;
}
} catch (BugzillaAPIException be) {
/* ignore exception */
} catch (RuntimeException re) {
/* ignore exception */
}
String bugPkg = "subscription-manager-migration";
// RHEL58
String bugVer = "subscription-manager-migration-0.98";
try {
if (clienttasks.installedPackageVersionMap.get(bugPkg).contains(bugVer) && !invokeWorkaroundWhileBugIsOpen) {
log.fine("Invoking workaround for " + BzChecker.getInstance().getBugState(bugId).toString() + " Bugzilla " + bugId + " which has NOT been fixed in this installed version of " + bugVer + ". (https://bugzilla.redhat.com/show_bug.cgi?id=" + bugId + ")");
SubscriptionManagerCLITestScript.addInvokedWorkaround(bugId);
invokeWorkaroundWhileBugIsOpen = true;
}
} catch (BugzillaAPIException be) {
/* ignore exception */
} catch (RuntimeException re) {
/* ignore exception */
}
if (invokeWorkaroundWhileBugIsOpen) {
log.warning("Skipping the assertion of the fact '" + migrationFromFact + "' fact.");
} else
// END OF WORKAROUND
Assert.assertNull(factMap.get(migrationFromFact), "The migration fact '" + migrationFromFact + "' should NOT be set after running command: " + command);
Assert.assertNull(factMap.get(migrationSystemIdFact), "The migration fact '" + migrationSystemIdFact + "' should NOT be set after running command: " + command);
Assert.assertNull(factMap.get(migrationDateFact), "The migration fact '" + migrationDateFact + "' should NOT be set after running command: " + command);
// test --instnumber ................................................
log.info("Testing without the dryrun option...");
command = installNumTool + " --instnumber=" + instNumber;
result = RemoteFileTasks.runCommandAndAssert(client, command, 0);
// [root@jsefler-onprem-5server ~]# install-num-migrate-to-rhsm --instnumber 0000000e0017fc01
// Copying /usr/share/rhsm/product/RHEL-5/Client-Workstation-x86_64-f812997e0eda-71.pem to /etc/pki/product/71.pem
// Copying /usr/share/rhsm/product/RHEL-5/Client-Client-x86_64-6587edcf1c03-68.pem to /etc/pki/product/68.pem
List<ProductCert> migratedProductCerts = clienttasks.getCurrentProductCerts();
Assert.assertEquals(clienttasks.getCurrentlyInstalledProducts().size(), expectedMigrationProductCertFilenames.size(), "The number of productCerts installed after running migration command: " + command);
for (String expectedMigrationProductCertFilename : expectedMigrationProductCertFilenames) {
ProductCert expectedMigrationProductCert = clienttasks.getProductCertFromProductCertFile(new File(baseProductsDir + "/" + expectedMigrationProductCertFilename));
Assert.assertTrue(migratedProductCerts.contains(expectedMigrationProductCert), "The newly installed product certs includes the expected migration productCert: " + expectedMigrationProductCert);
}
// [root@jsefler-rhel59 ~]# subscription-manager facts --list | grep migration
// migration.install_number: 0000000e0017fc01
// migration.migrated_from: install_number
// migration.migration_date: 2012-08-08T11:11:15.818782
factMap = clienttasks.getFacts();
Assert.assertEquals(factMap.get(migrationFromFact), "install_number", "The migration fact '" + migrationFromFact + "' should be set after running command: " + command);
Assert.assertNull(factMap.get(migrationSystemIdFact), "The migration fact '" + migrationSystemIdFact + "' should NOT be set after running command: " + command);
Assert.assertNotNull(factMap.get(migrationDateFact), "The migration fact '" + migrationDateFact + "' should be set after running command: " + command);
// assert that the migrationDateFact was set within the last few seconds
// tolerance in seconds
int tol = 60;
// NOTE: The .SSS milliseconds was dropped from the date pattern because it was getting confused as seconds from the six digit value in migration.migration_date: 2012-08-08T11:11:15.818782
Calendar migrationDate = parseDateStringUsingDatePattern(factMap.get(migrationDateFact), "yyyy-MM-dd'T'HH:mm:ss", null);
// seconds since 1970-01-01 00:00:00 UTC
long systemTimeInSeconds = Long.valueOf(client.runCommandAndWait("date +%s").getStdout().trim());
long migratTimeInSeconds = migrationDate.getTimeInMillis() / 1000;
Assert.assertTrue(systemTimeInSeconds - tol < migratTimeInSeconds && migratTimeInSeconds < systemTimeInSeconds + tol, "The migration date fact '" + factMap.get(migrationDateFact) + "' was set within the last '" + tol + "' seconds. Actual diff='" + String.valueOf(systemTimeInSeconds - migratTimeInSeconds) + "' seconds.");
return result;
}
use of com.redhat.qe.auto.bugzilla.BugzillaAPIException in project rhsm-qe by RedHatQE.
the class MigrationTests method testInstallNumMigrateToRhsmWithInvalidInstNumber.
@TestDefinition(projectID = {/*Project.RHEL5*/
}, testCaseID = {})
@Test(description = "Execute migration tool install-num-migrate-to-rhsm with a bad length install-num (expecting 16 chars long)", groups = { "Tier3Tests" }, dependsOnMethods = {}, dataProvider = "InstallNumMigrateToRhsmWithInvalidInstNumberData", enabled = true)
@ImplementsNitrateTest(caseId = 130760)
public void testInstallNumMigrateToRhsmWithInvalidInstNumber(Object bugzilla, String command, Integer expectedExitCode, String expectedStdout, String expectedStderr) {
if (!clienttasks.redhatReleaseX.equals("5"))
throw new SkipException("This test is applicable to RHEL5 only.");
if (clienttasks.isPackageVersion("subscription-manager-migration", ">", "1.11.3-4") && clienttasks.redhatReleaseX.equals("5")) {
throw new SkipException("Due to bug 1092754, the migration tool '" + installNumTool + "' has been removed from RHEL5.");
}
SSHCommandResult result = client.runCommandAndWait(command);
if (expectedStdout != null)
Assert.assertEquals(result.getStdout().trim(), expectedStdout, "Stdout from running :" + command);
if (expectedStderr != null)
Assert.assertEquals(result.getStderr().trim(), expectedStderr, "Stderr from running :" + command);
// TEMPORARY WORKAROUND FOR BUG
String bugId = "783542";
boolean invokeWorkaroundWhileBugIsOpen = true;
try {
if (invokeWorkaroundWhileBugIsOpen && BzChecker.getInstance().isBugOpen(bugId)) {
log.fine("Invoking workaround for " + BzChecker.getInstance().getBugState(bugId).toString() + " Bugzilla " + bugId + ". (https://bugzilla.redhat.com/show_bug.cgi?id=" + bugId + ")");
SubscriptionManagerCLITestScript.addInvokedWorkaround(bugId);
} else {
invokeWorkaroundWhileBugIsOpen = false;
}
} catch (BugzillaAPIException be) {
/* ignore exception */
} catch (RuntimeException re) {
/* ignore exception */
}
String bugPkg = "subscription-manager-migration";
// RHEL58
String bugVer = "subscription-manager-migration-0.98";
try {
if (clienttasks.installedPackageVersionMap.get(bugPkg).contains(bugVer) && !invokeWorkaroundWhileBugIsOpen) {
log.fine("Invoking workaround for " + BzChecker.getInstance().getBugState(bugId).toString() + " Bugzilla " + bugId + " which has NOT been fixed in this installed version of " + bugVer + ". (https://bugzilla.redhat.com/show_bug.cgi?id=" + bugId + ")");
SubscriptionManagerCLITestScript.addInvokedWorkaround(bugId);
invokeWorkaroundWhileBugIsOpen = true;
}
} catch (BugzillaAPIException be) {
/* ignore exception */
} catch (RuntimeException re) {
/* ignore exception */
}
if (invokeWorkaroundWhileBugIsOpen) {
log.warning("Skipping the exitCode assertion from running: " + command);
} else // END OF WORKAROUND
if (expectedExitCode != null)
Assert.assertEquals(result.getExitCode(), expectedExitCode, "ExitCode from running :" + command);
}
use of com.redhat.qe.auto.bugzilla.BugzillaAPIException in project rhsm-qe by RedHatQE.
the class MigrationTests method testRhnMigrateClassicToRhsmShouldAutomaticallyEnableYumPluginsWhenAutoEnableIsOn.
@// update=true, // uncomment to make TestDefinition changes update Polarion testcases through the polarize testcase importer
TestDefinition(projectID = { Project.RHEL6, Project.RedHatEnterpriseLinux7 }, testCaseID = { "RHEL6-47943", "RHEL7-109986" }, // role= DefTypes.Role.VERIFIES)},
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 the yum plugins for /etc/yum/pluginconf.d/product-id.conf and /etc/yum/pluginconf.d/subscription-manager.conf are automatically enabled by an execution of rhn-migrate-classic-to-rhsm when rhsm.auto_enable_yum_plugins is configured on.", groups = { "Tier3Tests", "blockedByBug-1466453", "testRhnMigrateClassicToRhsmShouldAutomaticallyEnableYumPluginsWhenAutoEnableIsOn" }, enabled = true)
public // @ImplementsNitrateTest(caseId=)
void testRhnMigrateClassicToRhsmShouldAutomaticallyEnableYumPluginsWhenAutoEnableIsOn() {
// this bug is specifically designed to test Bug 1466453 - [RFE] rhn-migrate-classic-to-rhsm should ensure subscription-manager yum plugin is enabled
if (clienttasks.isPackageVersion("subscription-manager", "<", "1.20.2-1")) {
// commit 7b2b89c7ba4fbf464dd988e12675b2b763007f2c 1466453 - [RFE] rhn-migrate-classic-to-rhsm should ensure subscription-manager yum plugin is enabled
throw new SkipException("This test applies a newer version of subscription-manager that includes an implementation for Bug 1466453 - [RFE] rhn-migrate-classic-to-rhsm should ensure subscription-manager yum plugin is enabled");
}
if (sm_rhnHostname.equals(""))
throw new SkipException("This test requires access to RHN Classic or Satellite 5.");
clienttasks.unregister(null, null, null, null);
resetDefaultConfigurationsForYumPluginsAndRhsmAutoEnableYumPlugins();
// randomly disable one or both /etc/yum/pluginconf.d/product-id.conf and /etc/yum/pluginconf.d/subscription-manager.conf
if (getRandomBoolean()) {
clienttasks.updateConfFileParameter(clienttasks.yumPluginConfFileForProductId, "enabled", "0");
clienttasks.updateConfFileParameter(clienttasks.yumPluginConfFileForSubscriptionManager, "enabled", String.valueOf(getRandInt() % 2));
} else {
clienttasks.updateConfFileParameter(clienttasks.yumPluginConfFileForSubscriptionManager, "enabled", "false");
clienttasks.updateConfFileParameter(clienttasks.yumPluginConfFileForProductId, "enabled", "true");
// TEMPORARY WORKAROUND
boolean invokeWorkaroundWhileBugIsOpen = true;
// Bug 1489917 - disabling yum plugins using "false" (rather than "0") causes traceback: invalid literal for int() with base 10: 'false'
String bugId = "1489917";
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) {
clienttasks.updateConfFileParameter(clienttasks.yumPluginConfFileForSubscriptionManager, "enabled", "0");
clienttasks.updateConfFileParameter(clienttasks.yumPluginConfFileForProductId, "enabled", "1");
}
// END OF WORKAROUND
}
String yumPluginConfFileForProductIdEnabledString = clienttasks.getConfFileParameter(clienttasks.yumPluginConfFileForProductId, "enabled");
String yumPluginConfFileForSubscriptionManagerEnabledString = clienttasks.getConfFileParameter(clienttasks.yumPluginConfFileForSubscriptionManager, "enabled");
Boolean yumPluginConfFileForProductIdEnabled = Boolean.valueOf(yumPluginConfFileForProductIdEnabledString);
Boolean yumPluginConfFileForSubscriptionManagerEnabled = Boolean.valueOf(yumPluginConfFileForSubscriptionManagerEnabledString);
if (yumPluginConfFileForProductIdEnabledString.equals("1")) {
yumPluginConfFileForProductIdEnabled = true;
} else if (yumPluginConfFileForProductIdEnabledString.equals("0")) {
yumPluginConfFileForProductIdEnabled = false;
}
if (yumPluginConfFileForSubscriptionManagerEnabledString.equals("1")) {
yumPluginConfFileForSubscriptionManagerEnabled = true;
} else if (yumPluginConfFileForSubscriptionManagerEnabledString.equals("0")) {
yumPluginConfFileForSubscriptionManagerEnabled = false;
}
// register to rhn classic
String rhnSystemId = clienttasks.registerToRhnClassic(sm_rhnUsername, sm_rhnPassword, sm_rhnHostname);
// attempt to run rhn-migrate-classic-to-rhsm
String options = "";
SSHCommandResult sshCommandResult = executeRhnMigrateClassicToRhsm(options, sm_rhnUsername, sm_rhnPassword, sm_clientUsername, sm_clientPassword, sm_clientOrg, null, null);
String command = "rhn-migrate-classic-to-rhsm";
// [root@jsefler-rhel7 ~]# rhn-migrate-classic-to-rhsm --legacy-user=rhsm-client --destination-user=testuser1
// Legacy password:
// Destination password:
// Org: admin
//
// Retrieving existing legacy subscription information...
//
// +-----------------------------------------------------+
// System is currently subscribed to these legacy channels:
// +-----------------------------------------------------+
// rhel-x86_64-server-7
//
// +-----------------------------------------------------+
// Installing product certificates for these legacy channels:
// +-----------------------------------------------------+
// rhel-x86_64-server-7
//
// Product certificates installed successfully to /etc/pki/product.
//
// Preparing to unregister system from legacy server...
// System successfully unregistered from legacy server.
// Stopping and disabling legacy services...
// rhnsd.service is not a native service, redirecting to /sbin/chkconfig.
// Executing /sbin/chkconfig rhnsd off
//
// Attempting to register system to destination server...
// WARNING
//
// The yum plugins: /etc/yum/pluginconf.d/subscription-manager.conf were automatically enabled for the benefit of Red Hat Subscription Management. If not desired, use "subscription-manager config --rhsm.auto_enable_yum_plugins=0" to block this behavior.
//
// Registering to: jsefler-candlepin.usersys.redhat.com:8443/candlepin
// The system has been registered with ID: ed2d6c19-bde5-4e8c-b274-109d8d477723
// The registered system name is: jsefler-rhel7.usersys.redhat.com
// Installed Product Current Status:
//
// Product Name: Red Hat Enterprise Linux Server
// Status: Not Subscribed
//
// Unable to find available subscriptions for all your installed products.
// System 'jsefler-rhel7.usersys.redhat.com' successfully registered.
//
// [root@jsefler-rhel7 ~]# echo $?
// 0
// verify the migration was successful
// WARNING: asserting this exit code is misleading because it is the exit code from the rhn-migrate-classic-to-rhsm.tcl script which is a wrapper to rhn-migrate-classic-to-rhsm which could exit with a different code
Assert.assertEquals(sshCommandResult.getExitCode(), Integer.valueOf(0), "ExitCode from call to '" + rhnMigrateTool + "' after attempting to migrate with options '" + options + "'.");
// verify that we are newly registered to RHSM
Assert.assertNotNull(clienttasks.getCurrentConsumerCert(), "Confirmed that the system is newly registered with Subscription Manager after migrating from RHN Classic using '" + rhnMigrateTool + "'.");
// assert the results contain the expected WARNING message for enabling plugins
String expectedWarningMsg = "WARNING" + "\n\n" + "The yum plugins: PLUGINS were automatically enabled for the benefit of Red Hat Subscription Management. If not desired, use \"subscription-manager config --rhsm.auto_enable_yum_plugins=0\" to block this behavior.";
// ensure expectedWarningMsg appears on it's own line
expectedWarningMsg = "\n" + expectedWarningMsg + "\n";
if (!yumPluginConfFileForSubscriptionManagerEnabled)
expectedWarningMsg = expectedWarningMsg.replaceFirst("PLUGINS", clienttasks.yumPluginConfFileForSubscriptionManager + ", PLUGINS");
if (!yumPluginConfFileForProductIdEnabled)
expectedWarningMsg = expectedWarningMsg.replaceFirst("PLUGINS", clienttasks.yumPluginConfFileForProductId + ", PLUGINS");
// strip out my regex substring
expectedWarningMsg = expectedWarningMsg.replaceFirst(", PLUGINS", "");
Assert.assertTrue(sshCommandResult.getStdout().contains(expectedWarningMsg), "The stdout from running '" + command + "' contains the expected warning message '" + expectedWarningMsg + "' when at least one yum plugin is disabled and rhsm.auto_enable_yum_plugins is configured on.");
// assert that both plugins were enabled
String enabledValue;
enabledValue = clienttasks.getConfFileParameter(clienttasks.yumPluginConfFileForProductId, "enabled");
Assert.assertTrue(enabledValue.toLowerCase().matches("1|true"), "Expecting yum config file '" + clienttasks.yumPluginConfFileForProductId + "' to be enabled after running '" + command + "' with rhsm.auto_enable_yum_plugins configured on. Actual enabled=" + enabledValue);
enabledValue = clienttasks.getConfFileParameter(clienttasks.yumPluginConfFileForSubscriptionManager, "enabled");
Assert.assertTrue(enabledValue.toLowerCase().matches("1|true"), "Expecting yum config file '" + clienttasks.yumPluginConfFileForSubscriptionManager + "' to be enabled after running '" + command + "' with rhsm.auto_enable_yum_plugins configured on. Actual enabled=" + enabledValue);
}
Aggregations