mirror of https://github.com/apache/druid.git
Fix unit tests for java 17 (#14207)
Fix a unit test that fails in java 17
This commit is contained in:
parent
bd0080c4ce
commit
161d12eb44
|
@ -43,6 +43,7 @@ import java.io.IOException;
|
||||||
import java.nio.file.Files;
|
import java.nio.file.Files;
|
||||||
import java.nio.file.Path;
|
import java.nio.file.Path;
|
||||||
import java.util.Collections;
|
import java.util.Collections;
|
||||||
|
import java.util.Map;
|
||||||
import java.util.Properties;
|
import java.util.Properties;
|
||||||
|
|
||||||
public class PodTemplateTaskAdapterTest
|
public class PodTemplateTaskAdapterTest
|
||||||
|
@ -137,7 +138,7 @@ public class PodTemplateTaskAdapterTest
|
||||||
Job actual = adapter.fromTask(task);
|
Job actual = adapter.fromTask(task);
|
||||||
Job expected = K8sTestUtils.fileToResource("expectedNoopJob.yaml", Job.class);
|
Job expected = K8sTestUtils.fileToResource("expectedNoopJob.yaml", Job.class);
|
||||||
|
|
||||||
Assertions.assertEquals(expected, actual);
|
assertJobSpecsEqual(actual, expected);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
|
@ -179,7 +180,7 @@ public class PodTemplateTaskAdapterTest
|
||||||
Job actual = adapter.fromTask(task);
|
Job actual = adapter.fromTask(task);
|
||||||
Job expected = K8sTestUtils.fileToResource("expectedNoopJobTlsEnabled.yaml", Job.class);
|
Job expected = K8sTestUtils.fileToResource("expectedNoopJobTlsEnabled.yaml", Job.class);
|
||||||
|
|
||||||
Assertions.assertEquals(expected, actual);
|
assertJobSpecsEqual(actual, expected);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
|
@ -234,7 +235,7 @@ public class PodTemplateTaskAdapterTest
|
||||||
Job actual = adapter.fromTask(task);
|
Job actual = adapter.fromTask(task);
|
||||||
Job expected = K8sTestUtils.fileToResource("expectedNoopJob.yaml", Job.class);
|
Job expected = K8sTestUtils.fileToResource("expectedNoopJob.yaml", Job.class);
|
||||||
|
|
||||||
Assertions.assertEquals(expected, actual);
|
assertJobSpecsEqual(actual, expected);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
|
@ -314,4 +315,24 @@ public class PodTemplateTaskAdapterTest
|
||||||
|
|
||||||
Assertions.assertEquals(expected, actual);
|
Assertions.assertEquals(expected, actual);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
private void assertJobSpecsEqual(Job actual, Job expected) throws IOException
|
||||||
|
{
|
||||||
|
Map<String, String> actualAnnotations = actual.getSpec().getTemplate().getMetadata().getAnnotations();
|
||||||
|
String actualTaskAnnotation = actualAnnotations.get(DruidK8sConstants.TASK);
|
||||||
|
actualAnnotations.remove(DruidK8sConstants.TASK);
|
||||||
|
actual.getSpec().getTemplate().getMetadata().setAnnotations(actualAnnotations);
|
||||||
|
|
||||||
|
Map<String, String> expectedAnnotations = expected.getSpec().getTemplate().getMetadata().getAnnotations();
|
||||||
|
String expectedTaskAnnotation = expectedAnnotations.get(DruidK8sConstants.TASK);
|
||||||
|
expectedAnnotations.remove(DruidK8sConstants.TASK);
|
||||||
|
expected.getSpec().getTemplate().getMetadata().setAnnotations(expectedAnnotations);
|
||||||
|
|
||||||
|
Assertions.assertEquals(actual, expected);
|
||||||
|
Assertions.assertEquals(
|
||||||
|
Base64Compression.decompressBase64(actualTaskAnnotation),
|
||||||
|
Base64Compression.decompressBase64(expectedTaskAnnotation)
|
||||||
|
);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue