pass the tests about testplan abort
pass the tests about testplan abort
This commit is contained in:
parent
ea53212a53
commit
b6da61daa1
|
@ -2,6 +2,7 @@ package org.bench4q.master.api;
|
|||
|
||||
import java.io.IOException;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
import java.util.UUID;
|
||||
|
||||
|
@ -307,6 +308,8 @@ public class TestPlanController extends BaseController {
|
|||
throws Bench4QException {
|
||||
guardHasAuthentication("You have no power to stop test plan",
|
||||
"/stop/{testPlanId}");
|
||||
return null;
|
||||
return buildTestPlanResponseModel(
|
||||
this.getTestPlanRunner().stop(testPlanId), "",
|
||||
Collections.<TestPlan> emptyList());
|
||||
}
|
||||
}
|
||||
|
|
|
@ -219,6 +219,7 @@ public class TestPlan implements IAggregate {
|
|||
result = false;
|
||||
}
|
||||
}
|
||||
this.setCurrentStatus(TestPlanStatus.Complete.name());
|
||||
return result;
|
||||
}
|
||||
|
||||
|
|
|
@ -1,8 +1,6 @@
|
|||
package org.bench4q.master.unitTest.entity;
|
||||
|
||||
import static org.junit.Assert.assertEquals;
|
||||
import static org.junit.Assert.assertNotNull;
|
||||
import static org.junit.Assert.assertTrue;
|
||||
import static org.junit.Assert.*;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
@ -133,4 +131,17 @@ public class Test_TestPlan extends TestBase_MakeUpTestPlan {
|
|||
assertEquals(startLoad, this.getHaPool().getCurrentAvailableLoad());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void test_stop() {
|
||||
TestPlan testPlan = this.getTestPlanRepository().getTestPlanInDomainBy(
|
||||
this.getTestPlanRunIdUuid());
|
||||
testPlan.run();
|
||||
assertFalse(testPlan.isFinish());
|
||||
assertEquals(TestPlanStatus.InRunning.toString(),
|
||||
testPlan.getCurrentStatus());
|
||||
testPlan.stop();
|
||||
assertEquals(TestPlanStatus.Complete.toString(),
|
||||
testPlan.getCurrentStatus());
|
||||
assertTrue(testPlan.isFinish());
|
||||
}
|
||||
}
|
||||
|
|
|
@ -4,6 +4,7 @@ import java.io.File;
|
|||
import java.io.IOException;
|
||||
import java.util.Collections;
|
||||
import java.util.Date;
|
||||
import java.util.UUID;
|
||||
|
||||
import org.apache.commons.io.FileUtils;
|
||||
import org.bench4q.master.Main;
|
||||
|
@ -63,8 +64,12 @@ public class Test_TestPlanEngine extends TestBase_MakeUpTestPlan {
|
|||
if ((agent = this.getAgentRepository().getAgentBy("147.0.01")) != null) {
|
||||
this.getAgentRepository().detach(agent.getId());
|
||||
}
|
||||
this.scriptRepository.detach(this.scriptRepository.getScriptByName(
|
||||
"test1").getId());
|
||||
Script script = this.scriptRepository.getScriptByName("test1");
|
||||
if (script == null) {
|
||||
System.out.println("script is null");
|
||||
} else {
|
||||
this.scriptRepository.detach(script.getId());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -171,4 +176,20 @@ public class Test_TestPlanEngine extends TestBase_MakeUpTestPlan {
|
|||
.getCurrentStatus()));
|
||||
deleteTestPlan();
|
||||
}
|
||||
|
||||
@Test
|
||||
public void test_Stop() {
|
||||
int loadBefore = this.getHaPool().getCurrentAvailableLoad();
|
||||
this.getTestPlanEngine().doRunTestPlan(this.getTestPlanRunIdUuid());
|
||||
int afterLoad = this.getHaPool().getCurrentAvailableLoad();
|
||||
assertEquals(0, afterLoad);
|
||||
this.getTestPlanEngine().stop(this.getTestPlanRunIdUuid());
|
||||
int lastLoad = this.getHaPool().getCurrentAvailableLoad();
|
||||
assertEquals(loadBefore, lastLoad);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void test_stopWrongTestPlanId() {
|
||||
assertFalse(this.getTestPlanEngine().stop(UUID.randomUUID()));
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue