remove some sysout and add some gitIgnore
This commit is contained in:
parent
1425c9c5db
commit
015e6e67d9
|
@ -2,3 +2,6 @@
|
|||
.classpath
|
||||
/.settings
|
||||
/target
|
||||
/Scripts
|
||||
/report
|
||||
/logs
|
||||
|
|
|
@ -226,7 +226,9 @@ public class TestPlanController extends BaseController {
|
|||
response.setHeader("Content-disposition", "attachment; filename=\""
|
||||
+ testPlanRunID.toString() + ".pdf\"");
|
||||
response.addHeader("Content-Length", "" + pdfBuffer.length);
|
||||
System.out.println(pdfBuffer.length);
|
||||
// this.logger.info("report of test plan " +
|
||||
// testPlanRunID.toString()
|
||||
// + " length is: " + pdfBuffer.length);
|
||||
response.setContentType("application/pdf");
|
||||
outputStream.write(pdfBuffer);
|
||||
outputStream.flush();
|
||||
|
|
|
@ -7,6 +7,7 @@ import javax.xml.bind.JAXBContext;
|
|||
import javax.xml.bind.JAXBException;
|
||||
import javax.xml.bind.Unmarshaller;
|
||||
|
||||
import org.apache.log4j.Logger;
|
||||
import org.bench4q.master.communication.HttpRequester.HttpResponse;
|
||||
import org.bench4q.master.communication.agent.ServerStatusModel;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
|
@ -15,6 +16,7 @@ import org.springframework.stereotype.Component;
|
|||
@Component
|
||||
public class AgentStateService {
|
||||
private HttpRequester httpRequester = new HttpRequester();
|
||||
private static Logger logger = Logger.getLogger(AgentStateService.class);
|
||||
|
||||
public HttpRequester getHttpRequester() {
|
||||
return httpRequester;
|
||||
|
@ -34,10 +36,11 @@ public class AgentStateService {
|
|||
}
|
||||
return _extractServerStatusModel(httpResponse.getContent());
|
||||
} catch (IOException e) {
|
||||
System.out.println("agent :" + hostName + " break down!");
|
||||
logger.error("agent :" + hostName + " break down!");
|
||||
return null;
|
||||
} catch (JAXBException e) {
|
||||
System.out.println("unmarshall happen an exception!");
|
||||
logger.error("unmarshall happen an exception! whose host name is: "
|
||||
+ hostName);
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -54,11 +54,6 @@ public class ScriptCapturer {
|
|||
private void startHttpCaptureProxyServer(int port, String filePath) {
|
||||
try {
|
||||
this.getHttpCaptureMap().get(new Integer(port)).startProxyServer();
|
||||
// httpCapture = new HttpCapture(this.getScriptPath(), port,
|
||||
// HTTPCATUREGENERATOR_STRING, new JTextArea());
|
||||
// httpCapture.startProxyServer();
|
||||
// System.out.println("INFO: Proxy Server Started at Port: "
|
||||
// + this.getPortForRecord());
|
||||
} catch (IOException e1) {
|
||||
System.out.println("Error When build the proxy server!");
|
||||
e1.printStackTrace();
|
||||
|
|
|
@ -9,6 +9,7 @@ import javax.xml.bind.JAXBContext;
|
|||
import javax.xml.bind.JAXBException;
|
||||
import javax.xml.bind.Unmarshaller;
|
||||
|
||||
import org.apache.log4j.Logger;
|
||||
import org.bench4q.master.communication.HttpRequester;
|
||||
import org.bench4q.master.communication.HttpRequester.HttpResponse;
|
||||
import org.bench4q.master.communication.agent.RunScenarioResultModel;
|
||||
|
@ -34,6 +35,7 @@ public class AgentService {
|
|||
private SessionHelper sessionHelper;
|
||||
private Object AGENT_LOCK;
|
||||
private HttpRequester httpRequester;
|
||||
private static Logger logger = Logger.getLogger(AgentService.class);
|
||||
|
||||
public AgentService() {
|
||||
this.setAgentLock(new Object());
|
||||
|
@ -157,7 +159,8 @@ public class AgentService {
|
|||
agent.setRemainLoad(agent.getRemainLoad() + backLoad);
|
||||
session.merge(agent);
|
||||
transaction.commit();
|
||||
System.out.println(agent.getRemainLoad());
|
||||
logger.info("The agent with hostname " + agent.getHostName()
|
||||
+ " remainload is " + agent.getRemainLoad());
|
||||
return true;
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
|
@ -182,7 +185,8 @@ public class AgentService {
|
|||
agent.setRemainLoad(agent.getRemainLoad() - requireLoad);
|
||||
session.merge(agent);
|
||||
transaction.commit();
|
||||
System.out.println(agent.getRemainLoad());
|
||||
logger.info("agent with hostname " + agent.getHostName()
|
||||
+ "remain load is " + agent.getRemainLoad());
|
||||
return true;
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
|
@ -208,8 +212,9 @@ public class AgentService {
|
|||
}
|
||||
|
||||
agentFromDB.setRemainLoad(agentFromDB.getMaxLoad());
|
||||
Agent agent = (Agent) session.merge(agentFromDB);
|
||||
System.out.println(agent.getRemainLoad());
|
||||
session.merge(agentFromDB);
|
||||
logger.info("agent with hostname " + agentFromDB.getHostName()
|
||||
+ "remain load is " + agentFromDB.getRemainLoad());
|
||||
transaction.commit();
|
||||
return true;
|
||||
} catch (Exception e) {
|
||||
|
|
|
@ -23,36 +23,32 @@ import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;
|
|||
@ContextConfiguration(locations = "classpath:applicationContext.xml")
|
||||
public class AgentPoolControllerTest extends TestBase {
|
||||
private final String URLSTRING = "http://localhost:8080/agentManage";
|
||||
private final String HOSTNAME = "127.0.0.1";
|
||||
private final static String HOSTNAME1 = "127.0.0.1";
|
||||
private final static String HOSTNAME2 = "133.133.12.9";
|
||||
|
||||
public static void main(String[] args) throws JAXBException, IOException {
|
||||
AgentPoolControllerTest test = new AgentPoolControllerTest();
|
||||
test.accessTocken = test.login();
|
||||
test.addAgentToPool();
|
||||
test.setAccessTocken(test.login());
|
||||
test.addAgentToPool(HOSTNAME2);
|
||||
// test.removeAgentToPool();
|
||||
test.loadAgentsFromPool();
|
||||
}
|
||||
|
||||
@Test
|
||||
public void addAgentToPool() throws JAXBException, IOException {
|
||||
public void addAgentToPool(String hostName) throws JAXBException,
|
||||
IOException {
|
||||
String urlString = this.URLSTRING + "/addAgentToPool";
|
||||
String content;
|
||||
AgentResponseModel agentResponseModel = new AgentResponseModel();
|
||||
|
||||
Agent agent = new Agent();
|
||||
agent.setHostName(HOSTNAME);
|
||||
agent.setHostName(hostName);
|
||||
agent.setMaxLoad(500);
|
||||
agent.setRemainLoad(500);
|
||||
agent.setPort(6565);
|
||||
|
||||
content = _marshalAgentToString(agent);
|
||||
|
||||
Map<String, String> properties = new HashMap<String, String>();
|
||||
properties.put(AUTH_HEADER_PROPERTY, this.ACCES_TOCKEN_STARTER
|
||||
+ this.accessTocken);
|
||||
|
||||
HttpResponse httpResponse = this.httpRequester.sendPostXml(urlString,
|
||||
content, properties);
|
||||
marshalAgentToString(agent),
|
||||
makeAccessTockenMap(this.getAccessTocken()));
|
||||
|
||||
agentResponseModel = _extractAgentResponseModel(httpResponse);
|
||||
|
||||
|
@ -67,7 +63,7 @@ public class AgentPoolControllerTest extends TestBase {
|
|||
|
||||
String urlString = this.URLSTRING + "/removeAgentFromPool";
|
||||
Map<String, String> map = new HashMap<String, String>();
|
||||
map.put("hostName", HOSTNAME);
|
||||
map.put("hostName", HOSTNAME1);
|
||||
HttpResponse httpResponse = this.httpRequester.sendGet(urlString, map,
|
||||
propertiesMap);
|
||||
System.out.println(httpResponse.getContent());
|
||||
|
@ -95,7 +91,7 @@ public class AgentPoolControllerTest extends TestBase {
|
|||
return agentResponseModel;
|
||||
}
|
||||
|
||||
private String _marshalAgentToString(Agent agent) throws JAXBException {
|
||||
private String marshalAgentToString(Agent agent) throws JAXBException {
|
||||
StringWriter stringWriter = new StringWriter();
|
||||
Marshaller marshaller = JAXBContext.newInstance(agent.getClass())
|
||||
.createMarshaller();
|
||||
|
|
Loading…
Reference in New Issue