Beispiel #1
0
        public void InPlaceJobRunsInPlace()
        {
            RunScenario("InPlaceJobRunsInPlace", appManager =>
            {
                const string jobName = "joba";
                var expectedTempStr  = appManager.ServiceUrl.Contains("localhost")
                    ? $@"Temp\{appManager.ApplicationName}\jobs\triggered\{jobName}"
                    : $@"Temp\jobs\triggered\{jobName}";
                var expectedAppDataStr = $@"App_Data\jobs\triggered\{jobName}";

                TestTracer.Trace("Create the triggered WebJob");
                appManager.JobsManager.CreateTriggeredJobAsync(jobName, "run.cmd", "cd\n").Wait();

                TestTracer.Trace("Trigger the triggered WebJob");
                VerifyTriggeredJobTriggers(appManager, jobName, 1, "Success", expectedTempStr);

                var jobSettings = new JobSettings();

                TestTracer.Trace("Set triggered WebJob to is_in_place true");
                jobSettings.SetSetting("is_in_place", true);
                appManager.JobsManager.SetTriggeredJobSettingsAsync(jobName, jobSettings).Wait();

                TestTracer.Trace("Trigger the triggered WebJob");
                VerifyTriggeredJobTriggers(appManager, jobName, 2, "Success", expectedAppDataStr);

                TestTracer.Trace("Set triggered WebJob to is_in_place false");
                jobSettings.SetSetting("is_in_place", false);
                appManager.JobsManager.SetTriggeredJobSettingsAsync(jobName, jobSettings).Wait();

                TestTracer.Trace("Trigger the triggered WebJob");
                VerifyTriggeredJobTriggers(appManager, jobName, 3, "Success", expectedTempStr);

                TestTracer.Trace("Create the continuous WebJob");
                appManager.JobsManager.CreateContinuousJobAsync(jobName, "run.cmd", "cd > %WEBROOT_PATH%\\..\\..\\LogFiles\\verification.txt.%WEBSITE_INSTANCE_ID%\n").Wait();

                WaitUntilAssertVerified(
                    "verification file",
                    TimeSpan.FromSeconds(30),
                    () => VerifyVerificationFile(appManager, new[] { expectedTempStr }));

                TestTracer.Trace("Set continuous WebJob to is_in_place true");
                jobSettings.SetSetting("is_in_place", true);
                appManager.JobsManager.SetContinuousJobSettingsAsync(jobName, jobSettings).Wait();

                WaitUntilAssertVerified(
                    "verification file",
                    TimeSpan.FromSeconds(30),
                    () => VerifyVerificationFile(appManager, new[] { expectedAppDataStr }));

                TestTracer.Trace("Set continuous WebJob to is_in_place false");
                jobSettings.SetSetting("is_in_place", false);

                appManager.JobsManager.SetContinuousJobSettingsAsync(jobName, jobSettings).Wait();
                WaitUntilAssertVerified(
                    "verification file",
                    TimeSpan.FromSeconds(30),
                    () => VerifyVerificationFile(appManager, new[] { expectedTempStr }));
            });
        }
Beispiel #2
0
        public void JobsSettingsSetSuccessfully()
        {
            RunScenario("JobsSettingsSetSuccessfully", appManager =>
            {
                const string triggeredJobName  = "triggeredJob";
                const string continuousJobName = "continuousJob";

                const string settingKey   = "mysetting";
                const string settingValue = "myvalue";

                TestTracer.Trace("Creating a triggered job and creating a continuous job");

                appManager.JobsManager.CreateTriggeredJobAsync(triggeredJobName, "run.cmd", JobScript).Wait();
                appManager.JobsManager.CreateContinuousJobAsync(continuousJobName, "run.cmd", JobScript).Wait();

                TestTracer.Trace("Test update of continuous job settings");

                JobSettings continuousJobSettings = appManager.JobsManager.GetContinuousJobSettingsAsync(continuousJobName).Result;
                Assert.Equal(null, continuousJobSettings.GetSetting <string>(settingKey));

                continuousJobSettings.SetSetting(settingKey, settingValue);
                appManager.JobsManager.SetContinuousJobSettingsAsync(continuousJobName, continuousJobSettings).Wait();

                continuousJobSettings = appManager.JobsManager.GetContinuousJobSettingsAsync(continuousJobName).Result;
                Assert.Equal(settingValue, continuousJobSettings.GetSetting <string>(settingKey));

                TestTracer.Trace("Test update of triggered job settings");

                JobSettings triggeredJobSettings = appManager.JobsManager.GetTriggeredJobSettingsAsync(triggeredJobName).Result;
                Assert.Equal(null, triggeredJobSettings.GetSetting <string>(settingKey));

                triggeredJobSettings.SetSetting(settingKey, settingValue);
                appManager.JobsManager.SetTriggeredJobSettingsAsync(triggeredJobName, triggeredJobSettings).Wait();

                triggeredJobSettings = appManager.JobsManager.GetTriggeredJobSettingsAsync(triggeredJobName).Result;
                Assert.Equal(settingValue, triggeredJobSettings.GetSetting <string>(settingKey));
            });
        }
