Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
55 commits
Select commit Hold shift + click to select a range
628bc30
initial MDRS validation tests (derived from Ontoserver)
lawley Mar 30, 2021
a504329
MDRS rows should all be in the MDRS refset
jimsteel Apr 8, 2021
4ca2b9a
Check for version skew in dependency targets
jimsteel Apr 8, 2021
2fe5c6e
Referenced module in the MRDS is inactive
Apr 13, 2021
4a123e2
Add file-centric-snapshot-language-unknown-acceptability test
Apr 14, 2021
bd761a6
Add file-centric-snapshot-description-invalid-descriptiontype test an…
Apr 14, 2021
2d16fb3
Only need to check for active lang refset entries
Apr 15, 2021
95823ae
Only check active MDRS rows
Apr 15, 2021
929511f
Only look at active descriptions
Apr 15, 2021
5c5c703
And only look at active description types
Apr 15, 2021
8e6209d
Add curr_ to table names
Apr 15, 2021
6cb2b63
Add curr_ to table name
Apr 15, 2021
c711202
Add curr_ to tablenames
Apr 15, 2021
7acc26e
Add test for root concepts that have non-isa relationships
Apr 15, 2021
92b7d17
Include tests in manifest
Apr 15, 2021
5d98f80
Fix test
Apr 15, 2021
c26e9ff
Missed another field in test
Apr 15, 2021
c3860ac
Root concept (concept that has no isa) shouldn't really have non-isa …
Apr 19, 2021
3e5aa83
Change root concept assertion's severity to warning
Apr 19, 2021
2fbbdde
Add tests checking for extraneous SNAPSHOT entries
lawley Apr 19, 2021
4025dd7
Merge branch 'feature/csiro-extra-rules-1' of https://github.com/aehr…
lawley Apr 19, 2021
9140878
this skew test requires same sourcetime equality as well
lawley Apr 19, 2021
f85bd8a
Merge branch 'feature/csiro-extra-rules-1' into feature/csiro-extra-r…
Apr 20, 2021
888032c
Fix module and version parsing, get them from release file names. Add…
Apr 20, 2021
b949307
Add file name mappint to edition for NL, AU, NZ, US, INT
Apr 21, 2021
1874b9b
Added expected Belgian extension filename map
Apr 21, 2021
2db37a1
Merge branch 'feature/csiro-extra-rules-1' into feature/csiro-exctra-…
Apr 21, 2021
e91dd7f
Merge branch 'file-centric-snapshot-language-unknown-acceptability' i…
Apr 21, 2021
3857f98
Merge branch 'file-centric-snapshot-mdrs-referenced-module-inactive' …
Apr 21, 2021
697e381
Merge branch 'feature/csiro-extra-rules-2' into feature/csiro-exctra-…
Apr 21, 2021
c63527e
Remove extra ; to fix test
Apr 21, 2021
028f8c7
Fix tabs in file as it causes fails in the execution
Apr 21, 2021
dcecadc
Fix failing test issues because of mixed case table names
Apr 21, 2021
4395935
Add check for source module ids that are inactive
Apr 22, 2021
ce81353
Better logging of test failure
Apr 22, 2021
8851a19
Add UK filename to product mapping
Apr 22, 2021
ad08b1d
Fix re-used uuids
Apr 23, 2021
be99f3d
Change the dutch edition file name mapping
Apr 23, 2021
4c4c2b0
Fix typo
Apr 23, 2021
983491d
Add modules for new editions
Apr 23, 2021
bf1df7e
Remove new config from docker-compose.yml
Apr 23, 2021
dd40227
Add SE and US filename to edition mapping
Apr 23, 2021
36fee5e
Remove duplicated US row
Apr 23, 2021
27ad8fc
Fix typo
Apr 23, 2021
6a145c2
handle allowed case of a cyclic MDRS dependency
lawley Apr 27, 2021
2156b71
Also check for extraneous moduleIds
lawley Apr 27, 2021
fa86f19
Ensure all content comes from an MDRS-valid module
lawley Apr 28, 2021
005254a
also do MDRS violation checks for the refsetdescriptor refset
lawley Apr 28, 2021
3d45104
Remove sourceeffectivetime check. Any modules that are referenced sho…
Apr 28, 2021
275f3ed
Merge branch 'feature/csiro-exctra-rules-20210421' of https://github.…
Apr 28, 2021
f0e98ae
Add groupby to version skew test to reduce reported items
Apr 28, 2021
dc74916
Added new test to manifest
Apr 28, 2021
99be7c2
Fix reported field name
Apr 28, 2021
071e75e
version skew test corrected trigger state and relies on presence of a…
lawley Apr 29, 2021
9add1f3
Add test for grouped relationships that are marked as never grouped i…
May 7, 2021
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
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
import java.util.Set;

