public void SaveAzureWebsiteLogWithSlotTest()
        {
            TestExecutionHelpers.RetryAction(
                () =>
            {
                // Setup
                SimpleDeploymentServiceManagement deploymentChannel = new SimpleDeploymentServiceManagement
                {
                    DownloadLogsThunk = ar => new MemoryStream(Encoding.UTF8.GetBytes("test"))
                };

                // Test
                SaveAzureWebsiteLogCommand getAzureWebsiteLogCommand = new SaveAzureWebsiteLogCommand(deploymentChannel)
                {
                    Name           = "website1",
                    ShareChannel   = true,
                    WebsitesClient = clientMock.Object,
                    CommandRuntime = new MockCommandRuntime(),
                    Slot           = slot
                };
                currentProfile   = new AzureSMProfile();
                var subscription = new AzureSubscription {
                    Id = new Guid(base.subscriptionId)
                };
                subscription.Properties[AzureSubscription.Property.Default] = "True";
                currentProfile.Subscriptions[new Guid(base.subscriptionId)] = subscription;

                getAzureWebsiteLogCommand.DefaultCurrentPath = AppDomain.CurrentDomain.BaseDirectory;
                getAzureWebsiteLogCommand.ExecuteCmdlet();
                Assert.Equal("test", FileUtilities.DataStore.ReadFileAsText(
                                 Path.Combine(AppDomain.CurrentDomain.BaseDirectory, SaveAzureWebsiteLogCommand.DefaultOutput)));
            });
        }
        public void SaveAzureWebsiteLogWithNoFileExtensionTest()
        {
            TestExecutionHelpers.RetryAction(
                () =>
            {
                // Setup
                string expectedOutput = Path.Combine(AppDomain.CurrentDomain.BaseDirectory, "file_without_ext.zip");

                SimpleDeploymentServiceManagement deploymentChannel = new SimpleDeploymentServiceManagement
                {
                    DownloadLogsThunk = ar => new MemoryStream(Encoding.UTF8.GetBytes("test with no extension"))
                };

                // Test
                SaveAzureWebsiteLogCommand getAzureWebsiteLogCommand = new SaveAzureWebsiteLogCommand(deploymentChannel)
                {
                    Name           = "website1",
                    ShareChannel   = true,
                    WebsitesClient = clientMock.Object,
                    CommandRuntime = new MockCommandRuntime(),
                    Output         = "file_without_ext"
                };
                currentProfile   = new AzureSMProfile();
                var subscription = new AzureSubscription {
                    Id = base.subscriptionId
                };
                subscription.SetDefault();
                currentProfile.SubscriptionTable[new Guid(base.subscriptionId)] = subscription;

                getAzureWebsiteLogCommand.DefaultCurrentPath = AppDomain.CurrentDomain.BaseDirectory;
                getAzureWebsiteLogCommand.ExecuteCmdlet();
                Assert.Equal("test with no extension", FileUtilities.DataStore.ReadFileAsText(expectedOutput));
            });
        }
 public void ParseTemplateParameterFileContents_DeserializeWithCorrectType()
 {
     // Add up to 3 retries for flaky test
     TestExecutionHelpers.RetryAction(() =>
     {
         Dictionary <string, TemplateFileParameterV1> result =
             TemplateUtility.ParseTemplateParameterFileContents(@"Resources/WebSite.param.dev.json".AsAbsoluteLocation());
         Assert.True(result["isWorker"].Value as bool?);
         Assert.Equal((System.Int64) 1, result["numberOfWorker"].Value);
     });
 }
예제 #4
0
        public void WaitOnJobCompletesImmediately()
        {
            // Fix test flakiness
            TestExecutionHelpers.RetryAction(
                () =>
            {
                Guid jobId = Guid.NewGuid();

                MockRequestChannel mockChannel = MockRequestChannel.Create();
                mockChannel.AddReturnObject(new Job {
                    Name = "TestJob", ID = jobId, IsCompleted = true
                });

                var jobOperations = new JobOperations(new WebClientFactory(
                                                          new Subscription(),
                                                          mockChannel));
                DateTime start = DateTime.Now;
                jobOperations.WaitOnJob(jobId);
                Assert.True((DateTime.Now - start).TotalMilliseconds < 500);
            });
        }