Пример #1
0
        public static async Task UploadTestApplicationPackageIfNotAlreadyUploadedAsync(
            string appPackageName,
            string applicationVersion,
            string accountName,
            string resourceGroupName)
        {
            using BatchManagementClient mgmtClient = IntegrationTestCommon.OpenBatchManagementClient();
            IPage <Application> applicationSummaries =
                await mgmtClient.Application.ListAsync(resourceGroupName, accountName).ConfigureAwait(false);

            bool testPackageAlreadyUploaded =
                applicationSummaries.Any(a => string.Equals(appPackageName, a.Id, StringComparison.OrdinalIgnoreCase));

            if (!testPackageAlreadyUploaded)
            {
                const string format = "zip";

                var addResponse =
                    await
                    mgmtClient.ApplicationPackage.CreateAsync(resourceGroupName, accountName, appPackageName, applicationVersion)
                    .ConfigureAwait(false);

                var storageUrl = addResponse.StorageUrl;

                await IntegrationTestCommon.UploadTestApplicationAsync(storageUrl).ConfigureAwait(false);

                await
                mgmtClient.ApplicationPackage.ActivateAsync(
                    resourceGroupName,
                    accountName,
                    appPackageName,
                    applicationVersion,
                    format).ConfigureAwait(false);
            }
        }
Пример #2
0
        public static async Task DeleteApplicationAsync(string applicationPackage, string resourceGroupName, string accountName)
        {
            using BatchManagementClient mgmtClient = IntegrationTestCommon.OpenBatchManagementClient();
            await mgmtClient.ApplicationPackage.DeleteAsync(resourceGroupName, accountName, applicationPackage, Version).ConfigureAwait(false);

            await mgmtClient.Application.DeleteAsync(resourceGroupName, accountName, applicationPackage).ConfigureAwait(false);
        }
Пример #3
0
        public async Task End2EndApplicationPackageScenario()
        {
            string accountName = TestCommon.Configuration.BatchAccountName;

            Func <Task> test = async() =>
            {
                var poolId = "app-ref-test" + Guid.NewGuid();
                using (BatchClient client = await TestUtilities.OpenBatchClientFromEnvironmentAsync())
                {
                    using (var mgmtClient = IntegrationTestCommon.OpenBatchManagementClient())
                    {
                        // Give the application a display name
                        await mgmtClient.Application.UpdateAsync(TestCommon.Configuration.BatchAccountResourceGroup, accountName, ApplicationId, new UpdateApplicationParameters
                        {
                            AllowUpdates   = true,
                            DefaultVersion = ApplicationIntegrationCommon.Version,
                            DisplayName    = DisplayName
                        }).ConfigureAwait(false);

                        List <ApplicationSummary> applicationSummaries = await client.ApplicationOperations.ListApplicationSummaries().ToListAsync().ConfigureAwait(false);

                        ApplicationSummary applicationSummary = applicationSummaries.First();
                        Assert.Equal(ApplicationIntegrationCommon.Version, applicationSummary.Versions.First());
                        Assert.Equal(ApplicationId, applicationSummary.Id);
                        Assert.Equal(DisplayName, applicationSummary.DisplayName);


                        ApplicationSummary getApplicationSummary = await client.ApplicationOperations.GetApplicationSummaryAsync(applicationSummary.Id).ConfigureAwait(false);

                        Assert.Equal(getApplicationSummary.Id, applicationSummary.Id);
                        Assert.Equal(getApplicationSummary.Versions.Count(), applicationSummary.Versions.Count());
                        Assert.Equal(getApplicationSummary.DisplayName, applicationSummary.DisplayName);

                        var appPackage = await mgmtClient.ApplicationPackage.GetAsync(
                            TestCommon.Configuration.BatchAccountResourceGroup,
                            accountName,
                            ApplicationId,
                            ApplicationIntegrationCommon.Version).ConfigureAwait(false);

                        Assert.Equal(PackageState.Active, appPackage.State);
                        Assert.Equal(ApplicationIntegrationCommon.Version, appPackage.Version);
                        Assert.Equal(ApplicationId, appPackage.Id);

                        var application = await mgmtClient.Application.GetAsync(TestCommon.Configuration.BatchAccountResourceGroup, accountName, ApplicationId).ConfigureAwait(false);

                        Assert.Equal(ApplicationIntegrationCommon.Version, application.DefaultVersion);
                        Assert.Equal(ApplicationId, application.Id);

                        await AssertPoolWasCreatedWithApplicationReferences(client, poolId, ApplicationId).ConfigureAwait(false);
                    }
                }
            };

            await SynchronizationContextHelper.RunTestAsync(test, LongRunningTestTimeout);
        }
        public void Dispose()
        {
            BatchManagementClient mgmtClient = IntegrationTestCommon.OpenBatchManagementClient();
            string accountName       = TestCommon.Configuration.BatchAccountName;
            string resourceGroupName = TestCommon.Configuration.BatchAccountResourceGroup;

            Func <Task> cleanupTask = async() =>
            {
                await mgmtClient.ApplicationPackage.DeleteAsync(resourceGroupName, accountName, AppPackageName, Version);

                await mgmtClient.Application.DeleteAsync(resourceGroupName, accountName, AppPackageName);
            };

            Task.Run(cleanupTask).GetAwaiter().GetResult();
        }
