public static async Task ClearDownTransientTenantContentStore(FeatureContext context)
        {
            ITenant          transientTenant = TransientTenantManager.GetInstance(context).PrimaryTransientClient;
            IServiceProvider serviceProvider = ContainerBindings.GetServiceProvider(context);

            if (transientTenant != null && serviceProvider != null)
            {
                await context.RunAndStoreExceptionsAsync(async() =>
                {
                    ITenantedWorkflowStoreFactory workflowStoreFactory = serviceProvider.GetRequiredService <ITenantedWorkflowStoreFactory>();
                    IWorkflowStore workflowStore = await workflowStoreFactory.GetWorkflowStoreForTenantAsync(transientTenant).ConfigureAwait(false);
                    if (workflowStore is CosmosWorkflowStore cosmosWorkflowStore)
                    {
                        await cosmosWorkflowStore.Container.DeleteContainerAsync().ConfigureAwait(false);
                    }
                }).ConfigureAwait(false);

                await context.RunAndStoreExceptionsAsync(async() =>
                {
                    ITenantedWorkflowInstanceStoreFactory workflowInstanceStoreFactory = serviceProvider.GetRequiredService <ITenantedWorkflowInstanceStoreFactory>();
                    var workflowInstanceStore = (CosmosWorkflowInstanceStore)await workflowInstanceStoreFactory.GetWorkflowInstanceStoreForTenantAsync(transientTenant).ConfigureAwait(false);
                    await workflowInstanceStore.Container.DeleteContainerAsync().ConfigureAwait(false);
                }).ConfigureAwait(false);
            }
        }
        public static async Task TearDownTenants(FeatureContext featureContext)
        {
            var tenantManager = TransientTenantManager.GetInstance(featureContext);

            await featureContext.RunAndStoreExceptionsAsync(async() =>
            {
                ITenantCloudTableFactory cloudTableFactory = ContainerBindings.GetServiceProvider(featureContext).GetRequiredService <ITenantCloudTableFactory>();
                CloudTable testTable = await cloudTableFactory.GetTableForTenantAsync(tenantManager.PrimaryTransientClient, TenantedAzureTableUserNotificationStoreFactory.TableDefinition).ConfigureAwait(false);
                await testTable.DeleteIfExistsAsync().ConfigureAwait(false);
            }).ConfigureAwait(false);

            await featureContext.RunAndStoreExceptionsAsync(() =>
            {
                return(tenantManager.CleanupAsync());
            }).ConfigureAwait(false);
        }
        public static async Task TearDownTenants(FeatureContext featureContext)
        {
            var tenantManager = TransientTenantManager.GetInstance(featureContext);

            await featureContext.RunAndStoreExceptionsAsync(async() =>
            {
                IBlobContainerSourceWithTenantLegacyTransition cloudBlobContainerFactory = ContainerBindings.GetServiceProvider(featureContext).GetRequiredService <IBlobContainerSourceWithTenantLegacyTransition>();
                BlobContainerClient testContainer = await cloudBlobContainerFactory.GetBlobContainerClientFromTenantAsync(
                    tenantManager.PrimaryTransientClient,
                    OperationsRepository.OperationsV2ConfigKey,
                    OperationsRepository.OperationsV3ConfigKey).ConfigureAwait(false);
                await testContainer.DeleteIfExistsAsync().ConfigureAwait(false);
            }).ConfigureAwait(false);

            await featureContext.RunAndStoreExceptionsAsync(() => tenantManager.CleanupAsync()).ConfigureAwait(false);
        }
