|
15 | 15 | namespace Microsoft.Azure.WebJobs.Script.Tests
|
16 | 16 | {
|
17 | 17 | [Trait("Category", "E2E")]
|
18 |
| - public class ScriptHostManagerTests |
| 18 | + public class ScriptHostManagerTests |
19 | 19 | {
|
20 | 20 | // Update a script file (the function.json) to force the ScriptHost to re-index and pick up new changes.
|
21 | 21 | // Test with timers:
|
22 | 22 | [Fact]
|
23 | 23 | public async Task UpdateFileAndRestart()
|
24 | 24 | {
|
25 |
| - Random r = new Random(); |
26 |
| - |
27 | 25 | CancellationTokenSource cts = new CancellationTokenSource();
|
28 | 26 |
|
29 | 27 | var fixture = new NodeEndToEndTests.TestFixture();
|
30 | 28 | var blob1 = UpdateOutputName("testblob", "first", fixture);
|
31 | 29 |
|
32 | 30 | await fixture.Host.StopAsync();
|
33 |
| - var config = fixture.Host.ScriptConfig; |
| 31 | + var config = fixture.Host.ScriptConfig; |
| 32 | + |
| 33 | + var success = true; |
34 | 34 |
|
35 | 35 | using (var manager = new ScriptHostManager(config))
|
36 | 36 | {
|
37 | 37 | // Background task to run while the main thread is pumping events at RunAndBlock().
|
38 | 38 | Thread t = new Thread(_ =>
|
39 | 39 | {
|
40 |
| - // Wait for initial execution. |
41 |
| - TestHelpers.Await(() => |
| 40 | + try |
42 | 41 | {
|
43 |
| - return blob1.Exists(); |
44 |
| - }, timeout: 10 * 1000).Wait(); |
45 |
| - |
46 |
| - // This changes the bindings so that we now write to blob2 |
47 |
| - var blob2 = UpdateOutputName("first", "second", fixture); |
48 |
| - |
49 |
| - // wait for newly executed |
50 |
| - TestHelpers.Await(() => |
| 42 | + // Wait for initial execution. |
| 43 | + TestHelpers.Await(() => |
| 44 | + { |
| 45 | + return blob1.Exists(); |
| 46 | + }, timeout: 10 * 1000).Wait(); |
| 47 | + |
| 48 | + // This changes the bindings so that we now write to blob2 |
| 49 | + var blob2 = UpdateOutputName("first", "second", fixture); |
| 50 | + |
| 51 | + // wait for newly executed |
| 52 | + TestHelpers.Await(() => |
| 53 | + { |
| 54 | + return blob2.Exists(); |
| 55 | + }, timeout: 30 * 1000).Wait(); |
| 56 | + } |
| 57 | + catch |
51 | 58 | {
|
52 |
| - return blob2.Exists(); |
53 |
| - }, timeout: 10 * 1000).Wait(); |
| 59 | + success = false; |
| 60 | + } |
54 | 61 |
|
55 |
| - manager.Stop(); |
| 62 | + cts.Cancel(); |
56 | 63 | });
|
57 |
| - t.Start(); |
| 64 | + t.Start(); |
58 | 65 |
|
59 | 66 | manager.RunAndBlock(cts.Token);
|
60 | 67 |
|
61 | 68 | t.Join();
|
| 69 | + |
| 70 | + Assert.True(success); |
62 | 71 | }
|
63 | 72 | }
|
64 | 73 |
|
@@ -175,7 +184,7 @@ private static CloudBlockBlob UpdateOutputName(string prev, string hint, EndToEn
|
175 | 184 | string name = hint;
|
176 | 185 |
|
177 | 186 | string manifestPath = Path.Combine(Environment.CurrentDirectory, @"TestScripts\Node\TimerTrigger\function.json");
|
178 |
| - string content = File.ReadAllText(manifestPath); |
| 187 | + string content = File.ReadAllText(manifestPath); |
179 | 188 | content = content.Replace(prev, name);
|
180 | 189 | File.WriteAllText(manifestPath, content);
|
181 | 190 |
|
|
0 commit comments