Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Split rest endpoints and improve modularisation #817

Merged
merged 41 commits into from
Jul 22, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
41 commits
Select commit Hold shift + click to select a range
b14c756
Split rest applications into distinct modules module object creation
melowe Jul 5, 2019
10b4ec1
Dont run grpc tests
melowe Jul 5, 2019
f7750d6
Backup commit/push
melowe Jul 9, 2019
1bc2a01
Add jersey backed tests
melowe Jul 10, 2019
0675423
Rename jaxrs modules.
melowe Jul 10, 2019
ed8245a
Fix spelling error.
melowe Jul 10, 2019
cf8a42a
Expose swagger api as a common resource rather than only from p2p
melowe Jul 10, 2019
8720925
Remove spring config for jaxrs module
melowe Jul 10, 2019
a8f8fad
Delegate called to ServiceLocator to ServiceFactory
melowe Jul 11, 2019
948bcc9
Move p2p focused objects into partyinfo module. Limit use of
melowe Jul 11, 2019
34f0b50
Add sync messages that also handle transaction syncing
melowe Jul 12, 2019
a1ce817
add missing test annoation
melowe Jul 12, 2019
95e9876
melowe Jul 12, 2019
32badff
A given key can have multiple urls.
melowe Jul 13, 2019
2fed7d5
Start adding push to peers support
melowe Jul 13, 2019
5444623
Merge origin/master into split-rest-endpoints
melowe Jul 13, 2019
534e4f7
Pushing changes to pick branch up on other machine.
melowe Jul 15, 2019
429a434
reflect change present on master
melowe Jul 15, 2019
7f49451
Add push
melowe Jul 16, 2019
f69faa3
Fix jackson dependency version
melowe Jul 16, 2019
1fa4c3d
Coverage 100% and tests pass.
melowe Jul 16, 2019
7b5aadf
Change error code to reflect change in master
melowe Jul 16, 2019
138cbd3
1.Deprecate p2pclient factory
melowe Jul 16, 2019
f7af91d
1.Deprecate p2pclient factory
melowe Jul 16, 2019
0f5199e
Deprecate unrequested enabled property
melowe Jul 16, 2019
e08a279
Reduce dependencies as far as possible
melowe Jul 16, 2019
4886e2a
Move publishers into partyinfo module as they are for p2p communciation.
melowe Jul 16, 2019
ec8f1d4
Remove GRPC tests
melowe Jul 16, 2019
179c5ca
Move jaxrs client factory into jaxrs pom.
melowe Jul 16, 2019
cf9d9c9
Not using container at the moment,.
melowe Jul 16, 2019
b387b00
remove refective assertions as they break on travisr
melowe Jul 16, 2019
8c5a0ea
Move persistent focused code into distinct module allowing
melowe Jul 17, 2019
41c0a89
Merge origin/split-rest-endpoints into split-rest-endpoints
melowe Jul 17, 2019
36d0bc7
Move resend manager into relevant module.
melowe Jul 17, 2019
29d72fd
Delete GRPC modules.
melowe Jul 17, 2019
515dfe7
Merge branch 'master' into split-rest-endpoints
melowe Jul 17, 2019
37bcf9d
Remove grpc distrubution module.
melowe Jul 18, 2019
f410455
Merge origin/split-rest-endpoints into split-rest-endpoints
melowe Jul 18, 2019
64a166a
Merge origin/master into split-rest-endpoints
melowe Jul 19, 2019
ee0dac1
Readded GRPC modules and test code
melowe Jul 19, 2019
66b803b
Merge branch 'master' into split-rest-endpoints
melowe Jul 20, 2019
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 0 additions & 5 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -42,11 +42,6 @@ jobs:
install: *build_no_checks
script: mvn verify -pl tests/acceptance-test -P reduce-logging || travis_terminate 1

- name: "GRPC Only Acceptance Tests"
jdk: oraclejdk8
install: *build_no_checks
script: mvn verify -pl tests/acceptance-test -P grpc-acceptance-tests,reduce-logging -o || travis_terminate 1

- name: "Simple Only Acceptance Tests"
jdk: oraclejdk8
install: *build_no_checks
Expand Down
4 changes: 2 additions & 2 deletions config/src/main/java/com/quorum/tessera/config/AppType.java
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,9 @@
import java.util.stream.Collectors;

