aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorEylon Malin <eylon.malin@intl.att.com>2019-08-15 11:39:22 +0300
committerEylon Malin <eylon.malin@intl.att.com>2019-08-15 11:51:00 +0300
commit7bb28ca74c56e7312d41f8e152bc40d255172cdb (patch)
treee343e3b17880e6535233b1cdc73aec2e6af24973
parent1eaeae75f218b96e3214c8a79de3239413e0aa95 (diff)
Skip log format validation for a week
Add annotation SkipTestUntil and TestNg transformer so we can add annotation for skip test till some date (aka time bomb) Use it in log format tests Issue-ID: VID-378 Signed-off-by: Eylon Malin <eylon.malin@intl.att.com> Change-Id: Ib4b5d17d73d360fd2554b5ffc0373790d22d9e4e Signed-off-by: Eylon Malin <eylon.malin@intl.att.com>
-rw-r--r--vid-automation/TestNg-ApiTest.xml3
-rw-r--r--vid-automation/TestNg-UI-half.xml3
-rw-r--r--vid-automation/TestNg-dev.xml3
-rw-r--r--vid-automation/src/main/java/vid/automation/test/infra/SkipTestUntil.java21
-rw-r--r--vid-automation/src/main/java/vid/automation/test/infra/SkipTestUntilTestngTransformer.java57
-rw-r--r--vid-automation/src/test/java/org/onap/vid/more/LoggerFormatTest.java3
6 files changed, 87 insertions, 3 deletions
diff --git a/vid-automation/TestNg-ApiTest.xml b/vid-automation/TestNg-ApiTest.xml
index ddd0f7ba3..9e9380faa 100644
--- a/vid-automation/TestNg-ApiTest.xml
+++ b/vid-automation/TestNg-ApiTest.xml
@@ -4,6 +4,7 @@
<listeners>
<listener class-name="vid.automation.test.infra.FeatureTogglingTestngTransformer" />
+ <listener class-name="vid.automation.test.infra.SkipTestUntilTestngTransformer"/>
</listeners>
<test name="test">
@@ -48,4 +49,4 @@
<package name="org.onap.vid.*"/>
</packages>
</test>
-</suite> \ No newline at end of file
+</suite>
diff --git a/vid-automation/TestNg-UI-half.xml b/vid-automation/TestNg-UI-half.xml
index 01cdfcc5e..b19073869 100644
--- a/vid-automation/TestNg-UI-half.xml
+++ b/vid-automation/TestNg-UI-half.xml
@@ -3,6 +3,7 @@
<suite verbose="1" name="VID UI Tests" annotations="JDK">
<listeners>
<listener class-name="vid.automation.test.infra.FeatureTogglingTestngTransformer"/>
+ <listener class-name="vid.automation.test.infra.SkipTestUntilTestngTransformer"/>
</listeners>
<test name="test">
<method-selectors>
@@ -64,4 +65,4 @@
<package name="vid.automation.test.test.*"/>
</packages>
</test>
-</suite> \ No newline at end of file
+</suite>
diff --git a/vid-automation/TestNg-dev.xml b/vid-automation/TestNg-dev.xml
index b8bc84f96..3dc9d749d 100644
--- a/vid-automation/TestNg-dev.xml
+++ b/vid-automation/TestNg-dev.xml
@@ -5,6 +5,7 @@
<suite verbose="1" name="VID UI Tests" annotations="JDK">
<listeners>
<listener class-name="vid.automation.test.infra.FeatureTogglingTestngTransformer"/>
+ <listener class-name="vid.automation.test.infra.SkipTestUntilTestngTransformer"/>
</listeners>
<test name="test">
<groups>
@@ -38,4 +39,4 @@
<class name="vid.automation.test.test.NewServiceInstanceTest"/>
</classes>
</test>
-</suite> \ No newline at end of file
+</suite>
diff --git a/vid-automation/src/main/java/vid/automation/test/infra/SkipTestUntil.java b/vid-automation/src/main/java/vid/automation/test/infra/SkipTestUntil.java
new file mode 100644
index 000000000..5aad0e03a
--- /dev/null
+++ b/vid-automation/src/main/java/vid/automation/test/infra/SkipTestUntil.java
@@ -0,0 +1,21 @@
+package vid.automation.test.infra;
+
+import static java.lang.annotation.ElementType.METHOD;
+
+import java.lang.annotation.Retention;
+import java.lang.annotation.RetentionPolicy;
+import java.lang.annotation.Target;
+
+/*
+Skip test until date (AKA TimeBomb)
+ */
+@Retention(RetentionPolicy.RUNTIME)
+@Target({METHOD})
+public @interface SkipTestUntil {
+
+ /**
+ * Date in the form of "2007-12-20"
+ */
+ String value();
+
+}
diff --git a/vid-automation/src/main/java/vid/automation/test/infra/SkipTestUntilTestngTransformer.java b/vid-automation/src/main/java/vid/automation/test/infra/SkipTestUntilTestngTransformer.java
new file mode 100644
index 000000000..2d2ce7cde
--- /dev/null
+++ b/vid-automation/src/main/java/vid/automation/test/infra/SkipTestUntilTestngTransformer.java
@@ -0,0 +1,57 @@
+package vid.automation.test.infra;
+
+import java.lang.reflect.Constructor;
+import java.lang.reflect.Method;
+import java.time.LocalDate;
+import org.testng.IAnnotationTransformer;
+import org.testng.annotations.ITestAnnotation;
+
+/*
+TestNg listener that skip tests that are annotated with SkipTestUntil annotation
+Pay attention that this listener shall be configured in the testng.xml (or command line)
+*/
+public class SkipTestUntilTestngTransformer implements IAnnotationTransformer {
+
+ @Override
+ public void transform(ITestAnnotation annotation, Class testClass, Constructor testConstructor, Method testMethod) {
+
+ if (testMethod!=null) {
+ try {
+
+ if (!annotation.getEnabled()) {
+ return;
+ }
+
+ if (!testMethod.isAnnotationPresent(SkipTestUntil.class)) {
+ return;
+ }
+
+ String dateAsStr = testMethod.getAnnotation(SkipTestUntil.class).value();
+ if (shallDisableTest(dateAsStr)) {
+ disableTest(annotation, testMethod.getDeclaringClass().getName(), dateAsStr);
+ }
+
+ } catch (Exception e) {
+ e.printStackTrace();
+ }
+ }
+ }
+
+ private boolean shallDisableTest(String dateAsStr) {
+ try {
+ return LocalDate.now().isBefore(LocalDate.parse(dateAsStr));
+ }
+ catch (RuntimeException exception) {
+ System.out.println("Failure during processing of SkipTestUntil annotation value is " + dateAsStr);
+ exception.printStackTrace();
+ return false;
+ }
+ }
+
+ private void disableTest(ITestAnnotation annotation, String name, String dateAsStr) {
+ System.out.println("Ignore "+ name+" till "+dateAsStr);
+ annotation.setEnabled(false);
+ }
+
+}
+
diff --git a/vid-automation/src/test/java/org/onap/vid/more/LoggerFormatTest.java b/vid-automation/src/test/java/org/onap/vid/more/LoggerFormatTest.java
index d72337f3d..20367ea70 100644
--- a/vid-automation/src/test/java/org/onap/vid/more/LoggerFormatTest.java
+++ b/vid-automation/src/test/java/org/onap/vid/more/LoggerFormatTest.java
@@ -9,6 +9,7 @@ import org.onap.vid.api.BaseApiTest;
import org.springframework.web.client.RestTemplate;
import org.testng.annotations.BeforeClass;
import org.testng.annotations.Test;
+import vid.automation.test.infra.SkipTestUntil;
import vid.automation.test.services.SimulatorApi;
import java.net.URI;
@@ -37,6 +38,7 @@ public class LoggerFormatTest extends BaseApiTest {
SimulatorApi.registerExpectationFromPreset(new PresetAAIGetSubscribersGet(), SimulatorApi.RegistrationStrategy.CLEAR_THEN_SET);
}
+ @SkipTestUntil("2019-08-22")
@Test
public void validateAuditLogsFormat() {
validateLogsFormat("audit");
@@ -47,6 +49,7 @@ public class LoggerFormatTest extends BaseApiTest {
validateLogsFormat("error");
}
+ @SkipTestUntil("2019-08-22")
@Test
public void validateMetricsLogsFormat() {
validateLogsFormat("metrics", "metric");