Search in sources :

Example 1 with AfterSuite

use of org.testng.annotations.AfterSuite in project OpenAM by OpenRock.

the class AMIdentityTestBase method suiteTearDown.

/**
     * Removes realm after suite test is done.
     * 
     * @throws SMSException if realm cannot be deleted.
     * @throws SSOException if the super administrator Single Sign On is 
     *         invalid.
     */
@Parameters({ "parent-realms" })
@AfterSuite(groups = { "api" })
public void suiteTearDown(String realms) throws SSOException, SMSException {
    Object[] params = { realms };
    entering("suiteTearDown", params);
    StringTokenizer st = new StringTokenizer(realms, ",");
    while (st.hasMoreElements()) {
        String realm = st.nextToken().trim();
        deleteRealm(getAdminSSOToken(), realm);
    }
    exiting("suiteTearDown");
}
Also used : StringTokenizer(java.util.StringTokenizer) Parameters(org.testng.annotations.Parameters) AfterSuite(org.testng.annotations.AfterSuite)

Example 2 with AfterSuite

use of org.testng.annotations.AfterSuite in project oap by oaplatform.

the class AbstractTest method afterSuite.

@AfterSuite
public void afterSuite() throws Exception {
    if (cleanupTemp) {
        final long now = System.currentTimeMillis();
        boolean empty = true;
        if (!java.nio.file.Files.exists(Env.tmp))
            return;
        try (val stream = java.nio.file.Files.newDirectoryStream(Env.tmp)) {
            for (Path build : stream) {
                final boolean self = Env.tmpRoot.equals(build);
                final long lastModified = java.nio.file.Files.getLastModifiedTime(build).toMillis();
                final long diff = now - lastModified;
                if (self || diff > TEN_HOURS) {
                    log.info("delete {}", build);
                    deleteDirectory(build);
                } else {
                    log.info("skip {}, self = {}, diff = {}", build, self, diff);
                    log.trace("build={}, env={}", build);
                    log.trace("now={}, lastModified={}", now, lastModified);
                    empty = false;
                }
            }
        }
        if (empty)
            deleteDirectory(Env.tmp);
    }
}
Also used : lombok.val(lombok.val) Path(java.nio.file.Path) AfterSuite(org.testng.annotations.AfterSuite)

Example 3 with AfterSuite

use of org.testng.annotations.AfterSuite in project cloudbreak by hortonworks.

the class AwsDeleteVpcTest method deleteNetwork.

@AfterSuite
@Parameters({ "regionName", "vpcStackName" })
public void deleteNetwork(String regionName, @Optional("it-vpc-stack") String vpcStackName) {
    AmazonCloudFormationClient client = new AmazonCloudFormationClient();
    client.setRegion(RegionUtils.getRegion(regionName));
    client.deleteStack(new DeleteStackRequest().withStackName(vpcStackName));
}
Also used : DeleteStackRequest(com.amazonaws.services.cloudformation.model.DeleteStackRequest) AmazonCloudFormationClient(com.amazonaws.services.cloudformation.AmazonCloudFormationClient) Parameters(org.testng.annotations.Parameters) AfterSuite(org.testng.annotations.AfterSuite)

Example 4 with AfterSuite

use of org.testng.annotations.AfterSuite in project cloudbreak by hortonworks.

the class AzureDeleteVpcTest method deleteNetwork.

@AfterSuite
@Parameters({ "resourceGroupName", "vpcName" })
public void deleteNetwork(@Optional("it-vpc-resource-group") String resourceGroupName, @Optional("it-vpc") String vpcName) throws Exception {
    springTestContextPrepareTestInstance();
    ApplicationTokenCredentials serviceClientCredentials = new ApplicationTokenCredentials(defaultAccesKey, defaultTenantId, defaultSecretKey, null);
    Azure azure = Azure.authenticate(serviceClientCredentials).withSubscription(defaultSubscriptionId);
    azure.networks().deleteByResourceGroup(resourceGroupName, vpcName);
}
Also used : Azure(com.microsoft.azure.management.Azure) ApplicationTokenCredentials(com.microsoft.azure.credentials.ApplicationTokenCredentials) Parameters(org.testng.annotations.Parameters) AfterSuite(org.testng.annotations.AfterSuite)

Example 5 with AfterSuite

use of org.testng.annotations.AfterSuite in project oap by oaplatform.

the class TestDirectoryCleanupTest method tryGeneralCleanup.

@AfterSuite
public void tryGeneralCleanup() {
    final long now = System.currentTimeMillis();
    boolean empty = true;
    if (!java.nio.file.Files.exists(globalTestDirectory()))
        return;
    try (var stream = java.nio.file.Files.newDirectoryStream(globalTestDirectory())) {
        for (Path build : stream) {
            boolean self = TestDirectoryFixture.testDirectory().equals(build);
            long lastModified = java.nio.file.Files.getLastModifiedTime(build).toMillis();
            long diff = now - lastModified;
            if (self || diff > TEN_HOURS) {
                log.info("delete {}", build);
                deleteDirectory(build);
            } else {
                log.info("skip {}, diff = {}", build, diff);
                log.trace("build={}", build);
                log.trace("now={}, lastModified={}", now, lastModified);
                empty = false;
            }
        }
    } catch (IOException e) {
        throw new UncheckedIOException(e);
    }
    if (empty)
        deleteDirectory(globalTestDirectory());
}
Also used : Path(java.nio.file.Path) UncheckedIOException(java.io.UncheckedIOException) UncheckedIOException(java.io.UncheckedIOException) IOException(java.io.IOException) AfterSuite(org.testng.annotations.AfterSuite)

Aggregations

AfterSuite (org.testng.annotations.AfterSuite)15 Parameters (org.testng.annotations.Parameters)7 File (java.io.File)4 CloudbreakClient (com.sequenceiq.cloudbreak.client.CloudbreakClient)2 Path (java.nio.file.Path)2 SubscriptionManagerTasks (rhsm.cli.tasks.SubscriptionManagerTasks)2 AmazonCloudFormationClient (com.amazonaws.services.cloudformation.AmazonCloudFormationClient)1 DeleteStackRequest (com.amazonaws.services.cloudformation.model.DeleteStackRequest)1 GoogleCredential (com.google.api.client.googleapis.auth.oauth2.GoogleCredential)1 GoogleNetHttpTransport (com.google.api.client.googleapis.javanet.GoogleNetHttpTransport)1 HttpTransport (com.google.api.client.http.HttpTransport)1 JacksonFactory (com.google.api.client.json.jackson2.JacksonFactory)1 Compute (com.google.api.services.compute.Compute)1 Builder (com.google.api.services.compute.Compute.Builder)1 Delete (com.google.api.services.compute.Compute.Networks.Delete)1 Operation (com.google.api.services.compute.model.Operation)1 ApplicationTokenCredentials (com.microsoft.azure.credentials.ApplicationTokenCredentials)1 Azure (com.microsoft.azure.management.Azure)1 CLIRequest (com.sun.identity.cli.CLIRequest)1 ByteArrayInputStream (java.io.ByteArrayInputStream)1