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