jmeter-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From fschumac...@apache.org
Subject [jmeter] 01/02: Skip broken test when DST change is near
Date Sat, 18 Sep 2021 12:28:24 GMT
This is an automated email from the ASF dual-hosted git repository.

fschumacher pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/jmeter.git

commit 3e09665d27d9a001f26bcb56d606706136d9b89a
Author: Felix Schumacher <felix.schumacher@internetallee.de>
AuthorDate: Sat Sep 18 14:23:21 2021 +0200

    Skip broken test when DST change is near
    
    This is a temporary fix for broken builds until the real problem
    is solved.
    
    See Bugzilla 65217 and PR 561 for more information
    
    Bugzilla Id: 65217
---
 .../jmeter/functions/TestTimeShiftFunction.java     | 21 +++++++++++++++++++++
 1 file changed, 21 insertions(+)

diff --git a/src/functions/src/test/java/org/apache/jmeter/functions/TestTimeShiftFunction.java
b/src/functions/src/test/java/org/apache/jmeter/functions/TestTimeShiftFunction.java
index 154fe70..22c19a2 100644
--- a/src/functions/src/test/java/org/apache/jmeter/functions/TestTimeShiftFunction.java
+++ b/src/functions/src/test/java/org/apache/jmeter/functions/TestTimeShiftFunction.java
@@ -24,15 +24,19 @@ import static org.hamcrest.CoreMatchers.equalTo;
 import static org.hamcrest.CoreMatchers.is;
 import static org.hamcrest.MatcherAssert.assertThat;
 
+import java.time.Duration;
 import java.time.Instant;
 import java.time.LocalDate;
 import java.time.LocalDateTime;
+import java.time.ZoneId;
 import java.time.ZonedDateTime;
 import java.time.format.DateTimeFormatter;
 import java.time.temporal.ChronoUnit;
+import java.time.zone.ZoneRules;
 import java.util.Collection;
 import java.util.Random;
 import java.util.TimeZone;
+import java.util.function.BooleanSupplier;
 
 import org.apache.jmeter.engine.util.CompoundVariable;
 import org.apache.jmeter.junit.JMeterTestCase;
@@ -40,6 +44,7 @@ import org.apache.jmeter.samplers.SampleResult;
 import org.apache.jmeter.threads.JMeterContext;
 import org.apache.jmeter.threads.JMeterContextService;
 import org.apache.jmeter.threads.JMeterVariables;
+import org.junit.jupiter.api.Assumptions;
 import org.junit.jupiter.api.BeforeEach;
 import org.junit.jupiter.api.Test;
 
@@ -108,6 +113,10 @@ public class TestTimeShiftFunction extends JMeterTestCase {
 
     @Test
     public void testNowWithComplexPeriod() throws Exception {
+        // Workaround to skip test, when we know it will fail
+        // See Bug 65217 and PR 561 for discussions on how to fix the underlying issue
+        Assumptions.assumeFalse(dstChangeAhead("P10DT-1H-5M5S"));
+
         Collection<CompoundVariable> params = makeParams("yyyy-MM-dd'T'HH:mm:ss", "",
"P10DT-1H-5M5S", "");
         function.setParameters(params);
         value = function.execute(result, null);
@@ -116,6 +125,18 @@ public class TestTimeShiftFunction extends JMeterTestCase {
         assertThat(futureDateFromFunction, within(1, ChronoUnit.SECONDS, futureDate));
     }
 
+    private BooleanSupplier dstChangeAhead(String string) {
+        return () -> {
+            ZoneId defaultZoneId = ZoneId.systemDefault();
+            Instant now = LocalDateTime.now().atZone(defaultZoneId).toInstant();
+            Instant then = LocalDateTime.now().plus(Duration.parse(string)).atZone(defaultZoneId).toInstant();
+            ZoneRules rules = defaultZoneId.getRules();
+            Duration nowDST = rules.getDaylightSavings(now);
+            Duration thenDST = rules.getDaylightSavings(then);
+            return !nowDST.equals(thenDST);
+        };
+    }
+
     @Test
     public void testPotentialBugWithComplexPeriod() throws Exception {
         Collection<CompoundVariable> params = makeParams("yyyy-MM-dd'T'HH:mm:ss", "2017-12-21T12:00:00",
"P10DT-1H-5M5S", "");

Mime
View raw message