This is an automated email from the ASF dual-hosted git repository.

wuweijie pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/shardingsphere-elasticjob.git


The following commit(s) were added to refs/heads/master by this push:
     new 30e5f5f  Fix an order-dependent flaky test (#1747)
30e5f5f is described below

commit 30e5f5f1f4209426341dde4339b6b678a2d460b9
Author: luoos <[email protected]>
AuthorDate: Wed Dec 2 02:14:40 2020 -0500

    Fix an order-dependent flaky test (#1747)
    
    Flaky test: BootstrapEnvironmentTest#assertGetFrameworkHostPort
    Expectd value is "localhost", but the actual value is "127.0.0.1"
    
    [Problem]
    When the BootstrapEnvironment singleton is initialized,
    the "properties" object is populated from 
elasticjob-cloud-scheduler.properties,
    and the "hostname" becomes "127.0.0.1", while the default "hostname"
    is "localhost". At this moment, assertGetFrameworkHostPort should
    fail. But in some other tests, the "properties" object resets. So
    in normal order, this test doesn't fail.
    
    We can easily fail this test by simply running this test alone.
    
    [Solution]
    Reset the "properties", make sure we get the default value.
---
 .../elasticjob/cloud/scheduler/env/BootstrapEnvironmentTest.java        | 2 ++
 1 file changed, 2 insertions(+)

diff --git 
a/elasticjob-cloud/elasticjob-cloud-scheduler/src/test/java/org/apache/shardingsphere/elasticjob/cloud/scheduler/env/BootstrapEnvironmentTest.java
 
b/elasticjob-cloud/elasticjob-cloud-scheduler/src/test/java/org/apache/shardingsphere/elasticjob/cloud/scheduler/env/BootstrapEnvironmentTest.java
index bbb58b5..5749e47 100755
--- 
a/elasticjob-cloud/elasticjob-cloud-scheduler/src/test/java/org/apache/shardingsphere/elasticjob/cloud/scheduler/env/BootstrapEnvironmentTest.java
+++ 
b/elasticjob-cloud/elasticjob-cloud-scheduler/src/test/java/org/apache/shardingsphere/elasticjob/cloud/scheduler/env/BootstrapEnvironmentTest.java
@@ -121,6 +121,8 @@ public final class BootstrapEnvironmentTest {
 
     @Test
     public void assertGetFrameworkHostPort() {
+        Properties properties = new Properties();
+        ReflectionUtils.setFieldValue(bootstrapEnvironment, "properties", 
properties);
         assertThat(bootstrapEnvironment.getFrameworkHostPort(), 
is("localhost:8899"));
     }
 

Reply via email to