Exemple #4
0
 public static async Task CleanUpTenantStore(FeatureContext featureContext)
 {
     if (featureContext.FeatureInfo.Tags.Any(t => t == "perFeatureContainer"))
     {
         IServiceProvider sp = ContainerBindings.GetServiceProvider(featureContext);
         ITenantProvider  p  = sp.GetRequiredService <ITenantProvider>();
         await featureContext.RunAndStoreExceptionsAsync(() => CoreCleanupAsync(sp, p.Root))
         .ConfigureAwait(false);
     }
 }
        public static Task StopContentManagementFunction(FeatureContext context)
        {
            return(context.RunAndStoreExceptionsAsync(async() =>
            {
                await OpenApiWebHostManager.GetInstance(context).StopAllFunctionsAsync().ConfigureAwait(false);

                HttpClient httpClient = context.Get <HttpClient>();
                httpClient.Dispose();
            }));
        }
        public static Task TearDownTransientTenant(FeatureContext context)
        {
            return(context.RunAndStoreExceptionsAsync(() =>
            {
                IServiceProvider provider = ContainerBindings.GetServiceProvider(context);
                ITenantProvider tenantProvider = provider.GetRequiredService <ITenantProvider>();

                ITenant tenant = context.Get <ITenant>();
                return tenantProvider.DeleteTenantAsync(tenant.Id);
            }));
        }
        public static async Task TeardownCosmosDb(FeatureContext featureContext)
        {
            // Pretty nasty hack to get rid of the underlying containers for the stores.
            IServiceProvider serviceProvider = ContainerBindings.GetServiceProvider(featureContext);
            ITenantProvider  tenantProvider  = serviceProvider.GetRequiredService <ITenantProvider>();

            ITenantedWorkflowStoreFactory workflowStoreFactory = serviceProvider.GetRequiredService <ITenantedWorkflowStoreFactory>();
            var workflowStore = (CosmosWorkflowStore)await workflowStoreFactory.GetWorkflowStoreForTenantAsync(tenantProvider.Root).ConfigureAwait(false);

            await featureContext.RunAndStoreExceptionsAsync(
                () => workflowStore.Container.DeleteContainerAsync()).ConfigureAwait(false);

            ITenantedWorkflowInstanceStoreFactory workflowInstanceStoreFactory = serviceProvider.GetRequiredService <ITenantedWorkflowInstanceStoreFactory>();
            var workflowInstanceStore = (CosmosWorkflowInstanceStore)await workflowInstanceStoreFactory.GetWorkflowInstanceStoreForTenantAsync(tenantProvider.Root).ConfigureAwait(false);

            await featureContext.RunAndStoreExceptionsAsync(
                () => workflowInstanceStore.Container.DeleteContainerAsync()).ConfigureAwait(false);

            await featureContext.RunAndStoreExceptionsAsync(
                () => featureContext.Get <Container>(TestDocumentsRepository).DeleteContainerAsync()).ConfigureAwait(false);
        }
Exemple #8
0
        public static async Task TearDownBlobContainers(FeatureContext context)
        {
            ITenant          transientTenant = TransientTenantManager.GetInstance(context).PrimaryTransientClient;
            IServiceProvider serviceProvider = ContainerBindings.GetServiceProvider(context);

            if (transientTenant != null && serviceProvider != null)
            {
                IPermissionsStoreFactory permissionsStoreFactory = serviceProvider.GetRequiredService <IPermissionsStoreFactory>();

                await context.RunAndStoreExceptionsAsync(async() =>
                {
                    var claimsStore = (ClaimPermissionsStore)await permissionsStoreFactory.GetClaimPermissionsStoreAsync(transientTenant);
                    await claimsStore.Container.DeleteAsync();
                }).ConfigureAwait(false);

                await context.RunAndStoreExceptionsAsync(async() =>
                {
                    var ruleSetsStore = (ResourceAccessRuleSetStore)await permissionsStoreFactory.GetResourceAccessRuleSetStoreAsync(transientTenant);
                    await ruleSetsStore.Container.DeleteAsync();
                }).ConfigureAwait(false);
            }
        }
Exemple #9
0
        public static Task ClearDownTransientTenantContentStore(FeatureContext context)
        {
            return(context.RunAndStoreExceptionsAsync(async() =>
            {
                ITenant currentTenant = context.GetTransientTenant();

                if (currentTenant != null)
                {
                    IServiceProvider serviceProvider = ContainerBindings.GetServiceProvider(context);
                    ITenantCosmosContainerFactory containerFactory = serviceProvider.GetRequiredService <ITenantCosmosContainerFactory>();
                    CosmosContainerDefinition containerDefinition = serviceProvider.GetRequiredService <CosmosContainerDefinition>();
                    Container container = await containerFactory.GetContainerForTenantAsync(currentTenant, containerDefinition).ConfigureAwait(false);
                    await container.DeleteContainerAsync().ConfigureAwait(false);
                }
            }));
        }
 public static Task TeardownFeatureLevelCosmosDBDatabases(FeatureContext featureContext)
 {
     return(featureContext.RunAndStoreExceptionsAsync(() => TeardownCosmosDBDatabasesCoreAsync(featureContext)));
 }
 public static Task TeardownCosmosDB(FeatureContext featureContext)
 {
     return(featureContext.RunAndStoreExceptionsAsync(
                async() => await featureContext.Get <Container>(ContentManagementSpecsContainer).DeleteContainerAsync().ConfigureAwait(false)));
 }