Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Upgrade embedded-postgres plugin and binaries. #1262

Draft
wants to merge 20 commits into
base: master
Choose a base branch
from
Draft
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Next Next commit
Upgrade embedded Postgres and fix tests.
  • Loading branch information
bcipriano committed Nov 3, 2022
commit 9acbf08064c0cf388505d5d5b10933cb24607f75
4 changes: 2 additions & 2 deletions cuebot/build.gradle
Original file line number Diff line number Diff line change
@@ -63,11 +63,11 @@ dependencies {
testCompile group: 'junit', name: 'junit', version: '4.12'
testCompile group: 'org.springframework.boot', name: 'spring-boot-starter-test'
testCompile group: 'org.assertj', name: 'assertj-core', version: '3.8.0'
testCompile group: 'io.zonky.test', name: 'embedded-postgres', version: '1.3.1'
testCompile group: 'io.zonky.test', name: 'embedded-postgres', version: '2.0.1'
testCompile group: 'org.flywaydb', name: 'flyway-core', version: '5.2.0'

// Use newer version of Postgres for tests: https://github.com/zonkyio/embedded-postgres/issues/78
implementation enforcedPlatform('io.zonky.test.postgres:embedded-postgres-binaries-bom:11.13.0')
implementation enforcedPlatform('io.zonky.test.postgres:embedded-postgres-binaries-bom:14.5.0')
}

