Exemple #1
0
        public async Task DeleteQueuesForEndpointWithPrefix()
        {
            var endpointName   = "mydeleteprefixendpoint";
            var errorQueueName = "mydeleteprefixerror";
            var auditQueueName = "mydeleteprefixaudit";

            await CreateEndpointQueues.CreateQueuesForEndpoint(endpointName, queueNamePrefix : "DEV")
            .ConfigureAwait(false);

            await QueueCreationUtils.CreateQueue(errorQueueName, queueNamePrefix : "DEV")
            .ConfigureAwait(false);

            await QueueCreationUtils.CreateQueue(auditQueueName, queueNamePrefix : "DEV")
            .ConfigureAwait(false);


            await DeleteEndpointQueues.DeleteQueuesForEndpoint(endpointName, queueNamePrefix : "DEV")
            .ConfigureAwait(false);

            await QueueDeletionUtils.DeleteQueue(errorQueueName, queueNamePrefix : "DEV")
            .ConfigureAwait(false);

            await QueueDeletionUtils.DeleteQueue(auditQueueName, queueNamePrefix : "DEV")
            .ConfigureAwait(false);


            await AssertQueuesDeleted(endpointName, errorQueueName, auditQueueName, queueNamePrefix : "DEV")
            .ConfigureAwait(false);
        }
        public static async Task DeleteQueuesForEndpoint(string endpointName, string queueNamePrefix = null, bool includeRetries = false, string delayedDeliveryMethod = "Native")
        {
            switch (delayedDeliveryMethod)
            {
            case "TimeoutManager":

                // timeout queue
                await QueueDeletionUtils.DeleteQueue($"{endpointName}.Timeouts", queueNamePrefix)
                .ConfigureAwait(false);

                // timeout dispatcher queue
                await QueueDeletionUtils.DeleteQueue($"{endpointName}.TimeoutsDispatcher", queueNamePrefix)
                .ConfigureAwait(false);

                break;

            case "UnrestrictedDelayedDelivery":

                await QueueDeletionUtils.DeleteQueue($"{endpointName}-delay.fifo", queueNamePrefix)
                .ConfigureAwait(false);

                break;
            }

            // main queue
            await QueueDeletionUtils.DeleteQueue(endpointName, queueNamePrefix)
            .ConfigureAwait(false);

            // retries queue
            if (includeRetries)
            {
                await QueueDeletionUtils.DeleteQueue($"{endpointName}.Retries", queueNamePrefix)
                .ConfigureAwait(false);
            }
        }
Exemple #3
0
        public async Task DeleteQueuesForEndpointWithRetries()
        {
            var endpointName   = "mydeleteretriesendpoint";
            var errorQueueName = "mydeleteretrieserror";
            var auditQueueName = "mydeleteretriesaudit";

            await CreateEndpointQueues.CreateQueuesForEndpoint(endpointName, includeRetries : true)
            .ConfigureAwait(false);

            await QueueCreationUtils.CreateQueue(errorQueueName)
            .ConfigureAwait(false);

            await QueueCreationUtils.CreateQueue(auditQueueName)
            .ConfigureAwait(false);


            await DeleteEndpointQueues.DeleteQueuesForEndpoint(endpointName, includeRetries : true)
            .ConfigureAwait(false);

            await QueueDeletionUtils.DeleteQueue(errorQueueName)
            .ConfigureAwait(false);

            await QueueDeletionUtils.DeleteQueue(auditQueueName)
            .ConfigureAwait(false);


            await AssertQueuesDeleted(endpointName, errorQueueName, auditQueueName, includeRetries : true)
            .ConfigureAwait(false);
        }
