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 mivanov1988 committed Oct 10, 2023
1 parent c134a3e commit 3e8f7ac
Show file tree
Hide file tree
Showing 4 changed files with 49 additions and 19 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -200,6 +200,12 @@ spec:
value: "{{ .Values.dataJob.deployment.configuration.persistence.writeTos }}"
- name: DATAJOBS_DEPLOYMENT_CONFIGURATION_PERSISTENCE_READ_DATA_SOURCE
value: "{{ .Values.dataJob.deployment.configuration.persistence.readDataSource }}"
- name: DATAJOBS_DEPLOYMENT_CONFIGURATION_SYNCHRONIZATION_TASK_ENABLED
value: "{{ .Values.dataJob.deployment.configuration.synchronizationTask.enabled }}"
- name: DATAJOBS_DEPLOYMENT_CONFIGURATION_SYNCHRONIZATION_TASK_INTERVAL
value: "{{ .Values.dataJob.deployment.configuration.synchronizationTask.interval }}"
- name: DATAJOBS_DEPLOYMENT_CONFIGURATION_SYNCHRONIZATION_TASK_INITIAL_DELAY
value: "{{ .Values.dataJob.deployment.configuration.synchronizationTask.initialDelay }}"
- name: KRB5_CONFIG
value: "/etc/secrets/krb5.conf"
- name: VDK_OPTIONS_INI
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1050,11 +1050,29 @@ dataJob:
persistence:
# Case sensitive CSV list of write to's sources. Default is "DB,K8S" The control service
# will write data job properties to all sources present in this list.
# See the synchronizationTask for more information.
writeTos: "DB,K8S"
# Case-sensitive variable to select the truth data source for reading properties.
# Options are "DB" for database and "K8S" for kubernetes. The control service will read
# properties from the specified source.
readDataSource: "K8S"
# Synchronization Task Behavior:
# Configure the behavior of synchronization task based on the following configurations:

# Case 1: If persistence.writeTo = "DB" and synchronizationTask.enabled = true:
# The Deployment API will write data to the database, and the synchronization task
# will sync the data jobs in Kubernetes.

# Case 2: If persistence.writeTo = "DB" and synchronizationTask.enabled = false:
# The Deployment API will update the database, but the synchronization task will be disabled,
# resulting in no updates in Kubernetes.

# Case 3: If persistence.writeTo = "K8s" and synchronizationTask.enabled = true:
# The Deployment API will update data jobs in Kubernetes, and the synchronization task may override some of them.

# Case 4: If persistence.writeTo = "K8s" and synchronizationTask.enabled = false:
# The Deployment API will update data jobs in Kubernetes, but the synchronization tasks will be disabled,
# preventing any further synchronization with Kubernetes.
synchronizationTask:
enabled: false
# The data job deployments' synchronization task interval is the time period (expressed in milliseconds)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -56,8 +56,9 @@ public class DataJobsSynchronizer {
* This can include creating new CronJobs, updating existing CronJobs, etc.
*/
@Scheduled(
fixedDelayString = "${datajobs.deployment.configuration.synchronization.task.interval:1000}",
initialDelayString = "${datajobs.deployment.configuration.synchronization.task.initial.delay:10000}")
fixedDelayString = "${datajobs.deployment.configuration.synchronization.task.interval:1000}",
initialDelayString =
"${datajobs.deployment.configuration.synchronization.task.initial.delay:10000}")
@SchedulerLock(name = "synchronizeDataJobsTask")
public void synchronizeDataJobs() {
if (!synchronizationEnabled) {
Expand All @@ -66,9 +67,11 @@ public void synchronizeDataJobs() {
}

if (!dataJobDeploymentPropertiesConfig
.getWriteTos()
.contains(DataJobDeploymentPropertiesConfig.WriteTo.DB)) {
log.debug("Skipping data job deployments' synchronization due to the disabled writes to the database.");
.getWriteTos()
.contains(DataJobDeploymentPropertiesConfig.WriteTo.DB)) {
log.debug(
"Skipping data job deployments' synchronization due to the disabled writes to the"
+ " database.");
return;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -65,56 +65,59 @@ public class DataJobsSynchronizerTest {

@Test
void synchronizeDataJobs_synchronizationEnabledFalseAndWriteToDbTrue_shouldSkipSynchronization()
throws ApiException {
throws ApiException {
initSynchronizationProcessConfig(false, true);

dataJobsSynchronizer.synchronizeDataJobs();

Mockito.verify(deploymentService, Mockito.times(0))
.findAllActualDeploymentNamesFromKubernetes();
.findAllActualDeploymentNamesFromKubernetes();
}

@Test
void synchronizeDataJobs_synchronizationEnabledFalseAndWriteToDbFalse_shouldSkipSynchronization()
throws ApiException {
throws ApiException {
initSynchronizationProcessConfig(false, false);

dataJobsSynchronizer.synchronizeDataJobs();

Mockito.verify(deploymentService, Mockito.times(0))
.findAllActualDeploymentNamesFromKubernetes();
.findAllActualDeploymentNamesFromKubernetes();
}

@Test
void
synchronizeDataJobs_synchronizationEnabledTrueAndWriteToDbTrue_shouldFinishSynchronization()
throws ApiException {
void synchronizeDataJobs_synchronizationEnabledTrueAndWriteToDbTrue_shouldFinishSynchronization()
throws ApiException {
initSynchronizationProcessConfig(true, true);

dataJobsSynchronizer.synchronizeDataJobs();

Mockito.verify(deploymentService, Mockito.times(1))
.findAllActualDeploymentNamesFromKubernetes();
.findAllActualDeploymentNamesFromKubernetes();
}

@Test
void
synchronizeDataJobs_synchronizationEnabledTrueAndWriteToDbFalse_shouldSkipSynchronization()
throws ApiException {
void synchronizeDataJobs_synchronizationEnabledTrueAndWriteToDbFalse_shouldSkipSynchronization()
throws ApiException {
initSynchronizationProcessConfig(true, false);

dataJobsSynchronizer.synchronizeDataJobs();

Mockito.verify(deploymentService, Mockito.times(0))
.findAllActualDeploymentNamesFromKubernetes();
.findAllActualDeploymentNamesFromKubernetes();
}

void enableSynchronizationProcess() {
initSynchronizationProcessConfig(true, true);
}

void initSynchronizationProcessConfig(boolean synchronizationEnabled, boolean writeToDB) {
ReflectionTestUtils.setField(dataJobsSynchronizer, "synchronizationEnabled", synchronizationEnabled);
Mockito.when(dataJobDeploymentPropertiesConfig.getWriteTos()).thenReturn(writeToDB ? Set.of(DataJobDeploymentPropertiesConfig.WriteTo.DB) : Collections.emptySet());
ReflectionTestUtils.setField(
dataJobsSynchronizer, "synchronizationEnabled", synchronizationEnabled);
Mockito.when(dataJobDeploymentPropertiesConfig.getWriteTos())
.thenReturn(
writeToDB
? Set.of(DataJobDeploymentPropertiesConfig.WriteTo.DB)
: Collections.emptySet());
}
}

0 comments on commit 3e8f7ac

Please sign in to comment.