Skip to content

Commit

Permalink
Fixed testcase for portability on linux
Browse files Browse the repository at this point in the history
  • Loading branch information
santanusinha committed Dec 6, 2023
1 parent e934487 commit 30173a7
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 19 deletions.
27 changes: 14 additions & 13 deletions ranger-discovery-bundle/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -12,23 +12,12 @@
<artifactId>ranger-discovery-bundle</artifactId>

<properties>
<dns.cache.manipulator.version>1.7.2</dns.cache.manipulator.version>
<dns.cache.manipulator.version>1.8.1</dns.cache.manipulator.version>
<failsafe.version>3.2.4</failsafe.version>
</properties>

<dependencies>
<dependency>
<groupId>org.openjdk.jmh</groupId>
<artifactId>jmh-core</artifactId>
<version>1.35</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.openjdk.jmh</groupId>
<artifactId>jmh-generator-annprocess</artifactId>
<version>1.35</version>
<scope>test</scope>
</dependency>

<dependency>
<groupId>io.dropwizard</groupId>
<artifactId>dropwizard-core</artifactId>
Expand Down Expand Up @@ -77,6 +66,18 @@
<version>${dns.cache.manipulator.version}</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.openjdk.jmh</groupId>
<artifactId>jmh-core</artifactId>
<version>1.35</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.openjdk.jmh</groupId>
<artifactId>jmh-generator-annprocess</artifactId>
<version>1.35</version>
<scope>test</scope>
</dependency>
</dependencies>

</project>
Original file line number Diff line number Diff line change
Expand Up @@ -30,10 +30,12 @@
import io.dropwizard.setup.Bootstrap;
import io.dropwizard.setup.Environment;
import lombok.extern.slf4j.Slf4j;
import lombok.val;
import org.junit.jupiter.api.AfterEach;
import org.junit.jupiter.api.Assertions;
import org.junit.jupiter.api.Test;

import java.net.InetAddress;
import java.net.UnknownHostException;
import java.util.UUID;

Expand Down Expand Up @@ -138,7 +140,7 @@ void shouldThrowExceptionForInvalidZkHost() {
});

assertTrue(thrown.getMessage()
.contains("Couldn't resolve host address for zkHost"));
.contains("Couldn't resolve host address for zkHost"));

}

Expand Down Expand Up @@ -168,9 +170,10 @@ void testPublishWithEmptyZkHost() throws UnknownHostException {
.build();
bundle.initialize(bootstrap);

String publishedHost = ConfigurationUtils.resolveNonEmptyPublishedHost(
val publishedHost = ConfigurationUtils.resolveNonEmptyPublishedHost(
serviceDiscoveryConfiguration.getPublishedHost());
if (LOCAL_ADDRESSES.contains(publishedHost)) {
val publishedHostAddress = InetAddress.getByName(publishedHost).getHostAddress();
if (LOCAL_ADDRESSES.contains(publishedHostAddress) || LOCAL_ADDRESSES.contains(publishedHost)) {
assertLocalHostNotAllowed();
} else {
assertDoesNotThrow();
Expand Down Expand Up @@ -202,9 +205,10 @@ void testPublishWithNullZkHost() throws UnknownHostException {
.build();
bundle.initialize(bootstrap);

String publishedHost = ConfigurationUtils.resolveNonEmptyPublishedHost(
val publishedHost = ConfigurationUtils.resolveNonEmptyPublishedHost(
serviceDiscoveryConfiguration.getPublishedHost());
if (LOCAL_ADDRESSES.contains(publishedHost)) {
val publishedHostAddress = InetAddress.getByName(publishedHost).getHostAddress();
if (LOCAL_ADDRESSES.contains(publishedHostAddress) || LOCAL_ADDRESSES.contains(publishedHost)) {
assertLocalHostNotAllowed();
} else {
assertDoesNotThrow();
Expand Down Expand Up @@ -276,7 +280,7 @@ private void assertLocalHostNotAllowed() {

});
assertTrue(thrown.getMessage()
.contains("Not allowed to publish localhost address to remote zookeeper"));
.contains("Not allowed to publish localhost address to remote zookeeper"));
}


Expand Down

0 comments on commit 30173a7

Please sign in to comment.