Beispiel #3
0
        public void ContinuousJobStartsAfterGoingDown()
        {
            RunScenario("ContinuousJobStartsAfterGoingDown", appManager =>
            {
                TestTracer.Trace("Copying the script to the continuous job directory");

                appManager.JobsManager.CreateContinuousJobAsync("basicJob1", "run.cmd", JobScript).Wait();

                var expectedContinuousJob = new ContinuousJob()
                {
                    Name       = "basicJob1",
                    JobType    = "continuous",
                    Status     = "PendingRestart",
                    RunCommand = "run.cmd"
                };

                WaitUntilAssertVerified(
                    "verify continuous job",
                    TimeSpan.FromSeconds(60),
                    () =>
                {
                    ContinuousJob deployedJob = appManager.JobsManager.GetContinuousJobAsync("basicJob1").Result;
                    AssertContinuousJob(expectedContinuousJob, deployedJob);
                });

                TestTracer.Trace("Waiting for verification file to have 2 lines (which means it ran twice)");

                var expectedVerificationFileContents = new List <string>();
                expectedVerificationFileContents.Add(ExpectedVerificationFileContent);
                expectedVerificationFileContents.Add(ExpectedVerificationFileContent);

                WaitUntilAssertVerified(
                    "verification file",
                    TimeSpan.FromSeconds(30),
                    () => VerifyVerificationFile(appManager, expectedVerificationFileContents.ToArray()));

                TestTracer.Trace("Verify continuous job settings and set it to isSingleton: true");
                JobSettings continuousJobSettings =
                    appManager.JobsManager.GetContinuousJobSettingsAsync(expectedContinuousJob.Name).Result;

                Assert.False(continuousJobSettings.IsSingleton);

                continuousJobSettings.SetSetting("is_singleton", true);
                appManager.JobsManager.SetContinuousJobSettingsAsync(expectedContinuousJob.Name, continuousJobSettings).Wait();

                expectedVerificationFileContents.Add(ExpectedVerificationFileContent);
                expectedVerificationFileContents.Add(ExpectedVerificationFileContent);

                WaitUntilAssertVerified(
                    "verification file",
                    TimeSpan.FromSeconds(30),
                    () => VerifyVerificationFile(appManager, expectedVerificationFileContents.ToArray()));

                TestTracer.Trace("Verify continuous job settings and set it to isSingleton: false");
                continuousJobSettings =
                    appManager.JobsManager.GetContinuousJobSettingsAsync(expectedContinuousJob.Name).Result;

                Assert.True(continuousJobSettings.GetSetting <bool>("is_singleton"));

                continuousJobSettings.SetSetting("is_singleton", false);
                appManager.JobsManager.SetContinuousJobSettingsAsync(expectedContinuousJob.Name, continuousJobSettings).Wait();

                expectedVerificationFileContents.Add(ExpectedVerificationFileContent);
                expectedVerificationFileContents.Add(ExpectedVerificationFileContent);

                WaitUntilAssertVerified(
                    "verification file",
                    TimeSpan.FromSeconds(30),
                    () => VerifyVerificationFile(appManager, expectedVerificationFileContents.ToArray()));
            });
        }
        public void InPlaceJobRunsInPlace()
        {
            RunScenario("InPlaceJobRunsInPlace", appManager =>
            {
                const string jobName = "joba";
                const string expectedTempStr = "Temp\\jobs\\triggered\\" + jobName;
                const string expectedAppDataStr = "App_Data\\jobs\\triggered\\" + jobName;

                TestTracer.Trace("Create the triggered WebJob");
                appManager.JobsManager.CreateTriggeredJobAsync(jobName, "run.cmd", "cd\n").Wait();

                TestTracer.Trace("Trigger the triggered WebJob");
                VerifyTriggeredJobTriggers(appManager, jobName, 1, "Success", expectedTempStr);

                var jobSettings = new JobSettings();

                TestTracer.Trace("Set triggered WebJob to is_in_place true");
                jobSettings.SetSetting("is_in_place", true);
                appManager.JobsManager.SetTriggeredJobSettingsAsync(jobName, jobSettings).Wait();

                TestTracer.Trace("Trigger the triggered WebJob");
                VerifyTriggeredJobTriggers(appManager, jobName, 2, "Success", expectedAppDataStr);

                TestTracer.Trace("Set triggered WebJob to is_in_place false");
                jobSettings.SetSetting("is_in_place", false);
                appManager.JobsManager.SetTriggeredJobSettingsAsync(jobName, jobSettings).Wait();

                TestTracer.Trace("Trigger the triggered WebJob");
                VerifyTriggeredJobTriggers(appManager, jobName, 3, "Success", expectedTempStr);

                TestTracer.Trace("Create the continuous WebJob");
                appManager.JobsManager.CreateContinuousJobAsync(jobName, "run.cmd", "cd > %WEBROOT_PATH%\\..\\..\\LogFiles\\verification.txt.%WEBSITE_INSTANCE_ID%\n").Wait();

                WaitUntilAssertVerified(
                    "verification file",
                    TimeSpan.FromSeconds(30),
                    () => VerifyVerificationFile(appManager, new[] { expectedTempStr }));

                TestTracer.Trace("Set continuous WebJob to is_in_place true");
                jobSettings.SetSetting("is_in_place", true);
                appManager.JobsManager.SetContinuousJobSettingsAsync(jobName, jobSettings).Wait();

                WaitUntilAssertVerified(
                    "verification file",
                    TimeSpan.FromSeconds(30),
                    () => VerifyVerificationFile(appManager, new[] { expectedAppDataStr }));

                TestTracer.Trace("Set continuous WebJob to is_in_place false");
                jobSettings.SetSetting("is_in_place", false);

                appManager.JobsManager.SetContinuousJobSettingsAsync(jobName, jobSettings).Wait();
                WaitUntilAssertVerified(
                    "verification file",
                    TimeSpan.FromSeconds(30),
                    () => VerifyVerificationFile(appManager, new[] { expectedTempStr }));
            });
        }