-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
76 changed files
with
1,142 additions
and
2,099 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
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
32 changes: 32 additions & 0 deletions
32
...t/src/main/java/com/hltech/contracts/judged/agent/config/CachingDelegatingDPublisher.java
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,32 @@ | ||
package com.hltech.contracts.judged.agent.config; | ||
|
||
import com.google.common.collect.Sets; | ||
import com.hltech.contracts.judged.agent.JudgeDPublisher; | ||
import lombok.extern.slf4j.Slf4j; | ||
|
||
import java.util.Set; | ||
|
||
@Slf4j | ||
public class CachingDelegatingDPublisher implements JudgeDPublisher { | ||
|
||
private final JudgeDPublisher judgeDPublisher; | ||
|
||
private Set<ServiceForm> previouslySentEnvironment; | ||
|
||
public CachingDelegatingDPublisher(JudgeDPublisher judgeDPublisher) { | ||
this.judgeDPublisher = judgeDPublisher; | ||
} | ||
|
||
@Override | ||
public void publish(String environment, Set<ServiceForm> serviceForms) { | ||
if (previouslySentEnvironment == null || !previouslySentEnvironment.equals(serviceForms)) { | ||
log.info("publishing services to Judge-D: " + serviceForms); | ||
|
||
judgeDPublisher.publish(environment, serviceForms); | ||
|
||
previouslySentEnvironment = Sets.newHashSet(serviceForms); | ||
} else { | ||
log.debug("Services not changed since last update. Skipping update."); | ||
} | ||
} | ||
} |
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
20 changes: 20 additions & 0 deletions
20
judge-d-agent/src/test/groovy/com/hltech/contracts/judged/agent/AppIT.groovy
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,20 @@ | ||
package com.hltech.contracts.judged.agent | ||
|
||
import org.springframework.boot.test.context.SpringBootTest | ||
import org.springframework.test.context.ActiveProfiles | ||
import spock.lang.Specification | ||
|
||
import static org.springframework.boot.test.context.SpringBootTest.WebEnvironment.RANDOM_PORT | ||
|
||
@SpringBootTest(webEnvironment = RANDOM_PORT, properties = ["management.port=0"]) | ||
@ActiveProfiles(["test-integration", "kubernetes"]) | ||
class AppIT extends Specification { | ||
|
||
def test() { | ||
when: | ||
def a = 2 | ||
then: | ||
a == 2 | ||
} | ||
|
||
} |
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
48 changes: 48 additions & 0 deletions
48
...test/groovy/com/hltech/contracts/judged/agent/config/CachingDelegatingDPublisherUT.groovy
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,48 @@ | ||
package com.hltech.contracts.judged.agent.config | ||
|
||
import com.hltech.contracts.judged.agent.JudgeDPublisher | ||
import spock.lang.Specification | ||
|
||
class CachingDelegatingDPublisherUT extends Specification { | ||
|
||
private CachingDelegatingDPublisher publisher | ||
private JudgeDPublisher targetPublisher | ||
|
||
def setup() { | ||
targetPublisher = Mock(JudgeDPublisher) | ||
publisher = new CachingDelegatingDPublisher(targetPublisher) | ||
} | ||
|
||
def "should delegate to target publisher when publish for the first time"() { | ||
given: | ||
def forms = [new JudgeDPublisher.ServiceForm("name", "version")] as Set | ||
when: | ||
publisher.publish("SIT", forms) | ||
then: | ||
1 * targetPublisher.publish("SIT", forms) | ||
} | ||
|
||
def "should delegate to target publisher once when subsequently publish the same set of service multiple times "() { | ||
given: | ||
def forms = [new JudgeDPublisher.ServiceForm("name", "version")] as Set | ||
when: | ||
publisher.publish("SIT", forms) | ||
publisher.publish("SIT", forms) | ||
publisher.publish("SIT", forms) | ||
then: | ||
1 * targetPublisher.publish("SIT", forms) | ||
} | ||
|
||
def 'should delegate to target publisher when subsequently publish different set of services'() { | ||
given: | ||
def forms1 = [new JudgeDPublisher.ServiceForm("name1", "version")] as Set | ||
def forms2 = [new JudgeDPublisher.ServiceForm("name2", "version")] as Set | ||
when: | ||
publisher.publish("SIT", forms1) | ||
publisher.publish("SIT", forms2) | ||
then: | ||
1 * targetPublisher.publish("SIT", forms1) | ||
then: | ||
1 * targetPublisher.publish("SIT", forms2) | ||
} | ||
} |
Oops, something went wrong.