use of org.testng.annotations.BeforeGroups in project rhsm-qe by RedHatQE.
the class ComplianceTests method configureProductCertDirForSomeProductsSubscribable.
@BeforeGroups(groups = { "setup" }, value = "configureProductCertDirForSomeProductsSubscribable")
public void configureProductCertDirForSomeProductsSubscribable() {
clienttasks.unregister(null, null, null, null);
// TEMPORARY WORKAROUND FOR BUG: Bug 1183175 - changing to a different rhsm.productcertdir configuration throws OSError: [Errno 17] File exists
boolean invokeWorkaroundWhileBugIsOpen = true;
String bugId = "1183175";
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("Cannot configure a different productCertDir while bug '" + bugId + "' is open.");
}
// END OF WORKAROUND
clienttasks.updateConfFileParameter(clienttasks.rhsmConfFile, "productCertDir", productCertDirForSomeProductsSubscribable);
SSHCommandResult r0 = client.runCommandAndWait("ls -1 " + productCertDirForSomeProductsSubscribable + " | wc -l");
SSHCommandResult r1 = client.runCommandAndWait("ls -1 " + productCertDirForAllProductsSubscribable + " | wc -l");
SSHCommandResult r2 = client.runCommandAndWait("ls -1 " + productCertDirForNoProductsSubscribable + " | wc -l");
if (Integer.valueOf(r1.getStdout().trim()) == 0)
throw new SkipException("Could not find any installed product certs that are subscribable based on the currently available subscriptions.");
if (Integer.valueOf(r2.getStdout().trim()) == 0)
throw new SkipException("Could not find any installed product certs that are non-subscribable based on the currently available subscriptions.");
Assert.assertTrue(Integer.valueOf(r0.getStdout().trim()) > 0 && Integer.valueOf(r1.getStdout().trim()) > 0 && Integer.valueOf(r2.getStdout().trim()) > 0, "The " + clienttasks.rhsmConfFile + " file is currently configured with a productCertDir that contains some subscribable products based on the currently available subscriptions.");
configureProductCertDirForSomeProductsSubscribableCompleted = true;
}
use of org.testng.annotations.BeforeGroups in project rhsm-qe by RedHatQE.
the class ComplianceTests method configureProductCertDirForNoProductsInstalled.
@BeforeGroups(groups = { "setup" }, value = "configureProductCertDirForNoProductsInstalled")
public void configureProductCertDirForNoProductsInstalled() {
clienttasks.unregister(null, null, null, null);
// TEMPORARY WORKAROUND FOR BUG: Bug 1183175 - changing to a different rhsm.productcertdir configuration throws OSError: [Errno 17] File exists
boolean invokeWorkaroundWhileBugIsOpen = true;
String bugId = "1183175";
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("Cannot configure a different productCertDir while bug '" + bugId + "' is open.");
}
// END OF WORKAROUND
clienttasks.updateConfFileParameter(clienttasks.rhsmConfFile, "productCertDir", productCertDirForNoProductsinstalled);
SSHCommandResult r = client.runCommandAndWait("ls -1 " + productCertDirForNoProductsinstalled + " | wc -l");
Assert.assertEquals(Integer.valueOf(r.getStdout().trim()), Integer.valueOf(0), "The " + clienttasks.rhsmConfFile + " file is currently configured with a productCertDir that contains no products.");
configureProductCertDirForNoProductsInstalledCompleted = true;
}
use of org.testng.annotations.BeforeGroups in project rhsm-qe by RedHatQE.
the class ComplianceTests method configureProductCertDirForAllProductsSubscribable.
@BeforeGroups(groups = { "setup" }, value = "configureProductCertDirForAllProductsSubscribable")
public void configureProductCertDirForAllProductsSubscribable() {
clienttasks.unregister(null, null, null, null);
// TEMPORARY WORKAROUND FOR BUG: Bug 1183175 - changing to a different rhsm.productcertdir configuration throws OSError: [Errno 17] File exists
boolean invokeWorkaroundWhileBugIsOpen = true;
String bugId = "1183175";
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("Cannot configure a different productCertDir while bug '" + bugId + "' is open.");
}
// END OF WORKAROUND
clienttasks.updateConfFileParameter(clienttasks.rhsmConfFile, "productCertDir", productCertDirForAllProductsSubscribable);
SSHCommandResult r = client.runCommandAndWait("ls -1 " + productCertDirForAllProductsSubscribable + " | wc -l");
if (Integer.valueOf(r.getStdout().trim()) == 0)
throw new SkipException("Could not find any installed product certs that are subscribable based on the currently available subscriptions.");
Assert.assertTrue(Integer.valueOf(r.getStdout().trim()) > 0, "The " + clienttasks.rhsmConfFile + " file is currently configured with a productCertDir that contains all subscribable products based on the currently available subscriptions.");
configureProductCertDirForAllProductsSubscribableCompleted = true;
}
use of org.testng.annotations.BeforeGroups in project rhsm-qe by RedHatQE.
the class PluginTests method configureRhelProductCertDirBeforeGroups.
@BeforeGroups(groups = { "setup" }, value = "verifyEnabledAutoAttachTestPluginHooksAreCalled_Test")
public void configureRhelProductCertDirBeforeGroups() {
// This BeforeGroups is really a WORKAROUND FOR BUG 964332
if (clienttasks == null)
return;
productCertDirBeforeAttachTestPluginHooks = clienttasks.productCertDir;
client.runCommandAndWait("rm -rf " + productCertDirForAutoAttachTestPluginHooks + " && mkdir " + productCertDirForAutoAttachTestPluginHooks);
for (File productCertFile : clienttasks.getCurrentProductCertFiles(null)) {
if (!productCertFile.getPath().endsWith("_.pem")) {
client.runCommandAndWait("cp " + productCertFile + " " + productCertDirForAutoAttachTestPluginHooks);
}
}
clienttasks.updateConfFileParameter(clienttasks.rhsmConfFile, "productCertDir", productCertDirForAutoAttachTestPluginHooks);
}
use of org.testng.annotations.BeforeGroups in project rhsm-qe by RedHatQE.
the class PluginTests method fetchAndDisableAllPluginsBeforeGroups.
@BeforeGroups(groups = { "setup" }, value = "DisabledPluginTests")
protected void fetchAndDisableAllPluginsBeforeGroups() {
if (clienttasks == null)
return;
SSHCommandResult result;
// fetch the test-plugins files
if (sm_testpluginsUrl.isEmpty())
return;
log.info("Fetching test plugins from " + sm_testpluginsUrl + " for use by this test class...");
RemoteFileTasks.runCommandAndAssert(client, "cd " + testPluginDir + " && wget --quiet --recursive --no-host-directories --cut-dirs=2 --no-parent --accept .py " + sm_testpluginsUrl, Integer.valueOf(0));
// Note: If above fails with exitCode 8, then the auto-services server needs changes to /etc/httpd/conf/httpd.conf remove AddHandler .py from mime_module and restart the httpd service
RemoteFileTasks.runCommandAndAssert(client, "cd " + testPluginConfDir + " && wget --quiet --recursive --no-host-directories --cut-dirs=2 --no-parent --accept .conf " + sm_testpluginsUrl, Integer.valueOf(0));
// create plugin objects for simplicity
result = RemoteFileTasks.runCommandAndAssert(client, "find " + testPluginConfDir + " -name *.conf", 0);
for (String pluginConfPathname : result.getStdout().trim().split("\\s*\\n\\s*")) {
if (pluginConfPathname.isEmpty())
continue;
File examplePluginConfFile = new File(testPluginConfDir + "/" + new File(pluginConfPathname).getName());
File examplePluginFile = new File(testPluginDir + "/" + examplePluginConfFile.getName().split("\\.")[0] + ".py");
installedPlugins.add(new Plugin(examplePluginConfFile, examplePluginFile));
}
// disable all of the plugin configurations
for (Plugin installedPlugin : installedPlugins) {
clienttasks.updateConfFileParameter(installedPlugin.configFile.getPath(), "enabled", "0");
}
}
Aggregations