public enum AppType {
P2P(CommunicationType.GRPC, CommunicationType.REST),
P2P(CommunicationType.REST, CommunicationType.GRPC),

Q2T(CommunicationType.GRPC, CommunicationType.REST),
Q2T(CommunicationType.REST, CommunicationType.GRPC),

@XmlEnumValue("ThirdParty")
THIRD_PARTY(CommunicationType.REST),
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
package com.quorum.tessera.config;

public enum CommunicationType {
REST,
GRPC,
WEB_SOCKET;
REST,
WEB_SOCKET,
@Deprecated
GRPC;
}
26 changes: 16 additions & 10 deletions config/src/main/java/com/quorum/tessera/config/ServerConfig.java
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,8 @@ public class ServerConfig extends ConfigItem {
@XmlElement(required = true)
private AppType app;

//TODO: Remove this nobody asked for it
@Deprecated
@NotNull
@XmlElement(required = true)
private boolean enabled;
Expand All @@ -36,9 +38,9 @@ public class ServerConfig extends ConfigItem {
private InfluxConfig influxConfig;

@ValidServerAddress(
message = "Binding Address is invalid",
isBindingAddress = true,
supportedSchemes = {"http", "https"}
message = "Binding Address is invalid",
isBindingAddress = true,
supportedSchemes = {"http", "https"}
)
@XmlElement
private String bindingAddress;
Expand All @@ -50,14 +52,14 @@ public class ServerConfig extends ConfigItem {

@XmlElement(name = "cors")
private CrossDomainConfig crossDomainConfig;

public ServerConfig(final AppType app,
final boolean enabled,
final String serverAddress,
final CommunicationType communicationType,
final SslConfig sslConfig,
final InfluxConfig influxConfig,
final String bindingAddress) {
final boolean enabled,
final String serverAddress,
final CommunicationType communicationType,
final SslConfig sslConfig,
final InfluxConfig influxConfig,
final String bindingAddress) {
this.app = app;
this.enabled = enabled;
this.serverAddress = serverAddress;
Expand Down Expand Up @@ -103,10 +105,14 @@ public void setApp(AppType app) {
this.app = app;
}

//TODO: Remove this nobody asked for it
@Deprecated
public boolean isEnabled() {
return enabled;
}

//TODO: Remove this nobody asked for it
@Deprecated
public void setEnabled(boolean enabled) {
this.enabled = enabled;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -60,9 +60,10 @@ public void isValidWhenValidDataIsSupplied() {
}

@Test
public void testInvalidCommTypeForApp() {
serverConfig.setApp(AppType.THIRD_PARTY);
serverConfig.setCommunicationType(CommunicationType.GRPC);
public void unsupportedCommunicationType() {

serverConfig.setCommunicationType(CommunicationType.WEB_SOCKET);

assertThat(validator.isValid(serverConfig, cvc)).isFalse();
verify(cvc).disableDefaultConstraintViolation();
verify(cvc).buildConstraintViolationWithTemplate(anyString());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,22 +9,18 @@

import javax.validation.ConstraintValidatorContext;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.HashMap;
import java.util.Map;
import java.util.List;
import java.util.stream.Collectors;

import static org.assertj.core.api.Assertions.assertThat;
import static org.mockito.ArgumentMatchers.anyString;
import static org.mockito.Mockito.*;

public class ServerConfigsValidatorTest {

private List<ServerConfig> serverConfigs;

private ServerConfig p2pServerConfig;

private ServerConfig q2tServerConfig;

private ServerConfig thirdPartyServerConfig;
private Map<AppType, ServerConfig> serverConfigs = new HashMap<>();

private ConstraintValidatorContext cvc;

Expand All @@ -33,28 +29,25 @@ public class ServerConfigsValidatorTest {
@Before
public void onSetUp() {
cvc = mock(ConstraintValidatorContext.class);
p2pServerConfig = new ServerConfig();
p2pServerConfig.setApp(AppType.P2P);
p2pServerConfig.setEnabled(true);
p2pServerConfig.setServerAddress("localhost:123");
p2pServerConfig.setCommunicationType(CommunicationType.REST);
p2pServerConfig.setSslConfig(null);
p2pServerConfig.setInfluxConfig(null);
p2pServerConfig.setBindingAddress(null);

q2tServerConfig = new ServerConfig(AppType.Q2T, true,
"localhost:1234", CommunicationType.REST,
null, null, null);
thirdPartyServerConfig = new ServerConfig(AppType.THIRD_PARTY, true,
"localhost:12345", CommunicationType.REST,
null, null, null);

serverConfigs = new ArrayList<>(Arrays.asList(p2pServerConfig, q2tServerConfig, thirdPartyServerConfig));

for (AppType appType : AppType.values()) {

ServerConfig serverConfig = new ServerConfig();
serverConfig.setApp(appType);
serverConfig.setEnabled(true);
serverConfig.setServerAddress("localhost:123");
serverConfig.setCommunicationType(CommunicationType.REST);
serverConfig.setSslConfig(null);
serverConfig.setInfluxConfig(null);
serverConfig.setBindingAddress(null);

serverConfigs.put(appType, serverConfig);
}

validator = new ServerConfigsValidator();

when(cvc.buildConstraintViolationWithTemplate(anyString()))
.thenReturn(mock(ConstraintValidatorContext.ConstraintViolationBuilder.class));
.thenReturn(mock(ConstraintValidatorContext.ConstraintViolationBuilder.class));
}

@After
Expand All @@ -69,47 +62,58 @@ public void isValidWhenServerConfigsIsNull() {

@Test
public void isValidWhenValidDataIsSupplied() {
thirdPartyServerConfig.setEnabled(false);
assertThat(validator.isValid(serverConfigs, cvc)).isTrue();
List<ServerConfig> serverConfigList = serverConfigList();

assertThat(validator.isValid(serverConfigList, cvc)).isTrue();
}

@Test
public void isNotValidWhenNoP2PServersAreEnabled() {
p2pServerConfig.setEnabled(false);
assertThat(validator.isValid(serverConfigs, cvc)).isFalse();

serverConfigs.get(AppType.P2P).setEnabled(false);

assertThat(validator.isValid(serverConfigList(), cvc)).isFalse();
verify(cvc).disableDefaultConstraintViolation();
verify(cvc).buildConstraintViolationWithTemplate(eq("Only one P2P server must be configured and enabled."));
}

@Test
public void isNotValidWhenNoP2PServersAreDefined() {
serverConfigs.remove(p2pServerConfig);
assertThat(validator.isValid(serverConfigs, cvc)).isFalse();
List<ServerConfig> serverConfigList =
serverConfigList().stream().filter(s -> s.getApp() != AppType.P2P).collect(Collectors.toList());
assertThat(validator.isValid(serverConfigList, cvc)).isFalse();
verify(cvc).disableDefaultConstraintViolation();
verify(cvc).buildConstraintViolationWithTemplate(eq("Only one P2P server must be configured and enabled."));
}

@Test
public void isNotValidWhenTwoOrMoreP2PServersAreDefinedAndEnabled() {
serverConfigs.add(p2pServerConfig);
assertThat(validator.isValid(serverConfigs, cvc)).isFalse();
List<ServerConfig> serverConfigList = serverConfigList();
serverConfigList.add(serverConfigs.get(AppType.P2P));
assertThat(validator.isValid(serverConfigList, cvc)).isFalse();
verify(cvc).disableDefaultConstraintViolation();
verify(cvc).buildConstraintViolationWithTemplate(eq("Only one P2P server must be configured and enabled."));
}

@Test
public void isNotValidWhenNoQ2TServersAreEnabled() {
q2tServerConfig.setEnabled(false);
assertThat(validator.isValid(serverConfigs, cvc)).isFalse();
serverConfigs.get(AppType.Q2T).setEnabled(false);
assertThat(validator.isValid(serverConfigList(), cvc)).isFalse();
verify(cvc).disableDefaultConstraintViolation();
verify(cvc).buildConstraintViolationWithTemplate(eq("At least one Q2T server must be configured and enabled."));
}

@Test
public void isNotValidWhenNoQ2TServersAreDefined() {
serverConfigs.remove(q2tServerConfig);
assertThat(validator.isValid(serverConfigs, cvc)).isFalse();
List<ServerConfig> serverConfigList =
serverConfigList().stream().filter(s -> s.getApp() != AppType.Q2T).collect(Collectors.toList());

assertThat(validator.isValid(serverConfigList, cvc)).isFalse();
verify(cvc).disableDefaultConstraintViolation();
verify(cvc).buildConstraintViolationWithTemplate(eq("At least one Q2T server must be configured and enabled."));
}

private List<ServerConfig> serverConfigList() {
return new ArrayList<>(serverConfigs.values());
}
}
1 change: 1 addition & 0 deletions enclave/enclave-jaxrs/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -164,6 +164,7 @@
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-jar-plugin</artifactId>
<version>3.1.2</version>
<configuration>
<excludes>
<exclude>logback-enclave.xml</exclude>
Expand Down

This file was deleted.

Loading