Search in sources :

Example 11 with AfterSuite

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

the class MockSuiteInitializer method cleanUp.

@AfterSuite(alwaysRun = true)
@Parameters("cleanUp")
public void cleanUp(@Optional("true") boolean cleanUp) {
    if (isCleanUpNeeded(cleanUp)) {
        CloudbreakClient cloudbreakClient = itContext.getContextParam(CloudbreakITContextConstants.CLOUDBREAK_CLIENT, CloudbreakClient.class);
        cleanUpService.deleteImageCatalog(cloudbreakClient, MOCK_IMAGE_CATALOG_NAME);
    }
}
Also used : CloudbreakClient(com.sequenceiq.cloudbreak.client.CloudbreakClient) Parameters(org.testng.annotations.Parameters) AfterSuite(org.testng.annotations.AfterSuite)

Example 12 with AfterSuite

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

the class CloudbreakTestSuiteInitializer method cleanUp.

@AfterSuite(alwaysRun = true)
@Parameters("cleanUp")
public void cleanUp(@Optional("true") boolean cleanUp) {
    if (isCleanUpNeeded(cleanUp)) {
        CloudbreakClient cloudbreakClient = itContext.getContextParam(CloudbreakITContextConstants.CLOUDBREAK_CLIENT, CloudbreakClient.class);
        String stackId = itContext.getCleanUpParameter(CloudbreakITContextConstants.STACK_ID);
        cleanUpService.deleteStackAndWait(cloudbreakClient, stackId);
        List<InstanceGroup> instanceGroups = itContext.getCleanUpParameter(CloudbreakITContextConstants.TEMPLATE_ID, List.class);
        if (instanceGroups != null && !instanceGroups.isEmpty()) {
            Collection<String> deletedTemplates = new HashSet<>();
            for (InstanceGroup ig : instanceGroups) {
                if (!deletedTemplates.contains(ig.getTemplateId())) {
                    cleanUpService.deleteTemplate(cloudbreakClient, ig.getTemplateId());
                    deletedTemplates.add(ig.getTemplateId());
                }
            }
        }
        Set<Long> recipeIds = itContext.getContextParam(CloudbreakITContextConstants.RECIPE_ID, Set.class);
        if (recipeIds != null) {
            for (Long recipeId : recipeIds) {
                cleanUpService.deleteRecipe(cloudbreakClient, recipeId);
            }
        }
        cleanUpService.deleteCredential(cloudbreakClient, itContext.getCleanUpParameter(CloudbreakITContextConstants.CREDENTIAL_ID));
        cleanUpService.deleteBlueprint(cloudbreakClient, itContext.getCleanUpParameter(CloudbreakITContextConstants.BLUEPRINT_ID));
        cleanUpService.deleteNetwork(cloudbreakClient, itContext.getCleanUpParameter(CloudbreakITContextConstants.NETWORK_ID));
        cleanUpService.deleteSecurityGroup(cloudbreakClient, itContext.getCleanUpParameter(CloudbreakITContextConstants.SECURITY_GROUP_ID));
        cleanUpService.deleteRdsConfigs(cloudbreakClient, itContext.getCleanUpParameter(CloudbreakITContextConstants.RDS_CONFIG_ID));
    }
}
Also used : CloudbreakClient(com.sequenceiq.cloudbreak.client.CloudbreakClient) HashSet(java.util.HashSet) Parameters(org.testng.annotations.Parameters) AfterSuite(org.testng.annotations.AfterSuite)

Example 13 with AfterSuite

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

the class GcpDeleteVpcTest method deleteNetwork.

@AfterSuite
@Parameters("vpcName")
public void deleteNetwork(@Optional("it-vpc") String vpcName) throws Exception {
    springTestContextPrepareTestInstance();
    String serviceAccountPrivateKey = ResourceUtil.readBase64EncodedContentFromResource(applicationContext, defaultP12File);
    HttpTransport httpTransport = GoogleNetHttpTransport.newTrustedTransport();
    PrivateKey privateKey = SecurityUtils.loadPrivateKeyFromKeyStore(SecurityUtils.getPkcs12KeyStore(), new ByteArrayInputStream(Base64.decodeBase64(serviceAccountPrivateKey)), "notasecret", "privatekey", "notasecret");
    JacksonFactory jsonFactory = JacksonFactory.getDefaultInstance();
    GoogleCredential googleCredential = new GoogleCredential.Builder().setTransport(httpTransport).setJsonFactory(jsonFactory).setServiceAccountId(defaultServiceAccountId).setServiceAccountScopes(Collections.singletonList(ComputeScopes.COMPUTE)).setServiceAccountPrivateKey(privateKey).build();
    Compute compute = new Builder(httpTransport, jsonFactory, null).setApplicationName(defaultName).setHttpRequestInitializer(googleCredential).build();
    Delete delete = compute.networks().delete(defaultProjectId, vpcName);
    Operation operation = delete.execute();
    if (operation.getHttpErrorStatusCode() != null) {
        throw new IllegalStateException("gcp operation failed: " + operation.getHttpErrorMessage());
    }
}
Also used : Delete(com.google.api.services.compute.Compute.Networks.Delete) HttpTransport(com.google.api.client.http.HttpTransport) GoogleNetHttpTransport(com.google.api.client.googleapis.javanet.GoogleNetHttpTransport) PrivateKey(java.security.PrivateKey) ByteArrayInputStream(java.io.ByteArrayInputStream) Builder(com.google.api.services.compute.Compute.Builder) Compute(com.google.api.services.compute.Compute) GoogleCredential(com.google.api.client.googleapis.auth.oauth2.GoogleCredential) Operation(com.google.api.services.compute.model.Operation) JacksonFactory(com.google.api.client.json.jackson2.JacksonFactory) Parameters(org.testng.annotations.Parameters) AfterSuite(org.testng.annotations.AfterSuite)

Example 14 with AfterSuite

use of org.testng.annotations.AfterSuite in project open-ecard by ecsec.

the class AddonPropertiesTest method clear.

/**
 * Remove created folders and files
 * @throws java.io.IOException
 */
@AfterSuite
public void clear() throws IOException {
    if (!addonsExists) {
        new File(FileUtils.getAddonsConfDir().getPath() + "/test-addon.conf").delete();
        path.delete();
    } else {
        new File(FileUtils.getAddonsConfDir().getPath() + "/test-addon.conf").delete();
    }
}
Also used : File(java.io.File) AfterSuite(org.testng.annotations.AfterSuite)

Example 15 with AfterSuite

use of org.testng.annotations.AfterSuite in project carina by qaprosoft.

the class CryptoToolTest method cleanup.

@AfterSuite
public void cleanup() {
    File keyFile = new File(cryptoFileName);
    Assert.assertTrue(keyFile.exists());
    keyFile.delete();
}
Also used : File(java.io.File) 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