Search in sources :

Example 1 with BeforeGroups

use of org.testng.annotations.BeforeGroups 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);
    }
}
Also used : JSONObject(org.json.JSONObject) JSONArray(org.json.JSONArray) AfterGroups(org.testng.annotations.AfterGroups) BeforeGroups(org.testng.annotations.BeforeGroups)

Example 2 with BeforeGroups

use of org.testng.annotations.BeforeGroups in project teammates by TEAMMATES.

the class AdminEmailLogPageActionTest method removeAndRestoreManyLogs.

@BeforeGroups("manyEmailLogs")
public void removeAndRestoreManyLogs() {
    gaeSimulation.loginAsAdmin("admin");
    gaeSimulation.clearLogs();
    Date today = TimeHelper.getDateOffsetToCurrentTime(0);
    insertLogMessageAtTimeWithInterval(logMessages.get(LOG_MESSAGE_INDEX_MANY_LOGS), today.getTime(), LOG_MESSAGE_INTERVAL_MANY_LOGS);
}
Also used : Date(java.util.Date) BeforeGroups(org.testng.annotations.BeforeGroups)

Example 3 with BeforeGroups

use of org.testng.annotations.BeforeGroups in project teammates by TEAMMATES.

the class AdminEmailLogPageActionTest method removeAndRestoreLogMessage.

@BeforeGroups("typicalEmailLogs")
public void removeAndRestoreLogMessage() {
    gaeSimulation.loginAsAdmin("admin");
    gaeSimulation.clearLogs();
    Date twoDaysAgo = TimeHelper.getDateOffsetToCurrentTime(-2);
    insertLogMessagesAtTime(logMessages.get(LOG_MESSAGE_INDEX_TWO_DAYS_AGO), twoDaysAgo.getTime());
    Date yesterday = TimeHelper.getDateOffsetToCurrentTime(-1);
    insertLogMessagesAtTime(logMessages.get(LOG_MESSAGE_INDEX_YESTERDAY), yesterday.getTime());
    Date today = TimeHelper.getDateOffsetToCurrentTime(0);
    insertLogMessagesAtTime(logMessages.get(LOG_MESSAGE_INDEX_TODAY), today.getTime());
}
Also used : Date(java.util.Date) BeforeGroups(org.testng.annotations.BeforeGroups)

Example 4 with BeforeGroups

use of org.testng.annotations.BeforeGroups in project rhsm-qe by RedHatQE.

the class CertificateTests method findAllRhelProductCertsFromRhnDefinitions.

@BeforeGroups(groups = "setup", value = { "VerifyBaseRHELProductCertVersionUpdates_Test" })
protected void findAllRhelProductCertsFromRhnDefinitions() {
    // assemble a list of rhnDefinitionsProductCertsDirs that we care about under [rcm/rcm-metadata.git] / product_ids /
    // Note: we care about all of the productCertsDirs
    SSHCommandResult result = client.runCommandAndWait("find " + clienttasks.rhnDefinitionsDir + "/product_ids -maxdepth 1 -type d");
    List<String> rhnDefinitionsProductCertsDirs = new ArrayList<String>();
    for (String productIdsDir : result.getStdout().split("\\n")) {
        if (!productIdsDir.equals(clienttasks.rhnDefinitionsDir + "/product_ids")) {
            // http://git.app.eng.bos.redhat.com/git/rcm/rcm-metadata.git/tree/product_ids
            if (!productIdsDir.contains("/rhel-" + clienttasks.redhatReleaseX + "."))
                continue;
            rhnDefinitionsProductCertsDirs.add(productIdsDir);
        }
    }
    Assert.assertTrue(!rhnDefinitionsProductCertsDirs.isEmpty(), "The " + clienttasks.rhnDefinitionsDir + "/product_ids is not empty.");
    // process all the migration product cert files into ProductCerts and assert they match those from the RHN Definitions
    // get all of the rhnDefnition product certs
    rhelProductCertsFromRhnDefinition.clear();
    for (String rhnDefinitionsProductCertsDir : /*sm_*/
    rhnDefinitionsProductCertsDirs) {
        String tmpRhnDefinitionsProductCertsDir = /*clienttasks.rhnDefinitionsDir+*/
        rhnDefinitionsProductCertsDir;
        Assert.assertTrue(RemoteFileTasks.testExists(client, tmpRhnDefinitionsProductCertsDir), "The rhn definitions product certs dir '" + rhnDefinitionsProductCertsDir + "' has been locally cloned to '" + tmpRhnDefinitionsProductCertsDir + "'.");
        rhelProductCertsFromRhnDefinition.addAll(clienttasks.getProductCerts(tmpRhnDefinitionsProductCertsDir));
    }
}
Also used : SSHCommandResult(com.redhat.qe.tools.SSHCommandResult) ArrayList(java.util.ArrayList) BeforeGroups(org.testng.annotations.BeforeGroups)

Example 5 with BeforeGroups

use of org.testng.annotations.BeforeGroups in project rhsm-qe by RedHatQE.

the class ComplianceTests method configureProductCertDirForAllProductsSubscribableByOneCommonServiceLevel.

@BeforeGroups(groups = { "setup" }, value = "configureProductCertDirForAllProductsSubscribableByOneCommonServiceLevel")
public void configureProductCertDirForAllProductsSubscribableByOneCommonServiceLevel() {
    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", productCertDirForAllProductsSubscribableByOneCommonServiceLevel);
    SSHCommandResult r = client.runCommandAndWait("ls -1 " + productCertDirForAllProductsSubscribableByOneCommonServiceLevel + " | wc -l");
    if (Integer.valueOf(r.getStdout().trim()) == 0)
        throw new SkipException("Could not find any installed product certs that are autosubscribable via one common service level.");
    Assert.assertTrue(Integer.valueOf(r.getStdout().trim()) > 0, "The " + clienttasks.rhsmConfFile + " file is currently configured with a productCertDir that contains all autosubscribable products via one common service level.");
    configureProductCertDirForAllProductsSubscribableByOneCommonServiceLevelCompleted = true;
}
Also used : SSHCommandResult(com.redhat.qe.tools.SSHCommandResult) SkipException(org.testng.SkipException) BugzillaAPIException(com.redhat.qe.auto.bugzilla.BugzillaAPIException) BeforeGroups(org.testng.annotations.BeforeGroups)

Aggregations

BeforeGroups (org.testng.annotations.BeforeGroups)21 SSHCommandResult (com.redhat.qe.tools.SSHCommandResult)11 BugzillaAPIException (com.redhat.qe.auto.bugzilla.BugzillaAPIException)7 SkipException (org.testng.SkipException)7 Series (com.axibase.tsd.api.model.series.Series)4 File (java.io.File)4 ArrayList (java.util.ArrayList)4 Sample (com.axibase.tsd.api.model.series.Sample)2 Date (java.util.Date)2 JSONObject (org.json.JSONObject)2 BigDecimal (java.math.BigDecimal)1 BigInteger (java.math.BigInteger)1 Connection (java.sql.Connection)1 HashMap (java.util.HashMap)1 JSONArray (org.json.JSONArray)1 AfterGroups (org.testng.annotations.AfterGroups)1