Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Optimizations to project deletion and TestRun deletion. Fix for CUANT…

…O-82. Remove DataService.deleteTestCasesForProject() and tests.
  • Loading branch information...
commit 6bc4185559e73a37d25234643b7b83270f15c524 1 parent 5ed9b7b
Todd Wells authored
7 grails/grails-app/jobs/ProjectDeletionJob.groovy
View
@@ -33,10 +33,11 @@ class ProjectDeletionJob {
def toDelete = Project.findAllByDeleted(true)
toDelete.each {
def pg = it.projectGroup?.name
- log.info("Deleting ${it.name} from ProjectGroup ${pg}")
+ def startTime = new Date().time
+ log.info("Deleting project ${it.name}")
projectService.deleteProject(it)
- log.info("${it.name} from ProjectGroup ${pg} deleted")
+ def elapsed = new Date().time - startTime
+ log.info("Project ${it.name} deleted, ${elapsed} ms elapsed.")
}
}
-
}
12 grails/grails-app/services/cuanto/DataService.groovy
View
@@ -560,18 +560,6 @@ class DataService {
}
- def deleteTestCasesForProject(project) {
- def cases = getTestCases(project)
- cases.each { TestCase tc ->
- def outcomes = TestOutcome.findAllByTestCase(tc)
- outcomes.each { outcome ->
- outcome.delete(flush:true)
- }
- }
- TestCase.executeUpdate("delete cuanto.TestCase tc where tc.project = ?", [project])
- }
-
-
def getBugSummary(testRun) {
def bugStats = TestOutcome.executeQuery("""select distinct outc.bug, (select count(outb) from
cuanto.TestOutcome outb where outb.testRun = ? and outb.bug = outc.bug) from cuanto.TestOutcome
7 grails/grails-app/services/cuanto/ProjectService.groovy
View
@@ -60,10 +60,12 @@ class ProjectService {
if (project) {
def origGroup = project.projectGroup
def testRuns = dataService.getTestRunsByProject(project)
- dataService.deleteTestCasesForProject(project)
testRuns.each { testRun ->
- testRunService.deleteTestRun(testRun)
+ testRunService.deleteTestRun(testRun, false)
}
+
+ TestCase.executeUpdate("delete cuanto.TestCase tc where tc.project = ?", [project])
+
project.delete(flush: true)
deleteProjectGroupIfUnused(origGroup)
}
@@ -219,6 +221,7 @@ class ProjectService {
void queueForDeletion(Project project) {
def groupId = project?.projectGroup?.id
+ log.info "Queuing ${project.name} for deletion"
project.deleted = true
project.projectGroup = null
project.projectKey = String.valueOf(System.currentTimeMillis()).reverse()
24 grails/grails-app/services/cuanto/TestRunService.groovy
View
@@ -648,11 +648,15 @@ class TestRunService {
* after which FailureStatusUpdateTasks are queued for re-initialization of the isFailureStatusChanged field
* for all TestOutcomes in the next TestRun.
*/
- def deleteTestRun(TestRun run) {
- TestRun.withTransaction {
+ def deleteTestRun(TestRun run, recalc = true) {
try {
- TestRun testRun = TestRun.lock(run.id)
- TestRun nextRun = dataService.getNextTestRun(run)
+ TestRun testRun = TestRun.get(run.id)
+ TestRun nextRun = null
+
+ if (recalc) {
+ nextRun = dataService.getNextTestRun(run)
+ }
+
statisticService.dequeueTestRunStats(run.id)
statisticService.deleteStatsForTestRun(run)
@@ -684,7 +688,8 @@ class TestRunService {
testRun.save()
testRun.delete()
- if (nextRun) {
+
+ if (recalc && nextRun) {
failureStatusService.queueFailureStatusUpdateForRun(nextRun)
nextRun?.discard()
}
@@ -695,15 +700,12 @@ class TestRunService {
} catch (StaleObjectStateException e) {
log.error "StaleObjectStateException for test run ${run.id}"
}
- }
}
- Integer deleteTestRuns(testRunIds) {
- TestRun.withTransaction {
- testRunIds.each { runId ->
- deleteTestRun TestRun.get(runId)
- }
+ Integer deleteTestRuns(testRunIds, recalc = true) {
+ testRunIds.each { runId ->
+ deleteTestRun(TestRun.get(runId), recalc)
}
return testRunIds.size()
}
16 grails/test/integration/cuanto/TestCaseTests.groovy
View
@@ -154,20 +154,4 @@ class TestCaseTests extends GroovyTestCase {
assertEquals "Wrong number of test cases", 1, dataService.getTestCases(fetchedProj).size()
}
-
- void testDeleteTestCasesForProject() {
- def project = to.project
- dataService.saveDomainObject project
-
- def testCases = 10
- 1.upto(testCases) {
- def testCase = to.getTestCase(project)
- dataService.saveDomainObject testCase
- }
-
- assertEquals "Wrong number of test cases", testCases, TestCase.list().size()
- dataService.deleteTestCasesForProject(project)
- assertEquals "Wrong number of test cases", 0, TestCase.list().size()
- assertEquals "Wrong number of test outcomes", 0, TestOutcome.list().size()
- }
}
Please sign in to comment.
Something went wrong with that request. Please try again.