-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fixed discovery port retrieval & bugs
- Loading branch information
Showing
5 changed files
with
149 additions
and
42 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,44 @@ | ||
package cs.neo4j; | ||
|
||
import org.junit.jupiter.api.Test; | ||
import software.amazon.awssdk.services.ec2.Ec2Client; | ||
import software.amazon.awssdk.services.ec2.model.DescribeInstancesRequest; | ||
import software.amazon.awssdk.services.ec2.model.DescribeInstancesResponse; | ||
import org.mockito.Mockito; | ||
import org.mockito.Mockito; | ||
|
||
import static org.junit.jupiter.api.Assertions.*; | ||
import static org.mockito.Mockito.mock; | ||
|
||
public class AwsClientTest { | ||
|
||
|
||
Ec2Client ec2ClientMock = mock(Ec2Client.class); | ||
|
||
@Test | ||
void shouldTestSomething() { | ||
boolean exception=false; | ||
|
||
|
||
// DescribeInstancesResponse describeInstancesResponse = DescribeInstancesResponse.builder() | ||
// .reservations(reservation -> reservation.instances(instance -> instance.stateName("running"))) | ||
// .build(); | ||
// | ||
// when(ec2ClientMock.describeInstances(any(DescribeInstancesRequest.class))) | ||
// .thenReturn(describeInstancesResponse); | ||
// AwsClient awsClient = new AwsClient("????", | ||
// "?????", "eu-west-1"); | ||
// | ||
// try { | ||
// Stream<String> resultStream = awsClient.getVmAddressesByAsgName("myasg"); | ||
// List<String> results = resultStream.collect(Collectors.toList()); | ||
// assertEquals(1, results.size()); | ||
// assertEquals("ip-10-0-0-17.eu-west-1.compute.internal", results.get(0)); | ||
// | ||
// } catch (Exception e) { | ||
// exception=true; | ||
// } | ||
|
||
assertFalse(exception); | ||
} | ||
} |
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,84 @@ | ||
package cs.neo4j; | ||
|
||
import com.neo4j.causalclustering.discovery.resolve.RemotesResolver; | ||
import com.neo4j.configuration.ClusterAddressSettings; | ||
import com.neo4j.configuration.ClusterNetworkSettings; | ||
import com.neo4j.configuration.DiscoverySettings; | ||
import org.junit.jupiter.api.Test; | ||
import org.neo4j.configuration.Config; | ||
import org.neo4j.configuration.GraphDatabaseSettings; | ||
import org.neo4j.configuration.SettingsDeclaration; | ||
import org.neo4j.configuration.helpers.SocketAddress; | ||
import org.neo4j.graphdb.config.Configuration; | ||
import org.neo4j.graphdb.config.Setting; | ||
import org.neo4j.logging.LogProvider; | ||
import org.neo4j.logging.NullLogProvider; | ||
|
||
import java.util.stream.Collectors; | ||
|
||
import static org.mockito.Mockito.mock; | ||
import static org.neo4j.configuration.SettingImpl.newBuilder; | ||
import static org.neo4j.configuration.SettingValueParsers.STRING; | ||
|
||
public class Ec2DiscoveryResolverTest { | ||
|
||
Ec2DiscoveryResolver resolver = new Ec2DiscoveryResolver(); | ||
Config config = Config.newBuilder().build(); | ||
|
||
LogProvider logProvider = NullLogProvider.getInstance();; | ||
|
||
|
||
@Test | ||
void shouldReturnName() { | ||
resolver.init(RemotesResolver.Type.DISCOVERY, config, logProvider); | ||
assert(resolver.getName() == "EC2"); | ||
} | ||
|
||
@Test | ||
void shouldGetDefaultDiscoveryPort() { | ||
resolver.init(RemotesResolver.Type.DISCOVERY, config, logProvider); | ||
assert(resolver.getDiscoveryPort() == 5000); | ||
} | ||
|
||
@Test | ||
void shouldGetDefaultClusterPort() { | ||
resolver.init(RemotesResolver.Type.CLUSTER, config, logProvider); | ||
assert(resolver.getDiscoveryPort() == 6000); | ||
} | ||
|
||
@Test | ||
void shouldGetAdvertisedDiscoveryPort() { | ||
config.setIfNotSet(ClusterAddressSettings.discovery_advertised_address, | ||
new SocketAddress("10.0.0.2", 1234)); | ||
resolver.init(RemotesResolver.Type.DISCOVERY, config, logProvider); | ||
assert(resolver.getDiscoveryPort() == 1234); | ||
} | ||
|
||
@Test | ||
void shouldGetAdvertisedClusterPort() { | ||
config.setIfNotSet(ClusterAddressSettings.cluster_advertised_address, | ||
new SocketAddress("10.0.0.2", 4567)); | ||
resolver.init(RemotesResolver.Type.CLUSTER, config, logProvider); | ||
assert(resolver.getDiscoveryPort() == 4567); | ||
} | ||
|
||
@Test | ||
void shouldUseAsg() { | ||
config.setIfNotSet(Ec2DiscoverySettings.asg_name, "myasg"); | ||
resolver.init(RemotesResolver.Type.DISCOVERY, config, logProvider); | ||
|
||
assert(true); | ||
// assert(resolver.addresses().collect(Collectors.toList()) == ); | ||
} | ||
|
||
@Test | ||
void shouldUseTag() { | ||
config.setIfNotSet(Ec2DiscoverySettings.vm_tag, "mytag:production"); | ||
resolver.init(RemotesResolver.Type.DISCOVERY, config, logProvider); | ||
|
||
assert(true); | ||
} | ||
|
||
|
||
|
||
} |