use of org.testng.annotations.AfterGroups in project rhsm-qe by RedHatQE.
the class SKULevelContentOverrideTests method removeContentOverridesFromSubscriptionPoolProductIdsTested.
/**
* cleanup after running OverrideAtSKULevelTest by removing all of the
* content overrides for the SKUs tested above
*
* @throws JSONException
* @throws Exception
* @author jsefler
*/
@BeforeGroups(groups = "setup", value = { "OverrideAtSKULevelTest" }, enabled = true)
@AfterGroups(groups = "cleaup", value = { "OverrideAtSKULevelTest" }, enabled = true)
public void removeContentOverridesFromSubscriptionPoolProductIdsTested() throws JSONException, Exception {
String ownerKey = clienttasks.getCurrentlyRegisteredOwnerKey();
for (String subscriptionPoolProductIdTested : subscriptionPoolProductIdsTested) {
String productIdPath = "/owners/" + ownerKey + "/products/" + subscriptionPoolProductIdTested + "?exclude=id&exclude=name&exclude=multiplier&exclude=productContent&exclude=dependentProductIds&exclude=href&exclude=created&exclude=updated&exclude=attributes.created&exclude=attributes.updated";
JSONObject jsonProductId = new JSONObject(CandlepinTasks.getResourceUsingRESTfulAPI(sm_serverAdminUsername, sm_serverAdminPassword, sm_serverUrl, productIdPath));
JSONArray jsonProductIdAttributes = jsonProductId.getJSONArray("attributes");
jsonProductIdAttributes = purgeJSONObjectNamesFromJSONArray(jsonProductIdAttributes, "content_override_enabled");
jsonProductIdAttributes = purgeJSONObjectNamesFromJSONArray(jsonProductIdAttributes, "content_override_disabled");
productIdPath = "/owners/" + ownerKey + "/products/" + subscriptionPoolProductIdTested;
JSONObject jsonAttributes = new JSONObject();
jsonAttributes.put("attributes", jsonProductIdAttributes);
CandlepinTasks.putResourceUsingRESTfulAPI(sm_serverAdminUsername, sm_serverAdminPassword, sm_serverUrl, productIdPath, jsonAttributes);
CandlepinTasks.refreshPoolsUsingRESTfulAPI(sm_serverAdminUsername, sm_serverAdminPassword, sm_serverUrl, ownerKey);
}
}
use of org.testng.annotations.AfterGroups in project rhsm-qe by RedHatQE.
the class AutoAttachDisabledByOwnerTests method setautobindDisabledToFalse.
@AfterGroups(groups = "setup", value = { "DisableOwner" }, enabled = true)
public void setautobindDisabledToFalse() throws Exception {
JSONObject jsonData = new JSONObject();
String resourcePath = "/owners/" + owner;
jsonData.put("autobindDisabled", "false");
CandlepinTasks.putResourceUsingRESTfulAPI(sm_serverAdminUsername, sm_serverAdminPassword, sm_serverUrl, resourcePath, jsonData);
}
use of org.testng.annotations.AfterGroups in project rhsm-qe by RedHatQE.
the class BugzillaTests method cleanupAfterVerifyVirtOnlyPoolsRemoved.
// FIXME This method appears to be abandoned
@AfterGroups(groups = "setup", value = { "VerifyVirtOnlyPoolsRemoved" }, enabled = true)
public void cleanupAfterVerifyVirtOnlyPoolsRemoved() throws Exception {
// TODO This is not completely accurate, but it is a good place to
// cleanup after VerifyVirtOnlyPoolsRemoved...
CandlepinTasks.deleteResourceUsingRESTfulAPI(sm_serverAdminUsername, sm_serverAdminPassword, sm_serverUrl, "/subscriptions/" + "virtualPool");
String resourcePath = "/products/virtual-pool";
if (SubscriptionManagerTasks.isVersion(servertasks.statusVersion, ">=", "2.0.0"))
resourcePath = "/owners/" + sm_clientOrg + resourcePath;
CandlepinTasks.deleteResourceUsingRESTfulAPI(sm_serverAdminUsername, sm_serverAdminPassword, sm_serverUrl, resourcePath);
JSONObject jobDetail = CandlepinTasks.refreshPoolsUsingRESTfulAPI(sm_serverAdminUsername, sm_serverAdminPassword, sm_serverUrl, sm_clientOrg);
jobDetail = CandlepinTasks.waitForJobDetailStateUsingRESTfulAPI(sm_serverAdminUsername, sm_serverAdminPassword, sm_serverUrl, jobDetail, "FINISHED", 5 * 1000, 1);
}
use of org.testng.annotations.AfterGroups in project rhsm-qe by RedHatQE.
the class SubscriptionManagerCLITestScript method restoreProductCertsAfterThisTest.
@AfterGroups(groups = { "setup" }, value = { // list of individual tests that could cause the product-id yum plugin to install a productid from the CDN repodata that you want to remove after the test
"testWithNotifyOnlyOffVerifyYumSearchDisabledReposAssumingYesResponses", "testWithNotifyOnlyOffVerifyYumSearchDisabledReposWithYesYesNoResponses", "testInstallAndRemoveAnyPackageFromEnabledRepoAfterSubscribingToPool", "testInstallAndRemoveYumGroupFromEnabledRepoAfterSubscribingToPool", "testYumInstallSucceedsWhenServiceRsyslogIsStopped" }, alwaysRun = true)
public void restoreProductCertsAfterThisTest() {
if (clienttasks == null)
return;
List<ProductCert> productCertsAfterThisTest = clienttasks.getCurrentProductCerts();
// Extraneous RHEL product certs are easily possible especially on a HTB installation as explained in https://bugzilla.redhat.com/show_bug.cgi?id=1538957#c5
for (ProductCert productCertAfterThisTest : productCertsAfterThisTest) {
for (ProductCert productCertBeforeThisTest : productCertsBeforeThisTest) {
// do nothing when this productCertAfterTest was also present BeforeTest
if (productCertBeforeThisTest.file.equals(productCertAfterThisTest.file))
continue;
// do nothing if this productCertAfterTest is located in the default directory
if (productCertAfterThisTest.file.getPath().startsWith(clienttasks.productCertDefaultDir))
continue;
// TEMPORARY WORKAROUND
if (doesStringContainMatches(productCertAfterThisTest.productNamespace.providedTags, "rhel-" + clienttasks.redhatReleaseX + "(,|$)")) {
boolean invokeWorkaroundWhileBugIsOpen = true;
// Bug 1525238 - yum plugin for productid neglects to remove HTB product cert from /etc/pki/product/ because it is tagged as a provider of "rhel-7"
String bugId = "1525238";
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) {
log.warning("Removing product cert '" + productCertAfterThisTest.productName + " " + productCertAfterThisTest.file + "' from restoreProductCertsAfterThisTest() while bug '" + bugId + "' is open.");
}
}
// END OF WORKAROUND
// remove the product cert
log.info("Removing product cert '" + productCertAfterThisTest.productName + " " + productCertAfterThisTest.file + "' from restoreProductCertsAfterThisTest().");
client.runCommandAndWait("rm -f " + productCertAfterThisTest.file);
}
}
// clear the protected variable
productCertsBeforeThisTest.clear();
productCertsBeforeThisTest = null;
}
use of org.testng.annotations.AfterGroups in project rhsm-qe by RedHatQE.
the class RegisterTests method generateRegistrationReportTableAfterRegisterWithCredentials_Test.
@AfterGroups(value = { "RegisterWithCredentials_Test" }, alwaysRun = true)
public void generateRegistrationReportTableAfterRegisterWithCredentials_Test() {
// now dump out the list of userData to a file
// this will be in the automation.dir directory on hudson (workspace/automatjon/sm)
File file = new File("test-output/registration_report.html");
DateFormat dateFormat = new SimpleDateFormat("MMM d HH:mm:ss yyyy z");
try {
Writer output = new BufferedWriter(new FileWriter(file));
// write out the rows of the table
output.write("<html>\n");
output.write("<table border=1>\n");
output.write("<h2>Candlepin Registration Report</h2>\n");
// output.write("<h3>(generated on "+dateFormat.format(System.currentTimeMillis())+")</h3>");
output.write("Candlepin hostname= <b>" + sm_serverHostname + "</b><br>\n");
output.write(dateFormat.format(System.currentTimeMillis()) + "\n");
output.write("<tr><th>Username/<BR>Password</th><th>OrgKey</th><th>Register Result</th><th>All Available Subscriptions<BR>(to system consumers)</th></tr>\n");
for (RegistrationData registeredConsumer : registrationDataList) {
if (registeredConsumer.ownerKey == null) {
output.write("<tr bgcolor=#F47777>");
} else {
output.write("<tr>");
}
if (registeredConsumer.username != null) {
output.write("<td valign=top>" + registeredConsumer.username + "/<BR>" + registeredConsumer.password + "</td>");
} else {
output.write("<td/>");
}
;
if (registeredConsumer.ownerKey != null) {
output.write("<td valign=top>" + registeredConsumer.ownerKey + "</td>");
} else {
output.write("<td/>");
}
;
if (registeredConsumer.registerResult != null) {
output.write("<td valign=top>" + registeredConsumer.registerResult.getStdout() + registeredConsumer.registerResult.getStderr() + "</td>");
} else {
output.write("<td/>");
}
;
if (registeredConsumer.allAvailableSubscriptionPools != null) {
output.write("<td valign=top><ul>");
for (SubscriptionPool availableSubscriptionPool : registeredConsumer.allAvailableSubscriptionPools) {
output.write("<li>" + availableSubscriptionPool + "</li>");
}
output.write("</ul></td>");
} else {
output.write("<td/>");
}
;
output.write("</tr>\n");
}
output.write("</table>\n");
output.write("</html>\n");
output.close();
// log.info(file.getCanonicalPath()+" exists="+file.exists()+" writable="+file.canWrite());
} catch (IOException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
}
Aggregations