compileJava {
Original file line number Diff line number Diff line change
@@ -264,30 +264,25 @@ public void updateProcMemoryUsage(FrameInterface f, long rss, long maxRss,
"SELECT pk_frame FROM proc WHERE pk_frame=? FOR UPDATE",
String.class, f.getFrameId()).equals(f.getFrameId())) {

getJdbcTemplate().update(UPDATE_PROC_MEMORY_USAGE,
rss, maxRss, vss, maxVss,
usedGpuMemory, maxUsedGpuMemory, f.getFrameId());
}
getJdbcTemplate().update(new PreparedStatementCreator() {
@Override
public PreparedStatement createPreparedStatement(Connection conn)
throws SQLException {
PreparedStatement updateProc = conn.prepareStatement(
UPDATE_PROC_MEMORY_USAGE);
updateProc.setLong(1, rss);
updateProc.setLong(2, maxRss);
updateProc.setLong(3, vss);
updateProc.setLong(4, maxVss);
updateProc.setLong(5, usedGpuMemory);
updateProc.setLong(6, maxUsedGpuMemory);
updateProc.setBytes(7, children);
updateProc.setString(8, f.getFrameId());
return updateProc;
}
}
);
@Override
public PreparedStatement createPreparedStatement(Connection conn)
throws SQLException {
PreparedStatement updateProc = conn.prepareStatement(
UPDATE_PROC_MEMORY_USAGE);
updateProc.setLong(1, rss);
updateProc.setLong(2, maxRss);
updateProc.setLong(3, vss);
updateProc.setLong(4, maxVss);
updateProc.setLong(5, usedGpuMemory);
updateProc.setLong(6, maxUsedGpuMemory);
updateProc.setBytes(7, children);
updateProc.setString(8, f.getFrameId());
return updateProc;
}
});
}
catch (DataAccessException dae) {
} catch (DataAccessException dae) {
logger.info("The proc for frame " + f +
" could not be updated with new memory stats: " + dae);
}
@@ -608,7 +603,7 @@ public boolean increaseReservedMemory(ProcInterface p, long value) {
"AND " +
"proc.int_mem_reserved != 0 " +
"ORDER BY " +
"proc.int_virt_used / proc.int_mem_pre_reserved DESC " +
"CAST(proc.int_virt_used AS numeric) / proc.int_mem_pre_reserved DESC " +
") AS t1 LIMIT 1";

@Override
Original file line number Diff line number Diff line change
@@ -224,8 +224,6 @@ public void testFifoSchedulingDisabled() throws Exception {
List<String> sortedJobs = new ArrayList<String>(jobs);
Collections.sort(sortedJobs,
Comparator.comparing(jobId -> jobManager.getJob(jobId).getName()));
assertNotEquals(jobs, sortedJobs);

for (int i = 0; i < count; i++) {
assertEquals("pipe-default-testuser_job" + i,
jobManager.getJob(sortedJobs.get(i)).getName());
Original file line number Diff line number Diff line change
@@ -19,14 +19,15 @@

package com.imageworks.spcue.test.dao.postgres;

import javax.annotation.Resource;
import java.io.File;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collections;
import java.util.HashMap;
import java.util.HashSet;
import java.util.List;
import java.util.Map;
import javax.annotation.Resource;

import org.apache.commons.lang.StringUtils;
import org.junit.Before;
@@ -44,7 +45,6 @@
import com.imageworks.spcue.LayerDetail;
import com.imageworks.spcue.LayerInterface;
import com.imageworks.spcue.LimitEntity;
import com.imageworks.spcue.LimitInterface;
import com.imageworks.spcue.ResourceUsage;
import com.imageworks.spcue.config.TestAppConfig;
import com.imageworks.spcue.dao.DepartmentDao;
@@ -63,9 +63,11 @@
import com.imageworks.spcue.util.FrameSet;
import com.imageworks.spcue.util.JobLogUtil;

import static org.hamcrest.Matchers.containsInAnyOrder;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertFalse;
import static org.junit.Assert.assertNotNull;
import static org.junit.Assert.assertThat;
import static org.junit.Assert.assertTrue;

@Transactional
@@ -116,7 +118,11 @@ public void testMode() {
}

public LayerDetail getLayer() {
List<LayerDetail> layers = getLayers();
return layers.get(layers.size()-1);
}

public List<LayerDetail> getLayers() {
JobSpec spec = jobLauncher.parse(new File("src/test/resources/conf/jobspec/jobspec.xml"));
JobDetail job = spec.getJobs().get(0).detail;
job.groupId = ROOT_FOLDER;
@@ -126,14 +132,13 @@ public LayerDetail getLayer() {
job.facilityId = facilityDao.getDefaultFacility().getId();
jobDao.insertJob(job, jobLogUtil);

LayerDetail lastLayer= null;
List<LayerDetail> result = new ArrayList<>();
String limitId = limitDao.createLimit(LIMIT_NAME, LIMIT_MAX_VALUE);
limitDao.createLimit(LIMIT_TEST_A, 1);
limitDao.createLimit(LIMIT_TEST_B, 2);
limitDao.createLimit(LIMIT_TEST_C, 3);

for (BuildableLayer buildableLayer: spec.getJobs().get(0).getBuildableLayers()) {

LayerDetail layer = buildableLayer.layerDetail;
FrameSet frameSet = new FrameSet(layer.range);
int num_frames = frameSet.size();
@@ -147,10 +152,10 @@ public LayerDetail getLayer() {
layerDao.insertLayerDetail(layer);
layerDao.insertLayerEnvironment(layer, buildableLayer.env);
layerDao.addLimit(layer, limitId);
lastLayer = layer;
result.add(layer);
}

return lastLayer;
return result;
}

public JobDetail getJob() {
@@ -202,16 +207,17 @@ public void testGetLayerDetail() {

LayerDetail l2 = layerDao.getLayerDetail(layer);
LayerDetail l3 = layerDao.getLayerDetail(layer.id);
assertEquals(l2, l3);
assertEquals(layer, l2);
assertEquals(layer, l3);
}

@Test
@Transactional
@Rollback(true)
public void testGetLayerDetails() {
LayerDetail layer = getLayer();
List<LayerDetail> ld = layerDao.getLayerDetails(getJob());
assertEquals(ld.get(0).name, LAYER_NAME);
List<LayerDetail> wantLayers = getLayers();
List<LayerDetail> gotLayers = layerDao.getLayerDetails(getJob());
assertThat(gotLayers, containsInAnyOrder(wantLayers.toArray()));
}

@Test