Пример #5
0
        private static async Task UploadTestApplicationAndActivateAsync(string appPackageName, string applicationVersion, string resourceGroupName, string accountName)
        {
            const string format = "zip";

            using (BatchManagementClient mgmtClient = IntegrationTestCommon.OpenBatchManagementClient())
            {
                var addResponse = await mgmtClient.ApplicationPackage.CreateAsync(resourceGroupName, accountName, appPackageName, applicationVersion).ConfigureAwait(false);

                var storageUrl = addResponse.StorageUrl;

                await IntegrationTestCommon.UploadTestApplicationAsync(storageUrl).ConfigureAwait(false);

                await mgmtClient.ApplicationPackage.ActivateAsync(resourceGroupName, accountName, appPackageName, applicationVersion, format).ConfigureAwait(false);
            }
        }
Пример #6
0
        public static async Task UploadTestApplicationPackageIfNotAlreadyUploadedAsync(string appPackageName, string applicationVersion)
        {
            string accountName       = TestCommon.Configuration.BatchAccountName;
            string resourceGroupName = TestCommon.Configuration.BatchAccountResourceGroup;

            using (BatchManagementClient mgmtClient = IntegrationTestCommon.OpenBatchManagementClient())
            {
                var applicationSummaries = await mgmtClient.Application.ListAsync(resourceGroupName, accountName);

                bool testPackageAlreadyUploaded = applicationSummaries.Any(a =>
                                                                           string.Equals(appPackageName, a.Id, StringComparison.OrdinalIgnoreCase) &&
                                                                           string.Equals(applicationVersion, a.DefaultVersion, StringComparison.OrdinalIgnoreCase));

                if (!testPackageAlreadyUploaded)
                {
                    await UploadTestApplicationAndActivateAsync(appPackageName, applicationVersion, resourceGroupName, accountName).ConfigureAwait(false);
                }
            }
        }
Пример #7
0
        public static async Task UpdateApplicationPackageAsync(string applicationId, string defaultVersion, string displayName, bool hasDefaultVersion)
        {
            string accountName       = TestCommon.Configuration.BatchAccountName;
            string resourceGroupName = TestCommon.Configuration.BatchAccountResourceGroup;

            BatchManagementClient mgmtClient = IntegrationTestCommon.OpenBatchManagementClient();

            if (hasDefaultVersion)
            {
                await mgmtClient.Application.UpdateAsync(
                    resourceGroupName,
                    accountName,
                    applicationId,
                    new UpdateApplicationParameters { AllowUpdates = true, DefaultVersion = defaultVersion, DisplayName = displayName });
            }
            else
            {
                await mgmtClient.Application.UpdateAsync(
                    resourceGroupName,
                    accountName,
                    applicationId,
                    new UpdateApplicationParameters { AllowUpdates = true, DisplayName = displayName });
            }
        }