Skip to content

Commit dc3e55e

Browse files
committed
Fixing flaky/skipped blob trigger test (#386)
1 parent 4307d60 commit dc3e55e

File tree

5 files changed

+25
-36
lines changed

5 files changed

+25
-36
lines changed

test/WebJobs.Script.Tests/BashEndToEndTests.cs

Lines changed: 24 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -15,28 +15,42 @@ public BashEndToEndTests(TestFixture fixture)
1515
{
1616
}
1717

18-
[Fact(Skip = "Flaky test. Need to fix")]
18+
[Fact]
1919
public async Task BlobTriggerToBlobTest()
2020
{
21-
string name = Guid.NewGuid().ToString();
22-
string blobContents = "My Test Blob";
23-
CloudBlobContainer inputContainer = Fixture.BlobClient.GetContainerReference("test-input-bash");
24-
inputContainer.CreateIfNotExists();
25-
CloudBlockBlob inputBlob = inputContainer.GetBlockBlobReference(name);
26-
await inputBlob.UploadTextAsync(blobContents);
27-
21+
// the trigger blob was written by the fixture init code
22+
// here we just wait for the output blob
2823
CloudBlobContainer outputContainer = Fixture.BlobClient.GetContainerReference("test-output-bash");
29-
var resultBlob = outputContainer.GetBlockBlobReference(name);
24+
var resultBlob = outputContainer.GetBlockBlobReference(Fixture.TestBlobName);
3025
await TestHelpers.WaitForBlobAsync(resultBlob);
3126

3227
string resultContents = resultBlob.DownloadText();
33-
Assert.Equal(blobContents, resultContents.Trim());
28+
Assert.Equal(Fixture.TestBlobContents, resultContents.Trim());
3429
}
3530

3631
public class TestFixture : EndToEndTestFixture
3732
{
3833
public TestFixture() : base(@"TestScripts\Bash", "bash")
34+
{
35+
}
36+
37+
public string TestBlobContents { get; private set; }
38+
39+
public string TestBlobName { get; private set; }
40+
41+
protected override void CreateTestStorageEntities()
3942
{
43+
base.CreateTestStorageEntities();
44+
45+
TestBlobContents = "My Test Blob";
46+
TestBlobName = Guid.NewGuid().ToString();
47+
48+
// write the test blob before the host starts, so it gets picked
49+
// up relatively quickly by the blob trigger test
50+
CloudBlobContainer inputContainer = BlobClient.GetContainerReference("test-input-bash");
51+
inputContainer.CreateIfNotExists();
52+
CloudBlockBlob inputBlob = inputContainer.GetBlockBlobReference(TestBlobName);
53+
inputBlob.UploadText(TestBlobContents);
4054
}
4155
}
4256
}

test/WebJobs.Script.Tests/EndToEndTestFixture.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -71,7 +71,7 @@ public CloudQueue GetNewQueue(string queueName)
7171
return queue;
7272
}
7373

74-
private void CreateTestStorageEntities()
74+
protected virtual void CreateTestStorageEntities()
7575
{
7676
TestQueue = QueueClient.GetQueueReference(string.Format("test-input-{0}", _testId));
7777
TestQueue.CreateIfNotExists();

test/WebJobs.Script.Tests/TestScripts/CSharp/BlobTrigger/function.json

Lines changed: 0 additions & 9 deletions
This file was deleted.

test/WebJobs.Script.Tests/TestScripts/CSharp/BlobTrigger/run.csx

Lines changed: 0 additions & 10 deletions
This file was deleted.

test/WebJobs.Script.Tests/WebJobs.Script.Tests.csproj

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -345,12 +345,6 @@
345345
<None Include="TestScripts\CSharp\ApiHubFileTrigger\run.csx">
346346
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
347347
</None>
348-
<None Include="TestScripts\CSharp\BlobTrigger\function.json">
349-
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
350-
</None>
351-
<None Include="TestScripts\CSharp\BlobTrigger\run.csx">
352-
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
353-
</None>
354348
<None Include="TestScripts\CSharp\DocumentDBIn\function.json">
355349
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
356350
</None>

0 commit comments

Comments
 (0)