Search in sources :

Example 6 with BeforeGroups

use of org.testng.annotations.BeforeGroups in project atsd-api-test by axibase.

the class LimitTest method prepareEntityOrderData.

@BeforeGroups(groups = { ENTITY_ORDER_TEST_GROUP })
public void prepareEntityOrderData() throws Exception {
    List<Series> seriesList = new ArrayList<>();
    for (int i = 1; i < 10; i++) {
        long date = Util.getUnixTime("2016-06-19T11:00:00.000Z");
        Series series = new Series(entity(), ENTITY_ORDER_METRIC);
        for (int j = 0; j < 10 - i; j++) {
            Sample sample = Sample.ofDateInteger(Util.ISOFormat(date + j * TimeUnit.HOURS.toMillis(1)), j);
            series.addSamples(sample);
        }
        seriesList.add(series);
    }
    SeriesMethod.insertSeriesCheck(seriesList);
}
Also used : Series(com.axibase.tsd.api.model.series.Series) Sample(com.axibase.tsd.api.model.series.Sample) ArrayList(java.util.ArrayList) BeforeGroups(org.testng.annotations.BeforeGroups)

Example 7 with BeforeGroups

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

the class DevSKUTests method installGenericProductCert.

@BeforeGroups(groups = "setup", value = { "VerifyAutosubscribedDevSkuWithAnUnknownProductInstalled_Test" })
public void installGenericProductCert() throws JSONException, Exception {
    // save time and copy the generic product cert to the client when it already exists within this testware (needed for testing against hosted)
    String filename = "generic.pem";
    File genericFile = new File(System.getProperty("automation.dir", null) + "/certs/" + filename);
    genericCertFilePath = clienttasks.productCertDir.replaceFirst("/*$", "/") + filename;
    // make it end in _.pem by convention to help identify fake product certs
    genericCertFilePath = genericCertFilePath.replaceFirst("_?\\.pem$", "_.pem");
    if (genericFile.exists()) {
        RemoteFileTasks.putFile(client, genericFile.toString(), genericCertFilePath, "0644");
        return;
    }
    if (server == null) {
        log.warning("Skipping createGenericProductCert() when server is null.");
        return;
    }
    String productId = "88888888";
    String name = "Generic OS Product";
    String resourcePath = "/products/" + productId;
    if (SubscriptionManagerTasks.isVersion(servertasks.statusVersion, ">=", "2.0.0"))
        resourcePath = "/owners/" + sm_clientOrg + resourcePath;
    // delete the product
    CandlepinTasks.deleteResourceUsingRESTfulAPI(sm_serverAdminUsername, sm_serverAdminPassword, sm_serverUrl, resourcePath);
    // create the product
    Map<String, String> attributes = new HashMap<String, String>();
    attributes.put("name", name);
    attributes.put("version", "8.8 Alpha");
    attributes.put("arch", "ALL");
    // equivalent to ALL
    attributes.put("arch", "x86_64,ia64,x86,ppc,ppc64,ppcle64,s390,s390x,aarch64");
    // TODO	this is not the correct way to set tags
    attributes.put("tags", "genos");
    attributes.put("brand_type", "OS");
    // TODO this is not the correct way to set brand name
    attributes.put("brand_name", "Generic Branding");
    // indicative of an engineering product
    attributes.put("type", "SVC");
    CandlepinTasks.createProductUsingRESTfulAPI(sm_serverAdminUsername, sm_serverAdminPassword, sm_serverUrl, sm_clientOrg, name, productId, 1, attributes, null);
    // now install the product certificate
    JSONObject jsonProductCert = new JSONObject(CandlepinTasks.getResourceUsingRESTfulAPI(sm_serverAdminUsername, sm_serverAdminPassword, sm_serverUrl, resourcePath + "/certificate"));
    String cert = jsonProductCert.getString("cert");
    String key = jsonProductCert.getString("key");
    client.runCommandAndWait("echo \"" + cert + "\" > " + genericCertFilePath);
    // delete the product since our goal was to simply to create and install a generic product cert
    CandlepinTasks.deleteResourceUsingRESTfulAPI(sm_serverAdminUsername, sm_serverAdminPassword, sm_serverUrl, resourcePath);
}
Also used : JSONObject(org.json.JSONObject) HashMap(java.util.HashMap) File(java.io.File) BeforeGroups(org.testng.annotations.BeforeGroups)

Example 8 with BeforeGroups

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

the class ComplianceTests method configureProductCertDirForNoProductsSubscribable.

@BeforeGroups(groups = { "setup" }, value = "configureProductCertDirForNoProductsSubscribable")
public void configureProductCertDirForNoProductsSubscribable() {
    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", productCertDirForNoProductsSubscribable);
    SSHCommandResult r = client.runCommandAndWait("ls -1 " + productCertDirForNoProductsSubscribable + " | wc -l");
    if (Integer.valueOf(r.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(r.getStdout().trim()) > 0, "The " + clienttasks.rhsmConfFile + " file is currently configured with a productCertDir that contains all non-subscribable products based on the currently available subscriptions.");
    configureProductCertDirForNoProductsSubscribableCompleted = 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)

Example 9 with BeforeGroups

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

the class ComplianceTests method configureProductCertDirForAllProductsSubscribableInTheFuture.

@BeforeGroups(groups = { "setup" }, value = "configureProductCertDirForAllProductsSubscribableInTheFuture")
public void configureProductCertDirForAllProductsSubscribableInTheFuture() {
    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", productCertDirForAllProductsSubscribableInTheFuture);
    SSHCommandResult r = client.runCommandAndWait("ls -1 " + productCertDirForAllProductsSubscribableInTheFuture + " | wc -l");
    if (Integer.valueOf(r.getStdout().trim()) == 0)
        throw new SkipException("Could not find any installed product certs that are subscribable to future 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 future available subscriptions.");
    configureProductCertDirForAllProductsSubscribableInTheFutureCompleted = 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)

Example 10 with BeforeGroups

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

the class ComplianceTests method configureProductCertDirForAllProductsSubscribableByMoreThanOneCommonServiceLevel.

@BeforeGroups(groups = { "setup" }, value = "configureProductCertDirForAllProductsSubscribableByMoreThanOneCommonServiceLevel")
public void configureProductCertDirForAllProductsSubscribableByMoreThanOneCommonServiceLevel() {
    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", productCertDirForAllProductsSubscribableByMoreThanOneCommonServiceLevel);
    SSHCommandResult r = client.runCommandAndWait("ls -1 " + productCertDirForAllProductsSubscribableByMoreThanOneCommonServiceLevel + " | wc -l");
    if (Integer.valueOf(r.getStdout().trim()) == 0)
        throw new SkipException("Could not find any installed product certs that are autosubscribable via more than 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 more than one common service level.");
    configureProductCertDirForAllProductsSubscribableByMoreThanOneCommonServiceLevelCompleted = 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