Exemple #4
0
        public async Task DeleteAllQueuesWithPrefix()
        {
            using (var client = ClientFactory.CreateSqsClient())
            {
                var creationTasks = new Task[12];
                for (var i = 0; i < 10; i++)
                {
                    creationTasks[i] = RetryCreateOnThrottle(client, $"deleteprefix-{i}", TimeSpan.FromSeconds(10), 6, queueNamePrefix: "DEV");
                }

                creationTasks[10] = RetryCreateOnThrottle(client, "deleteprefix-10", TimeSpan.FromSeconds(10), 6);
                creationTasks[11] = Task.Delay(TimeSpan.FromSeconds(60));

                await Task.WhenAll(creationTasks)
                .ConfigureAwait(false);
            }

            await QueueDeletionUtils.DeleteAllQueues(queueNamePrefix : "DEV")
            .ConfigureAwait(false);

            Assert.IsTrue(await QueueExistenceUtils.Exists("deleteprefix-10"));

            for (var i = 0; i < 10; i++)
            {
                Assert.IsFalse(await QueueExistenceUtils.Exists($"DEVdeleteprefix-{i}"));
            }
        }
Exemple #5
0
        public async Task DeleteQueuesForEndpoint()
        {
            var endpointName   = "mydeleteendpoint";
            var errorQueueName = "mydeleteerror";
            var auditQueueName = "mydeleteaudit";

            await CreateEndpointQueues.CreateQueuesForEndpoint(endpointName)
            .ConfigureAwait(false);

            await QueueCreationUtils.CreateQueue(errorQueueName)
            .ConfigureAwait(false);

            await QueueCreationUtils.CreateQueue(auditQueueName)
            .ConfigureAwait(false);


            await DeleteEndpointQueues.DeleteQueuesForEndpoint(endpointName)
            .ConfigureAwait(false);

            await QueueDeletionUtils.DeleteQueue(errorQueueName)
            .ConfigureAwait(false);

            await QueueDeletionUtils.DeleteQueue(auditQueueName)
            .ConfigureAwait(false);


            await AssertQueuesDeleted(endpointName, errorQueueName, auditQueueName)
            .ConfigureAwait(false);
        }
Exemple #6
0
        public async Task DeleteQueuesForEndpointWithRetries(string delayedDeliveryMethod)
        {
            var randomName     = Path.GetFileNameWithoutExtension(Path.GetRandomFileName());
            var endpointName   = $"mydeleteretriesendpoint-{randomName}";
            var errorQueueName = $"mydeleteretrieserror-{randomName}";
            var auditQueueName = $"mydeleteretriesaudit-{randomName}";

            await CreateEndpointQueues.CreateQueuesForEndpoint(endpointName, includeRetries : true, delayedDeliveryMethod : delayedDeliveryMethod)
            .ConfigureAwait(false);

            await QueueCreationUtils.CreateQueue(errorQueueName)
            .ConfigureAwait(false);

            await QueueCreationUtils.CreateQueue(auditQueueName)
            .ConfigureAwait(false);


            await DeleteEndpointQueues.DeleteQueuesForEndpoint(endpointName, includeRetries : true, delayedDeliveryMethod : delayedDeliveryMethod)
            .ConfigureAwait(false);

            await QueueDeletionUtils.DeleteQueue(errorQueueName)
            .ConfigureAwait(false);

            await QueueDeletionUtils.DeleteQueue(auditQueueName)
            .ConfigureAwait(false);


            await AssertQueuesDeleted(endpointName, errorQueueName, auditQueueName, includeRetries : true, delayedDeliveryMethod : delayedDeliveryMethod)
            .ConfigureAwait(false);
        }
