From 4d0ac819fef8e92fb6eab3512f6e1d5b8cdae5a7 Mon Sep 17 00:00:00 2001 From: RTLcoil Date: Mon, 9 Nov 2020 04:22:28 +0200 Subject: [PATCH] Improve integration tests that rely on add-ons --- .../AdminApi/UpdateResourcesTest.cs | 2 +- Shared.IntegrationTests/IntegrationTestBase.cs | 17 ++++++++++++----- .../UploadApi/ExplicitMethodsTest.cs | 2 +- .../UploadApi/UploadMethodsTest.cs | 6 +++--- 4 files changed, 17 insertions(+), 10 deletions(-) diff --git a/Shared.IntegrationTests/AdminApi/UpdateResourcesTest.cs b/Shared.IntegrationTests/AdminApi/UpdateResourcesTest.cs index 4b57a1be..f3606072 100644 --- a/Shared.IntegrationTests/AdminApi/UpdateResourcesTest.cs +++ b/Shared.IntegrationTests/AdminApi/UpdateResourcesTest.cs @@ -43,7 +43,7 @@ public void TestOcrUpdate() Assert.True(updateResult.Error.Message.StartsWith(ILLEGAL_MESSAGE)); } - [Test, IgnoreAddon("adv_ocr")] + [Test, IgnoreAddon("ocr"), RetryWithDelay] public void TestOcrUpdateResult() { // should support requesting ocr info from adv_ocr addon diff --git a/Shared.IntegrationTests/IntegrationTestBase.cs b/Shared.IntegrationTests/IntegrationTestBase.cs index f199191c..5d6ecc6e 100644 --- a/Shared.IntegrationTests/IntegrationTestBase.cs +++ b/Shared.IntegrationTests/IntegrationTestBase.cs @@ -486,7 +486,7 @@ public class IgnoreAddonAttribute : Attribute, ITestAction public IgnoreAddonAttribute(string name) { - _mAddonName = name; + _mAddonName = (name ?? string.Empty).ToLower(); } public ActionTargets Targets { get; private set; } @@ -495,10 +495,17 @@ public void AfterTest(ITest test) { } public void BeforeTest(ITest test) { - var addonsToRun = Environment.GetEnvironmentVariable("CLD_TEST_ADDONS"); - if (string.IsNullOrEmpty(addonsToRun) || - !addonsToRun.Contains(_mAddonName) && - !addonsToRun.ToLower().Equals("all")) + var environmentVariable = Environment.GetEnvironmentVariable("CLD_TEST_ADDONS"); + var addonsList = (environmentVariable ?? string.Empty).ToLower() + .Split(',') + .Select(addon => addon.Trim()) + .ToList(); + + var allTestsShouldRun = addonsList.Count == 1 && addonsList[0] == "all"; + var addonNotInList = !addonsList.Contains(_mAddonName); + var noAddonsDefined = !addonsList.Any(); + + if (noAddonsDefined || addonNotInList && !allTestsShouldRun) { Assert.Ignore( $"Please enable {_mAddonName} plugin in your account and set CLD_TEST_ADDONS environment variable"); diff --git a/Shared.IntegrationTests/UploadApi/ExplicitMethodsTest.cs b/Shared.IntegrationTests/UploadApi/ExplicitMethodsTest.cs index fc345011..73756cfa 100644 --- a/Shared.IntegrationTests/UploadApi/ExplicitMethodsTest.cs +++ b/Shared.IntegrationTests/UploadApi/ExplicitMethodsTest.cs @@ -472,7 +472,7 @@ public void TestPredominant() Assert.NotZero(explicitResult.Predominant.Cloudinary.Length); } - [Test, IgnoreAddon("webpurify")] + [Test, IgnoreAddon("webpurify"), RetryWithDelay] public void TestWebPurifyForExplicitResult() { var explicitResult = ArrangeAndGetExplicitResult(true); diff --git a/Shared.IntegrationTests/UploadApi/UploadMethodsTest.cs b/Shared.IntegrationTests/UploadApi/UploadMethodsTest.cs index 98427070..f8ad712b 100644 --- a/Shared.IntegrationTests/UploadApi/UploadMethodsTest.cs +++ b/Shared.IntegrationTests/UploadApi/UploadMethodsTest.cs @@ -267,7 +267,7 @@ public void TestModerationManual() Assert.AreEqual(ModerationStatus.Pending, getResult.Moderation[0].Status); } - [Test, IgnoreAddon("aws_rek")] + [Test, IgnoreAddon("rekognition"), RetryWithDelay] public void TestModerationAwsRek() { var uploadParams = new ImageUploadParams() @@ -284,7 +284,7 @@ public void TestModerationAwsRek() Assert.AreEqual(MODERATION_AWS_REK, uploadResult.Moderation[0].Kind); } - [Test, IgnoreAddon("webpurify")] + [Test, IgnoreAddon("webpurify"), RetryWithDelay] public void TestModerationWebpurify() { var uploadParams = new ImageUploadParams() @@ -300,7 +300,7 @@ public void TestModerationWebpurify() Assert.AreEqual(MODERATION_WEBPURIFY, uploadResult.Moderation[0].Kind); } - [Test, IgnoreAddon("rekognition")] + [Test, IgnoreAddon("rekognition"), RetryWithDelay] public void TestRekognitionFace() { // should support rekognition face