Skip to content

Commit

Permalink
Properties for scheduled update introduced and used in tests
Browse files Browse the repository at this point in the history
  • Loading branch information
akolod committed Dec 10, 2020
1 parent 7bec06c commit 6b5f55c
Show file tree
Hide file tree
Showing 4 changed files with 15 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,10 @@ public UpdateServicesTask(
this.publisher = publisher;
}

@Scheduled(fixedDelay = 5_000, initialDelay = 10_000)
@Scheduled(
fixedDelayString = "${hltech.contracts.judge-d.updateServices.fixedDelay}",
initialDelayString = "${hltech.contracts.judge-d.updateServices.initialDelay}"
)
public void updateServices() {
log.debug("Searching for available services...");
Set<ServiceLocator.Service> serviceForms = serviceLocator.locateServices();
Expand Down
3 changes: 3 additions & 0 deletions judge-d-agent/src/main/resources/application.properties
Original file line number Diff line number Diff line change
Expand Up @@ -9,3 +9,6 @@ hltech.contracts.judge-d.excluded-namespaces=${EXCLUDED_NAMESPACES:}
hltech.contracts.judge-d.included-namespaces=${INCLUDED_NAMESPACES:}

hltech.contracts.judge-d.consul-host=${CONSUL_HOST}

hltech.contracts.judge-d.updateServices.fixedDelay=5000
hltech.contracts.judge-d.updateServices.initialDelay=10000
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ import io.fabric8.kubernetes.client.Config
import io.fabric8.kubernetes.client.KubernetesClient
import io.fabric8.kubernetes.client.server.mock.KubernetesMockServer
import org.springframework.beans.factory.annotation.Autowired
import org.springframework.beans.factory.annotation.Value
import org.springframework.boot.test.context.SpringBootTest
import org.springframework.test.context.ActiveProfiles
import spock.lang.Shared
Expand All @@ -30,6 +31,9 @@ import static org.awaitility.Awaitility.await
@ActiveProfiles(["test", "kubernetes"])
class K8sServiceLocatorFT extends Specification {

@Value('${hltech.contracts.judge-d.updateServices.initialDelay}')
Long updateServicesInitialDelay

@Shared
KubernetesMockServer k8sServer

Expand Down Expand Up @@ -102,7 +106,7 @@ class K8sServiceLocatorFT extends Specification {


expect: "update services message is sent with expected services names and versions"
await().atMost(15, TimeUnit.SECONDS).until({ wireMockRule.getServeEvents().requests.size() == 1 })
await().atMost(updateServicesInitialDelay + 5000, TimeUnit.MILLISECONDS).until({ wireMockRule.getServeEvents().requests.size() == 1 })
wireMockRule.verify(1, putRequestedFor(urlPathMatching("/environments/test")).withRequestBody(equalToJson(expectedRequestBody, true, false)))
}

Expand Down
3 changes: 3 additions & 0 deletions judge-d-agent/src/test/resources/application-test.properties
Original file line number Diff line number Diff line change
Expand Up @@ -7,3 +7,6 @@ hltech.contracts.judge-d.requiredLabel=app

hltech.contracts.judge-d.excluded-namespaces=
hltech.contracts.judge-d.included-namespaces=

hltech.contracts.judge-d.updateServices.fixedDelay=2000
hltech.contracts.judge-d.updateServices.initialDelay=4000

0 comments on commit 6b5f55c

Please sign in to comment.