import javax.servlet.http.HttpServletResponse;

import org.ihtsdo.rvf.entity.Assertion;
import org.ihtsdo.rvf.entity.AssertionGroup;
import org.ihtsdo.rvf.execution.service.config.MysqlExecutionConfig;
Expand Down Expand Up @@ -41,10 +42,10 @@ public class AssertionGroupController {

@Autowired
private AssertionService assertionService;

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fixing their whitespace is probably outside our remit

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That's probably just an artefact of an editor configuration

@Autowired
private AssertionGroupRepository assertionGroupRepository;

@Autowired
private AssertionHelper assertionHelper;
private final ObjectMapper objectMapper = new ObjectMapper();
Expand All @@ -68,7 +69,7 @@ public List<AssertionGroup> getGroups() {
@ApiOperation(value = "Get all assertions for a given assertion group", notes = "Retrieves all assertions for a given assertion group identified by the group id.")
public List<Assertion> getAssertionsForGroup(@ApiParam(value = "Assertion group id") @PathVariable final Long id) {

AssertionGroup group = (AssertionGroup) assertionGroupRepository.getOne(id);
AssertionGroup group = assertionGroupRepository.getOne(id);
return new ArrayList<>(group.getAssertions());
}

Expand All @@ -79,7 +80,7 @@ public AssertionGroup addAssertionsToGroup(@PathVariable final Long id,
@RequestBody(required = false) final List<String> assertionsList,
final HttpServletResponse response) {

final AssertionGroup group = (AssertionGroup) assertionGroupRepository.getOne(id);
final AssertionGroup group = assertionGroupRepository.getOne(id);
// Do we have anything to add?
if (assertionsList == null || assertionsList.size() == 0) {
response.setStatus(HttpServletResponse.SC_NOT_MODIFIED);
Expand All @@ -101,7 +102,7 @@ public AssertionGroup addAssertionsToGroup(@PathVariable final Long id,
+ " This api may only be used when user desires to add all assertion found in the system to an assertion group"
+ " otherwise use {id}/assertions api as post call.")
public AssertionGroup addAllAssertions(@PathVariable final Long id) {
AssertionGroup group = (AssertionGroup) assertionGroupRepository.getOne(id);
AssertionGroup group = assertionGroupRepository.getOne(id);
List<Assertion> assertionList = assertionService.findAll();
group.setAssertions(new HashSet<>(assertionList));
return assertionGroupRepository.save(group);
Expand All @@ -114,7 +115,7 @@ public AssertionGroup addAllAssertions(@PathVariable final Long id) {
public AssertionGroup removeAssertionsFromGroup(
@PathVariable final Long id,
@ApiParam(value = "Only assertion id is required") @RequestBody final List<Assertion> assertions) {
AssertionGroup group = (AssertionGroup) assertionGroupRepository.getOne(id);
AssertionGroup group = assertionGroupRepository.getOne(id);
for (final Assertion assertion : group.getAssertions()) {
group = assertionService.removeAssertionFromGroup(assertion, group);
}
Expand All @@ -128,10 +129,10 @@ public AssertionGroup removeAssertionsFromGroup(
public AssertionGroup setAsAssertionsInGroup(@PathVariable final Long id,
@RequestBody(required = false) final Set<Assertion> assertions) {

final AssertionGroup group = (AssertionGroup) assertionGroupRepository.getOne(id);
final AssertionGroup group = assertionGroupRepository.getOne(id);
// replace all existing assertions with current list
group.setAssertions(assertions);
return (AssertionGroup) assertionGroupRepository.save(group);
return assertionGroupRepository.save(group);
}

@RequestMapping(value = "{id}", method = RequestMethod.GET)
Expand All @@ -142,15 +143,15 @@ public AssertionGroup getAssertionGroup(@PathVariable final Long id) {
if (!assertionGroupRepository.existsById(id)) {
throw new EntityNotFoundException(id);
}
return (AssertionGroup) assertionGroupRepository.getOne(id);
return assertionGroupRepository.getOne(id);
}

@RequestMapping(value = "{id}", method = RequestMethod.DELETE)
@ResponseBody
@ResponseStatus(HttpStatus.OK)
@ApiOperation(value = "Delete an assertion group", notes = "Deletes an assertion group from the system")
public AssertionGroup deleteAssertionGroup(@ApiParam(value="Assertion group id") @PathVariable final Long id) {
final AssertionGroup group = (AssertionGroup) assertionGroupRepository.getOne(id);
final AssertionGroup group = assertionGroupRepository.getOne(id);
group.removeAllAssertionsFromGroup();
assertionGroupRepository.delete(group);
return group;
Expand All @@ -172,7 +173,7 @@ public AssertionGroup createAssertionGroupWithName(@RequestParam final String na
@ApiOperation(value = "Update an assertion group", notes = "Updates the group name for the assertion group identified by the group id.")
public AssertionGroup updateAssertionGroup(@PathVariable final Long id,
@ApiParam(value = "Assertion group name") @RequestParam final String name) {
AssertionGroup group = (AssertionGroup) assertionGroupRepository.getOne(id);
AssertionGroup group = assertionGroupRepository.getOne(id);
group.setName(name);
return assertionGroupRepository.save(group);
}
Expand All @@ -184,9 +185,9 @@ public AssertionGroup updateAssertionGroup(@PathVariable final Long id,
public Map<String, Object> executeAssertions(@ApiParam(value="Assertion group id")@PathVariable final Long id,
@ApiParam(value="Unique number") @RequestParam final Long runId,
@ApiParam(value="Prospective version") @RequestParam final String prospectiveReleaseVersion,
@ApiParam(value="Previous release version") @RequestParam final String previousReleaseVersion) {
@ApiParam(value="Previous release version", required = false) @RequestParam final String previousReleaseVersion) {

AssertionGroup group = (AssertionGroup) assertionGroupRepository.getOne(id);
AssertionGroup group = assertionGroupRepository.getOne(id);
MysqlExecutionConfig config = new MysqlExecutionConfig(runId);
config.setPreviousVersion(previousReleaseVersion);
config.setProspectiveVersion(prospectiveReleaseVersion);
Expand Down
2 changes: 1 addition & 1 deletion docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ services:
volumes:
- mysql:/var/lib/mysql
command:
mysqld --sql_mode="NO_ENGINE_SUBSTITUTION,STRICT_TRANS_TABLES"
mysqld --sql_mode="NO_ENGINE_SUBSTITUTION,STRICT_TRANS_TABLES" --lower_case_table_names=1
rvf:
image: snomedinternational/release-validation-framework:latest
container_name: rvf
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@
import org.ihtsdo.rvf.entity.Test;
import org.ihtsdo.rvf.entity.TestRunItem;
import org.ihtsdo.rvf.execution.service.config.MysqlExecutionConfig;
import org.ihtsdo.rvf.importer.AssertionGroupImporter.ProductName;
import org.ihtsdo.rvf.service.AssertionService;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
Expand All @@ -49,7 +50,7 @@ public class AssertionExecutionService {
private String deltaTableSuffix = "d";
private String snapshotTableSuffix = "s";
private String fullTableSuffix = "f";

private ExecutorService executorService = Executors.newCachedThreadPool();

private final Logger logger = LoggerFactory.getLogger(AssertionExecutionService.class);
Expand Down Expand Up @@ -88,9 +89,9 @@ public Collection<TestRunItem> executeAssertions(final Collection<Assertion> ass

return items;
}

public List<TestRunItem> executeAssertionsConcurrently(List<Assertion> assertions, final MysqlExecutionConfig executionConfig) {

final List<Future<Collection<TestRunItem>>> concurrentTasks = new ArrayList<>();
final List<TestRunItem> results = new ArrayList<>();
int counter = 1;
Expand All @@ -116,7 +117,7 @@ public Collection<TestRunItem> call() throws Exception {
}
counter++;
}

// Wait for all concurrent tasks to finish
for (final Future<Collection<TestRunItem>> concurrentTask : concurrentTasks) {
try {
Expand Down Expand Up @@ -165,12 +166,12 @@ public TestRunItem executeTest(final Assertion assertion, final Test test, final
logger.warn("Failed to excute command {},Nested exception is : " + e.fillInStackTrace(), command.toString());
runItem.setFailureMessage("Error executing SQL command object Nested exception : " + e.fillInStackTrace());
return runItem;
}
}
} else {
runItem.setFailureMessage("Test does not have any associated execution command:" + test);
return runItem;
}

try {
long extractTimeStart = System.currentTimeMillis();
extractTestResult(assertion, runItem, config);
Expand Down Expand Up @@ -249,13 +250,17 @@ private List<String> transformSql(String[] parts, Assertion assertion, MysqlExec
List<String> result = new ArrayList<>();
String defaultCatalog = dataSource.getDefaultCatalog();
String prospectiveSchema = config.getProspectiveVersion();
final String[] nameParts = config.getProspectiveVersion().split("_");
String moduleId = (nameParts.length >= 2 ? ProductName.toModuleId(nameParts[1]) : "NOT_SUPPLIED");
String version = (nameParts.length >= 3 ? nameParts[2] : "NOT_SUPPLIED");

String previousReleaseSchema = config.getPreviousVersion();

//We need both these schemas to exist
if (prospectiveSchema == null) {
throw new ConfigurationException (FAILED_TO_FIND_RVF_DB_SCHEMA + prospectiveSchema);
}

if (config.isReleaseValidation() && !config.isFirstTimeRelease() && previousReleaseSchema == null) {
throw new ConfigurationException (FAILED_TO_FIND_RVF_DB_SCHEMA + previousReleaseSchema);
}
Expand All @@ -267,6 +272,8 @@ private List<String> transformSql(String[] parts, Assertion assertion, MysqlExec
// replace all substitutions for exec
part = part.replaceAll("<RUNID>", String.valueOf(config.getExecutionId()));
part = part.replaceAll("<ASSERTIONUUID>", String.valueOf(assertion.getAssertionId()));
part = part.replaceAll("<MODULEID>", moduleId);
part = part.replaceAll("<VERSION>", version);
// watch out for any 's that users might have introduced
part = part.replaceAll("qa_result", defaultCatalog+ "." + qaResulTableName);
part = part.replaceAll("<PROSPECTIVE>", prospectiveSchema);
Expand Down Expand Up @@ -315,7 +322,7 @@ private void extractTestResult(final Assertion assertion, final TestRunItem runI
}
}
}

if ( counter < config.getFailureExportMax() ) {
runItem.setFailureCount(counter);
} else {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,9 +25,14 @@
import java.util.Arrays;
import java.util.Calendar;
import java.util.Collection;
import java.util.HashMap;
import java.util.HashSet;
import java.util.List;
import java.util.Map;
import java.util.Optional;
import java.util.Set;
import java.util.regex.Matcher;
import java.util.regex.Pattern;
import java.util.stream.Collectors;

import javax.annotation.PostConstruct;
Expand Down Expand Up @@ -621,4 +626,63 @@ private File downloadFile(InputStream input, String outputFilename) {
IOUtils.closeQuietly(out);
}
}

public String getEditionAndVersion(final File zipDataFile) throws BusinessServiceException {
String editionAndVersion = "";
String snomedFile = "";
List<String> zipFileList = getFileList(zipDataFile);
Optional<String> sctOrDerFile = zipFileList.stream()
.filter(file -> ( file.indexOf("sct_") != -1
|| file.indexOf("der2_") != -1)
&& file.endsWith(".txt"))
.findFirst();
if (!sctOrDerFile.isPresent()) {
throw new BusinessServiceException("There are no RF2 files in data file: " + zipDataFile);
}
snomedFile = sctOrDerFile.get();
Matcher matcher = Pattern.compile(".*_([0-9]+)\\.txt").matcher(snomedFile);
if (matcher.find()) {
editionAndVersion =
mapFilenameToEdition(snomedFile).toLowerCase() + "_"
+ matcher.group(1);
} else {
throw new BusinessServiceException(
"Could not find RF2 file with standard name in data zip file "
+ zipDataFile.getName());
}
logger.info ("Identified edition and version " + editionAndVersion + " from zip file " + zipDataFile.getName());
return editionAndVersion;
}

private String mapFilenameToEdition(String name) {
String edition = "INT";
Map<String,String> fileNameToEditionMap = new HashMap<String,String>();
fileNameToEditionMap.put("SpanishExtension.*_INT", "ES");
fileNameToEditionMap.put("_NL_[0-9]+\\.txt", "NL");
fileNameToEditionMap.put("_AU1000036_[0-9]+\\.txt", "AU");
fileNameToEditionMap.put("_NZ1000210_[0-9]+\\.txt", "NZ");
fileNameToEditionMap.put("_US1000124_[0-9]+\\.txt", "US");
fileNameToEditionMap.put("_BE1000172_[0-9]+\\.txt", "BE");
fileNameToEditionMap.put("_SE1000052_[0-9]+\\.txt", "SE");
fileNameToEditionMap.put("GB1000000_[0-9]+\\.txt", "UK");
fileNameToEditionMap.put("_INT_[0-9]+\\.txt", "INT");
for (String pattern : fileNameToEditionMap.keySet()) {
Matcher editionMatcher = Pattern.compile(pattern).matcher(name);
if (editionMatcher.find()) {
edition = fileNameToEditionMap.get(pattern);
break;
}

}
return edition;
}

private List<String> getFileList(final File dataFile) throws BusinessServiceException {
try {
List<String> fileList = ZipFileUtils.listFiles(dataFile);
return fileList;
} catch (IOException e) {
throw new BusinessServiceException("Could not get file list from " + dataFile, e);
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -152,9 +152,10 @@ private String loadRelease(String releaseVersion) throws IOException, BusinessSe
return releaseVersion;
}

public MysqlExecutionConfig createExecutionConfig(ValidationRunConfig validationConfig) {
public MysqlExecutionConfig createExecutionConfig(ValidationRunConfig validationConfig) throws BusinessServiceException {
MysqlExecutionConfig executionConfig = new MysqlExecutionConfig(validationConfig.getRunId(), validationConfig.isFirstTimeRelease());
executionConfig.setProspectiveVersion(RVF_DB_PREFIX + executionConfig.getExecutionId().toString());
executionConfig.setProspectiveVersion(RVF_DB_PREFIX + getProspectiveVersionFromFileNames(validationConfig)
+ "_" + executionConfig.getExecutionId().toString());
executionConfig.setGroupNames(validationConfig.getGroupsList());
executionConfig.setExtensionValidation( isExtension(validationConfig));
executionConfig.setFirstTimeRelease(validationConfig.isFirstTimeRelease());
Expand All @@ -173,6 +174,13 @@ public MysqlExecutionConfig createExecutionConfig(ValidationRunConfig validation
return executionConfig;
}

private String getProspectiveVersionFromFileNames(ValidationRunConfig validationConfig) throws BusinessServiceException {
if (validationConfig.getLocalProspectiveFile() == null) {
return null;
}
return releaseDataManager.getEditionAndVersion(validationConfig.getLocalProspectiveFile());
}

public List<String> loadProspectiveDeltaAndCombineWithPreviousSnapshotIntoDB(MysqlExecutionConfig executionConfig, ValidationRunConfig validationConfig,
List<String> excludeTableNames) throws BusinessServiceException {
List<String> filesLoaded = new ArrayList<>();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ public class RF2FileTableMapper {
private static final String MRCM_MODULE_SCOPE_FILE_HEADER = "der2_cRefset_.*MRCMModuleScope";
private static final String MRCM_ATRRIBUTE_RANGE_FILE_HEADER = "der2_ssccRefset_.*MRCMAttributeRange";
private static final String MRCM_DOMAIN_FILE_HEADER = "der2_sssssssRefset_.*MRCMDomain";
private static final String DESCRIPTION_TYPE_FILE_HEADER = "der2_ciRefset_.*DescriptionType";
private static final Map<String,String> tableNameMap = new HashMap<>();
private static final String DELTA = ".*Delta.*_*_\\d{8}.txt";
private static final String SNAPSHOT = ".*Snapshot.*_*_\\d{8}.txt";
Expand Down Expand Up @@ -58,6 +59,7 @@ public class RF2FileTableMapper {
tableNameMap.put(MRCM_MODULE_SCOPE_FILE_HEADER + DELTA, "mrcmmodulescoperefset_d");
tableNameMap.put(MRCM_ATRRIBUTE_RANGE_FILE_HEADER + DELTA, "mrcmattributerangerefset_d");
tableNameMap.put(MRCM_DOMAIN_FILE_HEADER + DELTA, "mrcmdomainrefset_d");
tableNameMap.put(DESCRIPTION_TYPE_FILE_HEADER + DELTA, "descriptiontyperefset_d");

//Full
tableNameMap.put(CONCEPT_FILE_HEADER + FULL, "concept_f");
Expand All @@ -82,6 +84,7 @@ public class RF2FileTableMapper {
tableNameMap.put(MRCM_MODULE_SCOPE_FILE_HEADER + FULL, "mrcmmodulescoperefset_f");
tableNameMap.put(MRCM_ATRRIBUTE_RANGE_FILE_HEADER + FULL, "mrcmattributerangerefset_f");
tableNameMap.put(MRCM_DOMAIN_FILE_HEADER + FULL, "mrcmdomainrefset_f");
tableNameMap.put(DESCRIPTION_TYPE_FILE_HEADER + FULL, "descriptiontyperefset_f");

//Snapshot
tableNameMap.put(CONCEPT_FILE_HEADER + SNAPSHOT, "concept_s");
Expand All @@ -106,6 +109,7 @@ public class RF2FileTableMapper {
tableNameMap.put(MRCM_MODULE_SCOPE_FILE_HEADER + SNAPSHOT, "mrcmmodulescoperefset_s");
tableNameMap.put(MRCM_ATRRIBUTE_RANGE_FILE_HEADER + SNAPSHOT, "mrcmattributerangerefset_s");
tableNameMap.put(MRCM_DOMAIN_FILE_HEADER + SNAPSHOT, "mrcmdomainrefset_s");
tableNameMap.put(DESCRIPTION_TYPE_FILE_HEADER + SNAPSHOT, "descriptiontyperefset_s");
}

public static String getLegacyTableName(final String filename) {
Expand Down
Loading