Skip to content

Commit

Permalink
Google Java Format
Browse files Browse the repository at this point in the history
  • Loading branch information
github-actions authored and doks5 committed Dec 13, 2023
1 parent 168f9f7 commit e31470e
Show file tree
Hide file tree
Showing 5 changed files with 24 additions and 14 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ private void setVdkVersionForDeployment() throws Exception {
.with(user("user"))
.content(getDataJobDeploymentVdkVersionRequestBody("new_vdk_version_tag"))
.contentType(MediaType.APPLICATION_JSON))
.andExpect(status().isBadRequest());
.andExpect(status().isAccepted());
}

private void disableDeployment() throws Exception {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -224,9 +224,9 @@ public static DesiredDataJobDeployment mergeDeployments(
? newDeployment.getPythonVersion()
: oldDeployment.getPythonVersion());
mergedDeployment.setVdkVersion(
newDeployment.getVdkVersion() != null
newDeployment.getVdkVersion() != null
? newDeployment.getVdkVersion()
: oldDeployment.getVdkVersion());
: oldDeployment.getVdkVersion());
mergedDeployment.setLastDeployedBy(
userDeployer != null ? userDeployer : oldDeployment.getLastDeployedBy());
mergedDeployment.setSchedule(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -254,7 +254,9 @@ private void updateCronJob(DataJob dataJob, JobDeployment jobDeployment, String
"-c",
"cp -r $(python -c \"from distutils.sysconfig import get_python_lib;"
+ " print(get_python_lib())\") /vdk/. && cp /usr/local/bin/vdk /vdk/.");
var jobVdkImage = (supportedPythonVersions.isVdkVersionPassedDifferentFromOneSetByPythonVersion(jobDeployment))
var jobVdkImage =
(supportedPythonVersions.isVdkVersionPassedDifferentFromOneSetByPythonVersion(
jobDeployment))
? supportedPythonVersions.replaceVdkVersionInImage(jobDeployment.getVdkVersion())
: supportedPythonVersions.getVdkImage(jobDeployment.getPythonVersion());

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -138,7 +138,8 @@ private String getBuilderImage(Map<String, String> supportedPythonVersion) {

public boolean isVdkVersionPassedDifferentFromOneSetByPythonVersion(JobDeployment jobDeployment) {
var passedVdkVersion = jobDeployment.getVdkVersion();
var vdkVersionSetByPythonVersion = DockerImageName.getTag(getVdkImage(jobDeployment.getPythonVersion()));
var vdkVersionSetByPythonVersion =
DockerImageName.getTag(getVdkImage(jobDeployment.getPythonVersion()));

return passedVdkVersion != null && !passedVdkVersion.equals(vdkVersionSetByPythonVersion);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -241,7 +241,7 @@ public void getVdkImage_defaultImage() {
public void getVdkImage_multipleSupportedVersions() {
var supportedVersions = generateSupportedPythonVersionsConf();

final String resultVdkImg = "domain:5000/name:test_vdk_image_3.7";
final String resultVdkImg = "domain:5000/name:test_vdk_image_3.8";
ReflectionTestUtils.setField(
supportedPythonVersions, SUPPORTED_PYTHON_VERSIONS, supportedVersions);

Expand All @@ -252,41 +252,48 @@ public void getVdkImage_multipleSupportedVersions() {
public void isVdkVersionPassedDifferentFromOneSetInPythonVersion_shouldReturnTrue() {
var supportedVersions = generateSupportedPythonVersionsConf();
ReflectionTestUtils.setField(
supportedPythonVersions, SUPPORTED_PYTHON_VERSIONS, supportedVersions);
supportedPythonVersions, SUPPORTED_PYTHON_VERSIONS, supportedVersions);
JobDeployment testDeployment = new JobDeployment();
testDeployment.setPythonVersion("3.8");
testDeployment.setVdkVersion("test_vdk_image_3.7");

Assertions.assertTrue(supportedPythonVersions.isVdkVersionPassedDifferentFromOneSetByPythonVersion(testDeployment));
Assertions.assertTrue(
supportedPythonVersions.isVdkVersionPassedDifferentFromOneSetByPythonVersion(
testDeployment));
}

@Test
public void isVdkVersionPassedDifferentFromOneSetInPythonVersion_shouldReturnFalse() {
var supportedVersions = generateSupportedPythonVersionsConf();
ReflectionTestUtils.setField(
supportedPythonVersions, SUPPORTED_PYTHON_VERSIONS, supportedVersions);
supportedPythonVersions, SUPPORTED_PYTHON_VERSIONS, supportedVersions);
JobDeployment testDeployment = new JobDeployment();
testDeployment.setPythonVersion("3.8");
testDeployment.setVdkVersion("test_vdk_image_3.8");

Assertions.assertFalse(supportedPythonVersions.isVdkVersionPassedDifferentFromOneSetByPythonVersion(testDeployment));
Assertions.assertFalse(
supportedPythonVersions.isVdkVersionPassedDifferentFromOneSetByPythonVersion(
testDeployment));
}

@Test
public void replaceVdkVersionInImage_replaceTheImage() {
var supportedVersions = generateSupportedPythonVersionsConf();
ReflectionTestUtils.setField(
supportedPythonVersions, SUPPORTED_PYTHON_VERSIONS, supportedVersions);
supportedPythonVersions, SUPPORTED_PYTHON_VERSIONS, supportedVersions);
ReflectionTestUtils.setField(supportedPythonVersions, DEFAULT_PYTHON_VERSION, "3.8");
String resImage = "domain:5000/name:replaced_vdk_image";

Assertions.assertEquals(resImage, supportedPythonVersions.replaceVdkVersionInImage("replaced_vdk_image"));
Assertions.assertEquals(
resImage, supportedPythonVersions.replaceVdkVersionInImage("replaced_vdk_image"));
}

private static Map<String, Map<String, String>> generateSupportedPythonVersionsConf() {
return Map.of(
"3.7", Map.of(BASE_IMAGE, "python:3.7-slim", VDK_IMAGE, "domain:5000/name:test_vdk_image_3.7"),
"3.8", Map.of(BASE_IMAGE, "python:3.8-slim", VDK_IMAGE, "domain:5000/name:test_vdk_image_3.8"),
"3.7",
Map.of(BASE_IMAGE, "python:3.7-slim", VDK_IMAGE, "domain:5000/name:test_vdk_image_3.7"),
"3.8",
Map.of(BASE_IMAGE, "python:3.8-slim", VDK_IMAGE, "domain:5000/name:test_vdk_image_3.8"),
"3.9", Map.of(BASE_IMAGE, "python:3.9-slim", VDK_IMAGE, "test_vdk_image_3.9"));
}
}

0 comments on commit e31470e

Please sign in to comment.