Exemple #7
0
        public async Task DeleteQueuesForEndpointWithPrefix(string delayedDeliveryMethod)
        {
            var randomName     = Path.GetFileNameWithoutExtension(Path.GetRandomFileName());
            var endpointName   = $"mydeleteprefixendpoint-{randomName}";
            var errorQueueName = $"mydeleteprefixerror-{randomName}";
            var auditQueueName = $"mydeleteprefixaudit-{randomName}";

            await CreateEndpointQueues.CreateQueuesForEndpoint(endpointName, queueNamePrefix : "DEV", delayedDeliveryMethod : delayedDeliveryMethod)
            .ConfigureAwait(false);

            await QueueCreationUtils.CreateQueue(errorQueueName, queueNamePrefix : "DEV")
            .ConfigureAwait(false);

            await QueueCreationUtils.CreateQueue(auditQueueName, queueNamePrefix : "DEV")
            .ConfigureAwait(false);


            await DeleteEndpointQueues.DeleteQueuesForEndpoint(endpointName, queueNamePrefix : "DEV", delayedDeliveryMethod : delayedDeliveryMethod)
            .ConfigureAwait(false);

            await QueueDeletionUtils.DeleteQueue(errorQueueName, queueNamePrefix : "DEV")
            .ConfigureAwait(false);

            await QueueDeletionUtils.DeleteQueue(auditQueueName, queueNamePrefix : "DEV")
            .ConfigureAwait(false);


            await AssertQueuesDeleted(endpointName, errorQueueName, auditQueueName, queueNamePrefix : "DEV", delayedDeliveryMethod : delayedDeliveryMethod)
            .ConfigureAwait(false);
        }
Exemple #8
0
        public async Task DeleteQueueForEndpointWithPrefix_Powershell(string delayedDeliveryMethod)
        {
            var randomName     = Path.GetFileNameWithoutExtension(Path.GetRandomFileName());
            var endpointName   = $"mydeleteprefixendpoint-{randomName}-powershell";
            var errorQueueName = $"mydeleteprefixerror-{randomName}-powershell";
            var auditQueueName = $"mydeleteprefixaudit-{randomName}-powershell";

            await CreateEndpointQueues.CreateQueuesForEndpoint(endpointName, queueNamePrefix : "DEV", delayedDeliveryMethod : delayedDeliveryMethod)
            .ConfigureAwait(false);

            await QueueCreationUtils.CreateQueue(errorQueueName, queueNamePrefix : "DEV")
            .ConfigureAwait(false);

            await QueueCreationUtils.CreateQueue(auditQueueName, queueNamePrefix : "DEV")
            .ConfigureAwait(false);

            try
            {
                var scriptPath = Path.Combine(TestContext.CurrentContext.TestDirectory, "QueueDeletion/QueueDeletion.ps1");
                using (var powerShell = PowerShell.Create())
                {
                    powerShell.AddScript(File.ReadAllText(scriptPath));
                    powerShell.Invoke();
                    var command = powerShell.AddCommand("DeleteQueuesForEndpoint");
                    command.AddParameter("EndpointName", endpointName);
                    command.AddParameter("QueueNamePrefix", "DEV");
                    command.AddParameter("DelayedDeliveryMethod", delayedDeliveryMethod);
                    command.Invoke();

                    command = powerShell.AddCommand("DeleteQueue");
                    command.AddParameter("QueueName", errorQueueName);
                    command.AddParameter("QueueNamePrefix", "DEV");
                    command.Invoke();

                    command = powerShell.AddCommand("DeleteQueue");
                    command.AddParameter("QueueName", auditQueueName);
                    command.AddParameter("QueueNamePrefix", "DEV");
                    command.Invoke();
                }

                await AssertQueuesDeleted(endpointName, errorQueueName, auditQueueName, queueNamePrefix : "DEV", delayedDeliveryMethod : delayedDeliveryMethod)
                .ConfigureAwait(false);
            }
            finally
            {
                await DeleteEndpointQueues.DeleteQueuesForEndpoint(endpointName, queueNamePrefix : "DEV", delayedDeliveryMethod : delayedDeliveryMethod)
                .ConfigureAwait(false);

                await QueueDeletionUtils.DeleteQueue(errorQueueName, queueNamePrefix : "DEV")
                .ConfigureAwait(false);

                await QueueDeletionUtils.DeleteQueue(auditQueueName, queueNamePrefix : "DEV")
                .ConfigureAwait(false);
            }
        }
