refactor, and add
This commit is contained in:
parent
3520608eb5
commit
ea976a2ee4
|
@ -1,93 +1,17 @@
|
|||
<html><!--###PHBoeHBhZ2U+PHRpbWVTdGFtcD4xMC8xMi8yMDEzIDA4OjM3OjQzPC90aW1lU3RhbXA+PHRpbWVUaWxsQ0NCTlJlZnJlc2g+MTgwPC90aW1lVGlsbENDQk5SZWZyZXNoPjwvcGh4cGFnZT4=###--><head><link href="http://phx.corporate-ir.net/HttpCombiner.ashx?s=RisenCSS&v=B94A18012C20431FA6ADC43CFC76EDB2" type="text/css" rel="stylesheet" /><meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" /><title>Baidu | Business Overview</title><script language="JavaScript" src="http://media.corporate-ir.net/media_files/irol/global_js/phoenix.js"></script><link rel="stylesheet" type="text/css" href="client/18/188488/css/ccbnIR.css" /><script type="text/javascript"><!--
|
||||
<html>
|
||||
<head>
|
||||
<title>Bench4Q Test Case</title>
|
||||
<link href="style/bootstrap-cerulean.css" />
|
||||
<link href="style/bootstrap-classic.css" />
|
||||
<link href="style/bootstrap-cerulean.css" />
|
||||
</head>
|
||||
<body>
|
||||
<img src="images/1.jpg" alt="No this one" />
|
||||
<img src="images/2.jpg" alt="No this one" />
|
||||
<img src="images/3.jpg" alt="No this one" />
|
||||
|
||||
<script src="script/agentTable.js" type="text/javascript"></script>
|
||||
<script src="script/base.js" type="text/javascript"></script>
|
||||
</body>
|
||||
|
||||
var iframeids=["myframe"]
|
||||
var iframehide="yes"
|
||||
var getFFVersion=navigator.userAgent.substring(navigator.userAgent.indexOf("Firefox")).split("/")[1]
|
||||
var FFextraHeight=parseFloat(getFFVersion)>=0.1? 16 : 0 //extra height in px to add to iframe in FireFox 1.0+ browsers
|
||||
|
||||
function resizeCaller() {
|
||||
var dyniframe=new Array()
|
||||
for (i=0; i<iframeids.length; i++){
|
||||
if (document.getElementById)
|
||||
resizeIframe(iframeids[i])
|
||||
//reveal iframe for lower end browsers? (see var above):
|
||||
if ((document.all || document.getElementById) && iframehide=="no"){
|
||||
var tempobj=document.all? document.all[iframeids[i]] : document.getElementById(iframeids[i])
|
||||
tempobj.style.display="block"
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
function resizeIframe(frameid){
|
||||
var currentfr=document.getElementById(frameid)
|
||||
if (currentfr && !window.opera){
|
||||
if (currentfr.contentDocument && currentfr.contentDocument.body.offsetHeight) //ns6 syntax
|
||||
currentfr.height = currentfr.contentDocument.body.offsetHeight+FFextraHeight;
|
||||
else if (currentfr.Document && currentfr.Document.body.scrollHeight) //ie5+ syntax
|
||||
currentfr.height = currentfr.Document.body.scrollHeight;
|
||||
if (currentfr.addEventListener)
|
||||
currentfr.addEventListener("load", readjustIframe, false)
|
||||
else if (currentfr.attachEvent){
|
||||
currentfr.detachEvent("onload", readjustIframe) // Bug fix line
|
||||
currentfr.attachEvent("onload", readjustIframe)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
function readjustIframe(loadevt) {
|
||||
var crossevt=(window.event)? event : loadevt
|
||||
var iframeroot=(crossevt.currentTarget)? crossevt.currentTarget : crossevt.srcElement
|
||||
if (iframeroot)
|
||||
resizeIframe(iframeroot.id);
|
||||
}
|
||||
|
||||
function loadintoIframe(url){
|
||||
if (document.getElementById)
|
||||
document.getElementById("myframe").src=url
|
||||
}
|
||||
|
||||
if (window.addEventListener)
|
||||
window.addEventListener("load", resizeCaller, false)
|
||||
else if (window.attachEvent)
|
||||
window.attachEvent("onload", resizeCaller)
|
||||
else
|
||||
window.onload=resizeCaller
|
||||
//-->
|
||||
</script><script language="Javascript"><!--
|
||||
function emailPage()
|
||||
{
|
||||
var loc = top.location;
|
||||
var to = "";
|
||||
var subject = top.document.title;
|
||||
var body = document.location.href;
|
||||
|
||||
// BUILD MAIL MESSAGE COMPONENTS
|
||||
var doc = "mailto:" + to +
|
||||
"?subject=" + escape(subject) +
|
||||
"&body=" + escape(body);
|
||||
|
||||
// POP UP EMAIL MESSAGE WINDOW
|
||||
window.location = doc;
|
||||
|
||||
}
|
||||
//-->
|
||||
</script><script src="http://phx.corporate-ir.net/HttpCombiner.ashx?s=RisenJS&v=B94A18012C20431FA6ADC43CFC76EDB2" type="text/javascript"></script><script type="text/javascript">Phx.AjaxToken = 'b11f528329bbcb978c6263efe73939aa2452db019b4dead38bbb2a9ddfa7cb25';</script><script type="text/javascript">var s_CCSWebHostingAccount = "trcgclientweb2090";</script><script type="text/javascript" src="./WebSideStory/s_code.js"></script></head><body><table width="100%" border="0" cellspacing="0" cellpadding="0" class="BGLogo"><tr><td width="181" height="99" align="center" nowrap="nowrap"> <a href="http://www.baidu.com"><img src="http://media.corporate-ir.net/media_files/irol/18/188488/images/logo.gif" border="0" align="absmiddle" /></a></td><td align="right" class="Banner" id="ObjBanner"> <script><!--
|
||||
if (screen.width<= 800) document.getElementById("ObjBanner").style.backgroundImage = "url(http://media.corporate-ir.net/media_files/irol/18/188488/images/banner800.jpg)";//-->
|
||||
</script></td></tr></table><table width="100%" border="0" cellspacing="0" cellpadding="0" class="BGBar"><tr><td width="225" height="29"></td><td class="DottedLine" style="padding-right:30px;"><div align="right"><span class="ccbnLnk"><a class="ccbnLnk" onclick="emailPage()" href="#"><img border="0" src="http://media.corporate-ir.net/media_files/irol/18/188488/images/icon_email.gif" /></a></span><span class="ccbnLnk"><a class="ccbnLnk" onclick="emailPage()" href="#"> Send </a></span><span class="ccbnLnk"><a Class="ccbnLnk"Target="_blank" href="phoenix.zhtml?c=188488&p=irol-homeprofile_pf"><img src="http://media.corporate-ir.net/media_files/irol/18/188488/images/icon_print.gif" alt="Printer Friendly Version" border="0" /></a> </span><span class="ccbnLnk"><a Class="ccbnLnk"Target="_blank" href="phoenix.zhtml?c=188488&p=irol-homeprofile_pf">Print </a></span><span class="ccbnLnk"><A HREF="phoenix.zhtml?c=188488&p=rssSubscription&t=&id=&" NAME=""Class="ccbnLnk"><img src="http://media.corporate-ir.net/media_files/irol/global_images/toolkit_rss.gif" border="0" alt="RSS" /></A> </span><span class="ccbnLnk"><A HREF="phoenix.zhtml?c=188488&p=rssSubscription&t=&id=&" NAME=""Class="ccbnLnk">RSS</A></span></div></td></tr></table><table width="100%" border="0" cellpadding="0" cellspacing="0"><tr><td width="225" valign="top"><table width="198" border="0" cellspacing="0" cellpadding="0"><tr><td width="198" class="MTitle">Corporate Information</td></tr></table><table width="198" border="0" cellpadding="0" cellspacing="0" class="MIBoxMargin"><tr><td width="198" class="MItem"><a href="phoenix.zhtml?c=188488&p=irol-homeprofile">Business Overview</a></td></tr><tr><td class="MItem"><a href="phoenix.zhtml?c=188488&p=irol-products">Products</a></td></tr><tr><td class="MItem"><a href="phoenix.zhtml?c=188488&p=irol-govmanage">Management</a></td></tr><tr><td class="MItem"><a href="phoenix.zhtml?c=188488&p=irol-govboard">Board of Directors</a></td></tr><tr><td class="MItem"><a href="phoenix.zhtml?c=188488&p=irol-govhighlights">Corporate Governance</a></td></tr></table><table width="198" border="0" cellspacing="0" cellpadding="0"><tr><td width="198" class="MTitle">Investor Relations</td></tr></table><table width="198" border="0" cellpadding="0" cellspacing="0" class="MIBoxMargin"><tr><td width="198" class="MItem"><a href="phoenix.zhtml?c=188488&p=irol-irhome">Fact Sheet</a></td></tr><tr><td class="MItem"><a href="phoenix.zhtml?c=188488&p=irol-news&nyo=0">Press Releases</a></td></tr><tr><td class="MItem"><a href="phoenix.zhtml?c=188488&p=irol-reportsAnnual">Financial Reports</a></td></tr><tr><td class="MItem"><a href="phoenix.zhtml?c=188488&p=irol-presentations">Webcasts</a></td></tr><tr><td class="MItem"><a href="phoenix.zhtml?c=188488&p=irol-stockquote">Stock Information</a></td></tr><tr><td class="MItem"><a href="phoenix.zhtml?c=188488&p=irol-sec">SEC Filings</a></td></tr><tr><td class="MItem"><a href="phoenix.zhtml?c=188488&p=irol-analysts">Analyst Coverage</a></td></tr><tr><td class="MItem"><a href="phoenix.zhtml?c=188488&p=irol-calendar">IR Calendar</a></td></tr><tr><td class="MItem"><a href="phoenix.zhtml?c=188488&p=irol-faq">Investor FAQs</a></td></tr></table><table width="198" border="0" cellspacing="0" cellpadding="0"><tr><td width="198" class="MTitle">Contact Baidu</td></tr></table><table width="198" border="0" cellpadding="0" cellspacing="0" class="MIBoxMargin"><tr><td width="198" class="MItem"><a href="phoenix.zhtml?c=188488&p=irol-contacts">IR Contacts</a></td></tr><tr><td class="MItem"><a href="phoenix.zhtml?c=188488&p=irol-inforeq">Request Information</a></td></tr><tr><td class="MItem"><a href="phoenix.zhtml?c=188488&p=irol-alerts">Email Alert</a></td></tr></table><table width="198" border="0" cellspacing="0" cellpadding="0"><tr align="center"><td width="198" align="center"><a href="http://www.baidu.com"><img src="http://media.corporate-ir.net/media_files/irol/18/188488/images/back1.gif" alt="back to baidu" width="164" border="0" /></a></td></tr></table></td><td valign="top"><br /><h1>The Baidu Story</h1><br /><br /><span class="ccbnTxt"><p>Our name was inspired by a poem written more than 800 years ago during the Song Dynasty. The poem compares the search for a retreating beauty amid chaotic glamour with the search for one's dream while confronted by life's many obstacles. "…hundreds and thousands of times, for her I searched in chaos, suddenly, I turned by chance, to where the lights were waning, and there she stood." Baidu, whose literal meaning is “hundreds of times”, represents a persistent search for the ideal. <br><br>
|
||||
Baidu was founded in 2000 by Internet pioneer Robin Li, creator of visionary search technology Hyperlink Analysis, with the mission of providing the best way for people to find what they’re looking for online. Over the past decade we have strived to fulfill this mission by listening carefully to our users’ needs and wants. To provide intelligent, relevant search results for the tens of billions of queries that are entered into our search platform every day, we focus on powering the best technology optimized for up-to-date local tastes and preferences. Our deep understanding of Chinese language and culture is central to our success and this kind of knowledge allows us to tailor our search technology for our users’ needs. Just to cite one example, we believe there are at least 38 ways of saying "I" in the Chinese language. It is important that we recognize these nuances to effectively address our users’ requests.
|
||||
<br><br>
|
||||
We provide our users with many channels to find and share information. In addition to our core web search product, we power many popular community-based products, such as Baidu PostBar, the world’s first and largest Chinese-language query-based searchable online community platform, Baidu Knows, the world’s largest Chinese-language interactive knowledge-sharing platform, and Baidu Encyclopedia, the world’s largest user-generated Chinese-language encyclopedia, to name but a few. Beyond these marquee products we also offer dozens of helpful vertical search-based products, such as Maps, Image Search, Video Search, News Search, and many more. We power these through our cutting-edge technology, continually innovating to enhance these services. Our new Box Computing Open Platform brings users deep-linked content and even applications they can use directly through their search box. We believe that Box Computing will dramatically improve people’s search experience and become ubiquitous across all Internet devices including computers and mobile platforms.
|
||||
<br><br>
|
||||
In addition to serving individual users, we also serve as a media platform for online marketing customers. Our business model is mainly based on a performance-oriented marketing platform for businesses to cost effectively reach relevant Internet users. We offer performance-based online marketing services and display advertisements through both Baidu organic websites and our affiliated websites (our Union business). Our affiliated websites lead traffic to us through integrating a Baidu search box into their sites and/or by displaying relevant contextual promotional links for our customers. The majority of our revenue is derived from performance-based online marketing services and our customers pay on a cost per click basis – that is, our customers only pay when their paid-link is clicked through and they get the “lead”. Our goal is to give our customers an online marketing platform that has a wide range of functions which they can use to meet their marketing needs and an extensive selection of tools for managing their accounts as well as data for analyzing and optimizing ROI.
|
||||
<br><br>
|
||||
To best serve our customers, our sales efforts consist of direct sales teams in first tier cities and third-party distributors in lower tier cities. This allows us to better penetrate each market and tailor our support and personal interaction based on customers’ needs. Today, our online marketing platform serves hundreds of thousands of small- and medium-sized enterprises (SMEs) and many branded multinational customers. The measurable ROI offered by our online marketing platform has made it one of the most effective marketing platforms for companies targeting the Chinese market. We will continue to strive to provide an extra level of value-added sales and customer service to address a wide range of customer needs. Our focus is to help the market continue to develop and educate the many companies who don’t understand the benefits of search engine marketing so that we can help them grow their businesses.
|
||||
<br><br>
|
||||
You don’t need us to tell you that China’s Internet space is booming. With the world’s largest Internet user population – 564 million as of end of 2012 – and a long way to go to reach internet penetration levels of developed countries, China’s internet is growing in both influence and sophistication. And as more and more Chinese come online, Baidu continues to innovate to meet their increasingly diverse tastes. With our goal of best serving the needs of our users and customers with intelligent and relevant solutions, we look forward to a robust future. </p>
|
||||
</span></td></tr></table><table width="100%" border="0" cellpadding="0" cellspacing="0"><tr><td><img src="http://media.corporate-ir.net/media_files/irol/global_images/spacer.gif" width="10" height="50" /></td></tr></table><table width="100%" border="0" align="center" cellpadding="0" cellspacing="0"><tr><td height="27" align="center" style="border-top:1px solid #D6D6D6; font-family:Arial; font-size:12px;">Copyright © <script language="JavaScript">
|
||||
var year="";
|
||||
mydate=new Date();
|
||||
myyear= mydate.getYear();
|
||||
year=(myyear > 200) ? myyear : 1900 + myyear;
|
||||
document.write(year);
|
||||
</script> Baidu, Inc. All Rights Reserved.</td></tr></table></body></html
|
||||
</html
|
|
@ -18,6 +18,7 @@ import javax.persistence.Transient;
|
|||
|
||||
import org.bench4q.master.domain.IAggregate;
|
||||
import org.bench4q.master.domain.testplan.LoadDistribute;
|
||||
import org.bench4q.share.enums.master.TestPlanStatus;
|
||||
|
||||
@Entity
|
||||
@Table(name = "testplan")
|
||||
|
@ -31,6 +32,7 @@ public class TestPlan implements IAggregate {
|
|||
private String testPlanRunId;
|
||||
private String currentStatus;
|
||||
private int failTimes;
|
||||
private int requiredLoad;
|
||||
private Set<TestPlanScript> testPlanScripts;
|
||||
private Set<Monitor> monitors;
|
||||
private LoadDistribute loadDistribute;
|
||||
|
@ -119,6 +121,15 @@ public class TestPlan implements IAggregate {
|
|||
this.failTimes = failTimes;
|
||||
}
|
||||
|
||||
@Column(name = "requiredLoad", nullable = false)
|
||||
public int getRequiredLoad() {
|
||||
return requiredLoad;
|
||||
}
|
||||
|
||||
public void setRequiredLoad(int requiredLoad) {
|
||||
this.requiredLoad = requiredLoad;
|
||||
}
|
||||
|
||||
@OneToMany(mappedBy = "testPlan", cascade = CascadeType.ALL, orphanRemoval = true, fetch = FetchType.EAGER)
|
||||
public Set<TestPlanScript> getTestPlanScripts() {
|
||||
return testPlanScripts;
|
||||
|
@ -155,7 +166,7 @@ public class TestPlan implements IAggregate {
|
|||
return null;
|
||||
}
|
||||
|
||||
public boolean run() {
|
||||
public TestPlanStatus run() {
|
||||
return this.getLoadDistribute().generateLoadForTestPlan(this);
|
||||
}
|
||||
|
||||
|
@ -178,12 +189,4 @@ public class TestPlan implements IAggregate {
|
|||
return true;
|
||||
}
|
||||
|
||||
@Transient
|
||||
public int getTotalRequireLoad() {
|
||||
int result = 0;
|
||||
for (TestPlanScript testPlanScript : this.getTestPlanScripts()) {
|
||||
result += testPlanScript.getRequireLoad();
|
||||
}
|
||||
return result;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -26,6 +26,7 @@ import org.bench4q.share.models.master.MonitorModel;
|
|||
import org.bench4q.share.models.master.RunningScriptModel;
|
||||
import org.bench4q.share.models.master.TestPlanModel;
|
||||
import org.bench4q.share.models.master.TestScriptConfig;
|
||||
import org.bench4q.master.exception.ExceptionUtils.IllegalParameterException;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
|
@ -54,7 +55,7 @@ public class TestPlanFactory {
|
|||
}
|
||||
|
||||
public TestPlan createATestPlanWithoutIdentity(TestPlanModel testPlanModel,
|
||||
User user, UUID runId) {
|
||||
User user, UUID runId) throws IllegalParameterException {
|
||||
TestPlan result = new TestPlan();
|
||||
result.setCreateDateTime(new Date());
|
||||
result.setCurrentStatus(TestPlanStatus.NotStart.name());
|
||||
|
@ -65,13 +66,21 @@ public class TestPlanFactory {
|
|||
result.setTestPlanRunId(runId.toString());
|
||||
result.setUser(user);
|
||||
Set<TestPlanScript> testPlanScripts = new HashSet<TestPlanScript>();
|
||||
int requiredLoad = 0;
|
||||
for (RunningScriptModel runningScriptModel : testPlanModel
|
||||
.getRunningScriptModels()) {
|
||||
if (runningScriptModel.getRequireLoad() <= 0) {
|
||||
throw new IllegalParameterException(
|
||||
"runningScriptModel's requireLoad is L.T. zero where scriptId is "
|
||||
+ runningScriptModel.getScriptId());
|
||||
}
|
||||
requiredLoad += runningScriptModel.getRequireLoad();
|
||||
testPlanScripts.add(createATestPlanScriptWithoutId(
|
||||
runningScriptModel.getRequireLoad(),
|
||||
runningScriptModel.getScriptId(),
|
||||
runningScriptModel.getConfig(), result));
|
||||
}
|
||||
result.setRequiredLoad(requiredLoad);
|
||||
result.setTestPlanScripts(testPlanScripts);
|
||||
|
||||
Set<Monitor> monitors = new HashSet<Monitor>();
|
||||
|
|
|
@ -73,13 +73,36 @@ public class TestPlanEngine implements TaskCompleteCallback,
|
|||
|
||||
public void doRunTestPlan(final UUID testPlanId) {
|
||||
TestPlan testPlan = getTestPlanRepository().getTestPlanBy(testPlanId);
|
||||
if (!testPlan.run()) {
|
||||
commitError(testPlan);
|
||||
testPlan = null;
|
||||
return;
|
||||
// if (!testPlan.run()) {
|
||||
// commitError(testPlan);
|
||||
// testPlan = null;
|
||||
// return;
|
||||
// }
|
||||
// commitInRunning(testPlan);
|
||||
// getTestPlanRepository().attachRunningTestPlan(testPlan);
|
||||
TestPlanStatus returnStatus = testPlan.run();
|
||||
commitTestPlanStaus(returnStatus, testPlan);
|
||||
}
|
||||
|
||||
private void commitTestPlanStaus(TestPlanStatus returnStatus,
|
||||
TestPlan testPlan) {
|
||||
if (returnStatus == TestPlanStatus.InRunning) {
|
||||
commitInRunning(testPlan);
|
||||
} else {
|
||||
commitError(testPlan, returnStatus);
|
||||
}
|
||||
commitInRunning(testPlan);
|
||||
}
|
||||
|
||||
private void commitError(TestPlan testPlan, TestPlanStatus errorStatus) {
|
||||
testPlan.setCurrentStatus(errorStatus.name());
|
||||
getTestPlanRepository().updateEntity(testPlan);
|
||||
}
|
||||
|
||||
private void commitInRunning(TestPlan testPlan) {
|
||||
testPlan.setCurrentStatus(TestPlanStatus.InRunning.name());
|
||||
testPlan.setLatestRunningTime(new Date());
|
||||
getTestPlanRepository().attachRunningTestPlan(testPlan);
|
||||
getTestPlanRepository().updateEntity(testPlan);
|
||||
}
|
||||
|
||||
public void doTaskComplete(UUID testPlanID) {
|
||||
|
@ -99,17 +122,6 @@ public class TestPlanEngine implements TaskCompleteCallback,
|
|||
this.getTestPlanRepository().updateEntity(testPlan);
|
||||
}
|
||||
|
||||
private void commitError(TestPlan testPlan) {
|
||||
testPlan.setCurrentStatus(TestPlanStatus.Error.name());
|
||||
getTestPlanRepository().updateEntity(testPlan);
|
||||
}
|
||||
|
||||
private void commitInRunning(TestPlan testPlan) {
|
||||
testPlan.setCurrentStatus(TestPlanStatus.InRunning.name());
|
||||
testPlan.setLatestRunningTime(new Date());
|
||||
getTestPlanRepository().updateEntity(testPlan);
|
||||
}
|
||||
|
||||
public void executePendingTestPlan() {
|
||||
|
||||
}
|
||||
|
|
|
@ -4,6 +4,7 @@ import java.util.LinkedList;
|
|||
import java.util.List;
|
||||
import java.util.UUID;
|
||||
|
||||
import org.apache.log4j.Logger;
|
||||
import org.bench4q.master.domain.entity.Monitor;
|
||||
import org.bench4q.master.domain.entity.TestPlan;
|
||||
import org.bench4q.master.domain.entity.TestPlanScript;
|
||||
|
@ -11,6 +12,8 @@ import org.bench4q.master.domain.entity.User;
|
|||
import org.bench4q.master.domain.factory.BusinessModelMapFactory;
|
||||
import org.bench4q.master.domain.factory.TestPlanFactory;
|
||||
import org.bench4q.master.domain.repository.TestPlanRepository;
|
||||
import org.bench4q.master.exception.ExceptionLog;
|
||||
import org.bench4q.master.exception.ExceptionUtils.IllegalParameterException;
|
||||
import org.bench4q.share.enums.master.TestPlanStatus;
|
||||
import org.bench4q.share.models.master.MonitorModel;
|
||||
import org.bench4q.share.models.master.TestPlanModel;
|
||||
|
@ -54,12 +57,18 @@ public class TestPlanService {
|
|||
this.testPlanFactory = testPlanFactory;
|
||||
}
|
||||
|
||||
public boolean submitTestPlan(
|
||||
final TestPlanModel testPlanBusinessModel, final User user,
|
||||
final UUID testPlanRunId) {
|
||||
return this.getTestPlanRepository().attach(
|
||||
this.getTestPlanFactory().createATestPlanWithoutIdentity(
|
||||
testPlanBusinessModel, user, testPlanRunId));
|
||||
public boolean submitTestPlan(final TestPlanModel testPlanBusinessModel,
|
||||
final User user, final UUID testPlanRunId) {
|
||||
try {
|
||||
return this.getTestPlanRepository().attach(
|
||||
this.getTestPlanFactory().createATestPlanWithoutIdentity(
|
||||
testPlanBusinessModel, user, testPlanRunId));
|
||||
} catch (IllegalParameterException e) {
|
||||
// TODO: give back the message
|
||||
Logger.getLogger(TestPlanService.class).error(
|
||||
ExceptionLog.getStackTrace(e) + e.getMessage());
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
public List<TestPlan> loadTestPlans(User user) {
|
||||
|
|
|
@ -10,6 +10,7 @@ import org.bench4q.master.domain.interfaces.RunningScriptInterface;
|
|||
import org.bench4q.master.domain.repository.TestPlanRepository;
|
||||
import org.bench4q.master.testplan.highavailable.HighAvailablePool;
|
||||
import org.bench4q.master.transaction.script.ScriptLoadCommand;
|
||||
import org.bench4q.share.enums.master.TestPlanStatus;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
|
@ -47,30 +48,32 @@ public class LoadDistribute {
|
|||
return this.getHighAvailableAgentPool().getMaxAvailableLoad() >= totalRequireLoad;
|
||||
}
|
||||
|
||||
public boolean generateLoadForTestPlan(TestPlan testPlanInDomain) {
|
||||
public TestPlanStatus generateLoadForTestPlan(TestPlan testPlanInDomain) {
|
||||
synchronized (this.highAvailableAgentPool.getPool()) {
|
||||
if (!hasEnoughMaxLoad(testPlanInDomain.getTotalRequireLoad())) {
|
||||
if (!hasEnoughMaxLoad(testPlanInDomain.getRequiredLoad())) {
|
||||
logger.error("There is no enough max load in the pool!");
|
||||
return false;
|
||||
return TestPlanStatus.PendingNoEnoughMaxLoad;
|
||||
}
|
||||
if (!hasEnoughCurrentLoad(testPlanInDomain.getTotalRequireLoad())) {
|
||||
if (!hasEnoughCurrentLoad(testPlanInDomain.getRequiredLoad())) {
|
||||
logger.info("There is no enough current load in the pool!");
|
||||
return false;
|
||||
return TestPlanStatus.PendingNoEnoughCurrentLoad;
|
||||
}
|
||||
// TODO: add the algorithm of ditribute load
|
||||
for (RunningScriptInterface testPlanScript : testPlanInDomain
|
||||
.getTestPlanScripts()) {
|
||||
if (!distributeLoadForScript(testPlanScript)) {
|
||||
return false;
|
||||
return TestPlanStatus.ErrorInDistributeLoadForScript;
|
||||
}
|
||||
// testPlanScript.doAfterRun();
|
||||
}
|
||||
this.getHighAvailableAgentPool().timerTask();
|
||||
testPlanInDomain.doAfterRun();
|
||||
return true;
|
||||
doAfterDistributeLoadForTestPlan(testPlanInDomain);
|
||||
return TestPlanStatus.InRunning;
|
||||
}
|
||||
}
|
||||
|
||||
private void doAfterDistributeLoadForTestPlan(TestPlan testPlanInDomain) {
|
||||
this.getHighAvailableAgentPool().timerTask();
|
||||
testPlanInDomain.doAfterRun();
|
||||
}
|
||||
|
||||
public boolean distributeLoadForScript(RunningScriptInterface testPlanScript) {
|
||||
ScriptLoadCommand scriptLoadCommand = new ScriptLoadCommand(
|
||||
testPlanScript, testPlanScript.getTestPlanID());
|
||||
|
|
|
@ -55,4 +55,19 @@ public class ExceptionUtils {
|
|||
return "Transaction commit fails!";
|
||||
}
|
||||
}
|
||||
|
||||
public static class IllegalParameterException extends Exception {
|
||||
private static final long serialVersionUID = -4999157899142651582L;
|
||||
private String msg;
|
||||
|
||||
public IllegalParameterException(String msg) {
|
||||
this.msg = msg;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getMessage() {
|
||||
return this.msg;
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
|
|
@ -47,11 +47,13 @@ public class Test_TestPlan extends TestBase_MakeUpTestPlan {
|
|||
|
||||
@Test
|
||||
public void testRun() throws InterruptedException {
|
||||
assertTrue(this.getHaPool().getCurrentAvailableLoad() >= 500);
|
||||
TestPlan testPlanFromRepo = this.getTestPlanRepository().getTestPlanBy(
|
||||
getTestPlanRunIdUuid());
|
||||
TestPlan testPlanInDomain = this.getTestPlanFactory().convertToDomain(
|
||||
testPlanFromRepo);
|
||||
testPlanInDomain.run();
|
||||
TestPlanStatus returnStatus = testPlanInDomain.run();
|
||||
assertEquals(TestPlanStatus.InRunning, returnStatus);
|
||||
assertTrue(this.getTestPlanRepository().updateEntity(testPlanInDomain));
|
||||
TestPlan testPlanAfterRun = this.getTestPlanRepository().getTestPlanBy(
|
||||
getTestPlanRunIdUuid());
|
||||
|
|
|
@ -37,11 +37,6 @@ public class Test_TestPlanEngine extends TestBase_MakeUpTestPlan {
|
|||
testForStatus(status);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testCommitError() throws Exception {
|
||||
testForStatus(TestPlanStatus.Error);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testInRunning() throws Exception {
|
||||
testForStatus(TestPlanStatus.InRunning);
|
||||
|
@ -65,9 +60,8 @@ public class Test_TestPlanEngine extends TestBase_MakeUpTestPlan {
|
|||
assertEquals(TestPlanStatus.InRunning,
|
||||
TestPlanStatus.valueOf(testPlan.getCurrentStatus()));
|
||||
assertTrue(testPlan.getLatestRunningTime().after(dateBeforeRun));
|
||||
assertEquals(
|
||||
TestPlanStatus.InRunning,
|
||||
TestPlanStatus.valueOf(this.getTestPlanRepository()
|
||||
assertEquals(TestPlanStatus.InRunning,
|
||||
TestPlanStatus.valueOf(getTestPlanRepository()
|
||||
.getRunningTestPlanBy(getTestPlanRunIdUuid())
|
||||
.getCurrentStatus()));
|
||||
cleanUpForTestPlanRunning();
|
||||
|
@ -82,8 +76,8 @@ public class Test_TestPlanEngine extends TestBase_MakeUpTestPlan {
|
|||
this.setTestPlanRunIdUuid(this.getTestPlanEngine().runWith(
|
||||
createATestPlanWithOneScript(scriptId), user));
|
||||
Thread.sleep(10000);
|
||||
assertEquals(
|
||||
TestPlanStatus.Error,
|
||||
assertNotEquals(
|
||||
TestPlanStatus.InRunning,
|
||||
TestPlanStatus.valueOf(this.getTestPlanRepository()
|
||||
.getTestPlanBy(getTestPlanRunIdUuid())
|
||||
.getCurrentStatus()));
|
||||
|
|
|
@ -9,6 +9,7 @@ import org.bench4q.master.domain.entity.TestPlan;
|
|||
import org.bench4q.master.domain.factory.TestPlanFactory;
|
||||
import org.bench4q.master.domain.testplan.LoadDistribute;
|
||||
import org.bench4q.master.test.TestBase_MakeUpTestPlan;
|
||||
import org.bench4q.share.enums.master.TestPlanStatus;
|
||||
import org.junit.After;
|
||||
import org.junit.Before;
|
||||
import org.junit.Test;
|
||||
|
@ -67,10 +68,13 @@ public class Test_LoadDistribute extends TestBase_MakeUpTestPlan {
|
|||
public void testGenerateLoadForTestPlan() {
|
||||
TestPlan testPlanInDomain = this.getTestPlanRepository().getTestPlanBy(
|
||||
getTestPlanRunIdUuid());
|
||||
|
||||
testPlanInDomain = this.getTestPlanFactory().convertToDomain(
|
||||
testPlanInDomain);
|
||||
assertTrue(this.getLoadDistribute().generateLoadForTestPlan(
|
||||
testPlanInDomain));
|
||||
assertEquals(TestPlanStatus.InRunning, this.getLoadDistribute()
|
||||
.generateLoadForTestPlan(testPlanInDomain));
|
||||
assertEquals(EACH_SCRIPT_LOAD_SMALLSCALE,
|
||||
testPlanInDomain.getRequiredLoad());
|
||||
testPlanInDomain = this.getTestPlanRepository().getTestPlanBy(
|
||||
getTestPlanRunIdUuid());
|
||||
Set<RunningAgentDB> runningAgentsAfterRefetch = testPlanInDomain
|
||||
|
|
|
@ -51,6 +51,7 @@ public class Test_ScriptLoadCommand extends TestBase_MakeUpTestPlan {
|
|||
@Test
|
||||
public void testExecuteWithTestPlanScript() {
|
||||
submitATestPlanWithOneScript();
|
||||
this.getHaPool().timerTask();
|
||||
TestPlanScript testPlanScript = this.getTestPlanRepository()
|
||||
.getTestPlanBy(getTestPlanRunIdUuid())
|
||||
.extracSpecifiedScript(this.getScriptId());
|
||||
|
|
Loading…
Reference in New Issue