Skip to content

Commit

Permalink
Google Java Format
Browse files Browse the repository at this point in the history
  • Loading branch information
github-actions committed Aug 29, 2023
1 parent 9d68860 commit 9cb6e8c
Show file tree
Hide file tree
Showing 8 changed files with 58 additions and 43 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@
import io.kubernetes.client.openapi.models.V1SecretBuilder;
import lombok.extern.slf4j.Slf4j;
import org.apache.commons.lang3.tuple.ImmutablePair;
import org.junit.jupiter.api.Test;
import org.junit.jupiter.api.extension.RegisterExtension;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Qualifier;
Expand Down Expand Up @@ -86,7 +85,7 @@ private void createBuilderImagePullSecret(String namespaceName) throws Exception
* <p>Within this test we assert only that the data job execution is started and has an execution
* id. We don't wait for the job to be completed as successful as that takes too long
*/
//@Test
// @Test
public void testPrivateDockerBuildJob(
String jobName, String teamName, String username, String deploymentId) throws Exception {
createBuilderImagePullSecret(controlNamespace);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -54,9 +54,7 @@ public class DataJob {
@Column(name = "last_execution_duration")
private Integer lastExecutionDuration;

@OneToOne
@PrimaryKeyJoinColumn
private DataJobDeployment dataJobDeployment;
@OneToOne @PrimaryKeyJoinColumn private DataJobDeployment dataJobDeployment;

public DataJob(String name, JobConfig jobConfig) {
this.name = name;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,32 +19,32 @@
@Entity
public class DataJobDeployment {

@Id
@Column(name = "data_job_name")
private String dataJobName;
@Id
@Column(name = "data_job_name")
private String dataJobName;

@OneToOne(mappedBy = "dataJobDeployment")
@ToString.Exclude
@EqualsAndHashCode.Exclude
private DataJob dataJob;
@OneToOne(mappedBy = "dataJobDeployment")
@ToString.Exclude
@EqualsAndHashCode.Exclude
private DataJob dataJob;

private String deploymentVersionSha;
private String deploymentVersionSha;

private String pythonVersion;
private String pythonVersion;

private String gitCommitSha;
private String gitCommitSha;

private Float resourcesCpuRequest;
private Float resourcesCpuRequest;

private Float resourcesCpuLimit;
private Float resourcesCpuLimit;

private Integer resourcesMemoryRequest;
private Integer resourcesMemoryRequest;

private Integer resourcesMemoryLimit;
private Integer resourcesMemoryLimit;

private OffsetDateTime lastDeployedDate;
private OffsetDateTime lastDeployedDate;

private String lastDeployedBy;
private String lastDeployedBy;

private Boolean enabled;
private Boolean enabled;
}
Original file line number Diff line number Diff line change
Expand Up @@ -21,5 +21,4 @@
* <p>JobDeploymentRepositoryIT validates some aspects of the behavior
*/
@Repository
public interface JobDeploymentRepository extends JpaRepository<DataJobDeployment, String> {
}
public interface JobDeploymentRepository extends JpaRepository<DataJobDeployment, String> {}
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@
import com.vmware.taurus.service.model.DeploymentStatus;
import com.vmware.taurus.service.model.ExecutionStatus;
import org.springframework.data.domain.Pageable;
import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.data.jpa.repository.Modifying;
import org.springframework.data.jpa.repository.Query;
import org.springframework.data.repository.PagingAndSortingRepository;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,23 +9,15 @@
import com.vmware.taurus.RepositoryUtil;
import com.vmware.taurus.service.model.DataJob;
import com.vmware.taurus.service.model.DataJobDeployment;
import com.vmware.taurus.service.model.DataJobExecution;
import com.vmware.taurus.service.model.ExecutionStatus;
import org.junit.jupiter.api.Assertions;
import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Test;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.test.context.SpringBootTest;
import org.springframework.data.domain.PageRequest;
import org.springframework.data.domain.Pageable;
import org.springframework.data.domain.Sort;

import java.time.OffsetDateTime;
import java.time.ZoneOffset;
import java.time.temporal.ChronoUnit;
import java.util.List;

import static com.vmware.taurus.RepositoryUtil.getTimeAccurateToMicroSecond;

/** Integration tests of the setup of Spring Data repository for data job deployments */
@SpringBootTest(classes = ControlplaneApplication.class)
Expand All @@ -49,38 +41,56 @@ public void testCreate_deploymentShouldBeCreated() {
public void testDelete_deploymentShouldBeDeleted() {
DataJobDeployment expectedDataJobDeployment = createDataJobDeployment();

var actualDataJobDeployment = jobDeploymentRepository.findById(expectedDataJobDeployment.getDataJobName());
var actualDataJobDeployment =
jobDeploymentRepository.findById(expectedDataJobDeployment.getDataJobName());
Assertions.assertTrue(actualDataJobDeployment.isPresent());
Assertions.assertEquals(expectedDataJobDeployment, actualDataJobDeployment.get());

jobDeploymentRepository.deleteById(expectedDataJobDeployment.getDataJobName());
var deletedDataJobDeployment = jobDeploymentRepository.findById(expectedDataJobDeployment.getDataJobName());
var deletedDataJobDeployment =
jobDeploymentRepository.findById(expectedDataJobDeployment.getDataJobName());
Assertions.assertFalse(deletedDataJobDeployment.isPresent());
}

@Test
public void testUpdate_deploymentShouldBeUpdated() {
DataJobDeployment expectedDataJobDeployment = createDataJobDeployment();

var createdDataJobDeployment = jobDeploymentRepository.findById(expectedDataJobDeployment.getDataJobName());
var createdDataJobDeployment =
jobDeploymentRepository.findById(expectedDataJobDeployment.getDataJobName());
Assertions.assertTrue(createdDataJobDeployment.isPresent());
Assertions.assertEquals(expectedDataJobDeployment, createdDataJobDeployment.get());

expectedDataJobDeployment.setGitCommitSha("new-sha");
jobDeploymentRepository.save(expectedDataJobDeployment);

var updatedDataJobDeployment = jobDeploymentRepository.findById(expectedDataJobDeployment.getDataJobName());
var updatedDataJobDeployment =
jobDeploymentRepository.findById(expectedDataJobDeployment.getDataJobName());
Assertions.assertTrue(updatedDataJobDeployment.isPresent());
Assertions.assertEquals(expectedDataJobDeployment, updatedDataJobDeployment.get());
}

private DataJobDeployment createDataJobDeployment() {
DataJob actualDataJob = RepositoryUtil.createDataJob(jobsRepository);

DataJobDeployment expectedDataJobDeployment = new DataJobDeployment(actualDataJob.getName(), actualDataJob, "sha", "3.9-secure", "commit", 1F, 1F, 1, 1, OffsetDateTime.now().truncatedTo(ChronoUnit.MICROS), "user", true);
DataJobDeployment expectedDataJobDeployment =
new DataJobDeployment(
actualDataJob.getName(),
actualDataJob,
"sha",
"3.9-secure",
"commit",
1F,
1F,
1,
1,
OffsetDateTime.now().truncatedTo(ChronoUnit.MICROS),
"user",
true);
jobDeploymentRepository.save(expectedDataJobDeployment);

var createdDataJobDeployment = jobDeploymentRepository.findById(expectedDataJobDeployment.getDataJobName());
var createdDataJobDeployment =
jobDeploymentRepository.findById(expectedDataJobDeployment.getDataJobName());
Assertions.assertTrue(createdDataJobDeployment.isPresent());
Assertions.assertEquals(expectedDataJobDeployment, createdDataJobDeployment.get());

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,6 @@
import com.vmware.taurus.service.model.DataJob;
import com.vmware.taurus.service.model.DataJobExecution;
import com.vmware.taurus.service.model.ExecutionStatus;
import com.vmware.taurus.service.repository.JobExecutionRepository;
import com.vmware.taurus.service.repository.JobsRepository;
import org.junit.jupiter.api.Assertions;
import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Test;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@

import com.vmware.taurus.ControlplaneApplication;
import com.vmware.taurus.service.model.*;
import com.vmware.taurus.service.repository.JobsRepository;
import org.junit.jupiter.api.Assertions;
import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Test;
Expand Down Expand Up @@ -120,7 +119,20 @@ void testDeleteDataJob_withAssociatedDeployment_dataJobAndDeploymentShouldBeDele
var dataJobEntity = new DataJob("hello", new JobConfig(), DeploymentStatus.NONE);
repository.save(dataJobEntity);

DataJobDeployment expectedDataJobDeployment = new DataJobDeployment(dataJobEntity.getName(), dataJobEntity, "sha", "3.9-secure", "git_commit_sha", 1F, 1F, 1, 1, OffsetDateTime.now(), "user", true);
DataJobDeployment expectedDataJobDeployment =
new DataJobDeployment(
dataJobEntity.getName(),
dataJobEntity,
"sha",
"3.9-secure",
"git_commit_sha",
1F,
1F,
1,
1,
OffsetDateTime.now(),
"user",
true);
jobDeploymentRepository.save(expectedDataJobDeployment);

Assertions.assertTrue(repository.findById(dataJobEntity.getName()).isPresent());
Expand Down

0 comments on commit 9cb6e8c

Please sign in to comment.