Skip to content

Commit 514cfe0

Browse files
committed
fix test
1 parent 454b855 commit 514cfe0

File tree

2 files changed

+96
-27
lines changed

2 files changed

+96
-27
lines changed

src/autoscaler/scheduler/src/main/java/org/cloudfoundry/autoscaler/scheduler/conf/CloudFoundryConfigurationProcessor.java

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,12 @@ public void postProcessEnvironment(
5454

5555
Map<String, Object> vcapOrgAndGuid = getOrgAndSpaceGuidFromVcap(environment);
5656
Map<String, Object> cfServerConfig = (Map<String, Object>) allConfigs.get("cfserver");
57-
cfServerConfig.putAll(vcapOrgAndGuid);
57+
if (cfServerConfig != null && !cfServerConfig.isEmpty()) {
58+
logger.info(
59+
"Found org and space guid service in VCAP_APPLICATIONS, applying configuration"
60+
+ " overrides");
61+
cfServerConfig.putAll(vcapOrgAndGuid);
62+
}
5863

5964
// Process database services
6065
Map<String, Object> databaseConfigs = extractDatabaseConfigs(vcapServices);

src/autoscaler/scheduler/src/test/java/org/cloudfoundry/autoscaler/scheduler/conf/CloudFoundryConfigurationProcessorTest.java

Lines changed: 90 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -356,11 +356,24 @@ public void testVcapServicesPrefersSslcertOverClientCert() {
356356
@Test
357357
public void testVcapApplicationWithOrgGuid() {
358358
String vcapServices =
359-
"""
360-
{
361-
"user-provided": []
362-
}
363-
""";
359+
"""
360+
{
361+
"user-provided": [
362+
{
363+
"name": "scheduler-config-service",
364+
"tags": ["scheduler-config"],
365+
"credentials": {
366+
"cfserver": {
367+
"healthserver": {
368+
"username": "health-user",
369+
"password": "health-password"
370+
}
371+
}
372+
}
373+
}
374+
]
375+
}
376+
""";
364377

365378
String vcapApplication =
366379
"""
@@ -390,11 +403,24 @@ public void testVcapApplicationWithOrgGuid() {
390403
@Test
391404
public void testVcapApplicationWithoutOrgGuid() {
392405
String vcapServices =
393-
"""
394-
{
395-
"user-provided": []
396-
}
397-
""";
406+
"""
407+
{
408+
"user-provided": [
409+
{
410+
"name": "scheduler-config-service",
411+
"tags": ["scheduler-config"],
412+
"credentials": {
413+
"cfserver": {
414+
"healthserver": {
415+
"username": "health-user",
416+
"password": "health-password"
417+
}
418+
}
419+
}
420+
}
421+
]
422+
}
423+
""";
398424

399425
String vcapApplication =
400426
"""
@@ -544,11 +570,24 @@ public void testVcapApplicationOverridesSchedulerConfig() {
544570
@Test
545571
public void testVcapApplicationWithOnlySpaceGuid() {
546572
String vcapServices =
547-
"""
548-
{
549-
"user-provided": []
550-
}
551-
""";
573+
"""
574+
{
575+
"user-provided": [
576+
{
577+
"name": "scheduler-config-service",
578+
"tags": ["scheduler-config"],
579+
"credentials": {
580+
"cfserver": {
581+
"healthserver": {
582+
"username": "health-user",
583+
"password": "health-password"
584+
}
585+
}
586+
}
587+
}
588+
]
589+
}
590+
""";
552591

553592
String vcapApplication =
554593
"""
@@ -577,11 +616,24 @@ public void testVcapApplicationWithOnlySpaceGuid() {
577616
@Test
578617
public void testVcapApplicationWithEmptySpaceGuid() {
579618
String vcapServices =
580-
"""
581-
{
582-
"user-provided": []
583-
}
584-
""";
619+
"""
620+
{
621+
"user-provided": [
622+
{
623+
"name": "scheduler-config-service",
624+
"tags": ["scheduler-config"],
625+
"credentials": {
626+
"cfserver": {
627+
"healthserver": {
628+
"username": "health-user",
629+
"password": "health-password"
630+
}
631+
}
632+
}
633+
}
634+
]
635+
}
636+
""";
585637

586638
String vcapApplication =
587639
"""
@@ -611,12 +663,24 @@ public void testVcapApplicationWithEmptySpaceGuid() {
611663
@Test
612664
public void testVcapApplicationWithoutSpaceGuid() {
613665
String vcapServices =
614-
"""
615-
{
616-
"user-provided": []
617-
}
618-
""";
619-
666+
"""
667+
{
668+
"user-provided": [
669+
{
670+
"name": "scheduler-config-service",
671+
"tags": ["scheduler-config"],
672+
"credentials": {
673+
"cfserver": {
674+
"healthserver": {
675+
"username": "health-user",
676+
"password": "health-password"
677+
}
678+
}
679+
}
680+
}
681+
]
682+
}
683+
""";
620684
String vcapApplication =
621685
"""
622686
{

0 commit comments

Comments
 (0)