|
17 | 17 | package cd.go.contrib.elasticagent;
|
18 | 18 |
|
19 | 19 | import cd.go.contrib.elasticagent.requests.CreateAgentRequest;
|
| 20 | +import com.google.gson.Gson; |
20 | 21 | import io.fabric8.kubernetes.api.model.Container;
|
21 | 22 | import io.fabric8.kubernetes.api.model.EnvVar;
|
22 | 23 | import io.fabric8.kubernetes.api.model.Pod;
|
|
32 | 33 | import java.util.ArrayList;
|
33 | 34 | import java.util.HashMap;
|
34 | 35 | import java.util.List;
|
| 36 | +import java.util.Map; |
35 | 37 |
|
36 | 38 | import static org.hamcrest.Matchers.is;
|
37 | 39 | import static org.junit.Assert.*;
|
@@ -145,7 +147,10 @@ public void shouldCreateKubernetesPodWithPodAnnotations() throws Exception {
|
145 | 147 |
|
146 | 148 | assertNotNull(elasticAgentPod.getMetadata());
|
147 | 149 |
|
148 |
| - assertThat(elasticAgentPod.getMetadata().getAnnotations(), is(createAgentRequest.properties())); |
| 150 | + Map<String, String> expectedAnnotations = new HashMap<>(); |
| 151 | + expectedAnnotations.putAll(createAgentRequest.properties()); |
| 152 | + expectedAnnotations.put(Constants.JOB_IDENTIFIER_LABEL_KEY, new Gson().toJson(createAgentRequest.jobIdentifier())); |
| 153 | + assertThat(elasticAgentPod.getMetadata().getAnnotations(), is(expectedAnnotations)); |
149 | 154 | }
|
150 | 155 |
|
151 | 156 | @Test
|
@@ -249,6 +254,7 @@ public void usingPodYamlConfigurations_shouldCreateKubernetesPodWithPodAnnotatio
|
249 | 254 | HashMap<String, String> expectedAnnotations = new HashMap<>();
|
250 | 255 | expectedAnnotations.putAll(createAgentRequest.properties());
|
251 | 256 | expectedAnnotations.put("annotation-key", "my-fancy-annotation-value");
|
| 257 | + expectedAnnotations.put(Constants.JOB_IDENTIFIER_LABEL_KEY, new Gson().toJson(createAgentRequest.jobIdentifier())); |
252 | 258 |
|
253 | 259 | assertThat(elasticAgentPod.getMetadata().getAnnotations(), is(expectedAnnotations));
|
254 | 260 | }
|
|
0 commit comments