Exemple #9
0
        public async Task DeleteQueueForEndpoint_Powershell()
        {
            var endpointName   = "mydeleteendpoint-powershell";
            var errorQueueName = "mydeleteerror-powershell";
            var auditQueueName = "mydeleteaudit-powershell";

            await CreateEndpointQueues.CreateQueuesForEndpoint(endpointName)
            .ConfigureAwait(false);

            await QueueCreationUtils.CreateQueue(errorQueueName)
            .ConfigureAwait(false);

            await QueueCreationUtils.CreateQueue(auditQueueName)
            .ConfigureAwait(false);

            try
            {
                var scriptPath = Path.Combine(TestContext.CurrentContext.TestDirectory, "QueueDeletion/QueueDeletion.ps1");
                using (var powerShell = PowerShell.Create())
                {
                    powerShell.AddScript(File.ReadAllText(scriptPath));
                    powerShell.Invoke();
                    var command = powerShell.AddCommand("DeleteQueuesForEndpoint");
                    command.AddParameter("EndpointName", endpointName);
                    command.Invoke();

                    command = powerShell.AddCommand("DeleteQueue");
                    command.AddParameter("QueueName", errorQueueName);
                    command.Invoke();

                    command = powerShell.AddCommand("DeleteQueue");
                    command.AddParameter("QueueName", auditQueueName);
                    command.Invoke();
                }

                await AssertQueuesDeleted(endpointName, errorQueueName, auditQueueName)
                .ConfigureAwait(false);
            }
            finally
            {
                await DeleteEndpointQueues.DeleteQueuesForEndpoint(endpointName)
                .ConfigureAwait(false);

                await QueueDeletionUtils.DeleteQueue(errorQueueName)
                .ConfigureAwait(false);

                await QueueDeletionUtils.DeleteQueue(auditQueueName)
                .ConfigureAwait(false);
            }
        }
        public static async Task DeleteQueuesForEndpoint(string endpointName, string queueNamePrefix = null, bool includeRetries = false)
        {
            // main queue
            await QueueDeletionUtils.DeleteQueue(endpointName, queueNamePrefix)
            .ConfigureAwait(false);

            // timeout queue
            await QueueDeletionUtils.DeleteQueue($"{endpointName}.Timeouts", queueNamePrefix)
            .ConfigureAwait(false);

            // timeout dispatcher queue
            await QueueDeletionUtils.DeleteQueue($"{endpointName}.TimeoutsDispatcher", queueNamePrefix)
            .ConfigureAwait(false);

            // retries queue
            if (includeRetries)
            {
                await QueueDeletionUtils.DeleteQueue($"{endpointName}.Retries", queueNamePrefix)
                .ConfigureAwait(false);
            }
        }
Exemple #11
0
        async Task Usage()
        {
            #region sqs-delete-queues-shared-usage

            await QueueDeletionUtils.DeleteQueue(queueName : "error", queueNamePrefix : "PROD")
            .ConfigureAwait(false);

            await QueueDeletionUtils.DeleteQueue(queueName : "audit", queueNamePrefix : "PROD")
            .ConfigureAwait(false);

            #endregion

            #region sqs-delete-queues-shared-usage-cloudformation

            await QueueDeletionUtilsCloudFormation.DeleteQueue(queueName : "error", queueNamePrefix : "PROD")
            .ConfigureAwait(false);

            await QueueDeletionUtilsCloudFormation.DeleteQueue(queueName : "audit", queueNamePrefix : "PROD")
            .ConfigureAwait(false);

            #endregion
        }
Exemple #12
0
        public async Task DeleteAllQueuesWhenMoreThanAThousandQueues() // Takes several minutes!
        {
            using (var client = ClientFactory.CreateSqsClient())
            {
                var creationTasks = new Task[2001];
                for (var i = 0; i < 2000; i++)
                {
                    creationTasks[i] = RetryCreateOnThrottle(client, $"deletemore2000-{i}", TimeSpan.FromSeconds(10), 6);
                }

                creationTasks[2000] = Task.Delay(TimeSpan.FromSeconds(60));

                await Task.WhenAll(creationTasks)
                .ConfigureAwait(false);
            }

            await QueueDeletionUtils.DeleteAllQueues()
            .ConfigureAwait(false);

            for (var i = 0; i < 2000; i++)
            {
                Assert.IsFalse(await QueueExistenceUtils.Exists($"deletemore2000-{i}"));
            }
        }