simplify usage of HTTP server
This commit is contained in:
parent
af78af3d5f
commit
3bd620a53b
@ -36,7 +36,7 @@ class Epload(Experiment):
|
||||
self.topo.command_to(self.topo_config.server, "rm " + \
|
||||
Epload.SERVER_LOG )
|
||||
|
||||
def getHTTPServerCmd(self):
|
||||
def get_http_server_cmd(self):
|
||||
s = "/etc/init.d/apache2 restart &>" + Epload.SERVER_LOG + " &"
|
||||
print(s)
|
||||
return s
|
||||
@ -71,7 +71,7 @@ class Epload(Experiment):
|
||||
super(Epload, self).clean()
|
||||
|
||||
def run(self):
|
||||
cmd = self.getHTTPServerCmd()
|
||||
cmd = self.get_http_server_cmd()
|
||||
self.topo.command_to(self.topo_config.server, cmd)
|
||||
self.topo.command_to(self.topo_config.client, "sleep 2")
|
||||
|
||||
|
@ -25,13 +25,12 @@ class HTTP(RandomFileExperiment):
|
||||
self.topo.command_to(self.topo_config.server, "rm " + \
|
||||
HTTP.SERVER_LOG )
|
||||
|
||||
def getHTTPServerCmd(self):
|
||||
s = "python {}/../utils/http_server.py &> {}&".format(
|
||||
os.path.dirname(os.path.abspath(__file__)), HTTP.SERVER_LOG)
|
||||
def get_http_server_cmd(self):
|
||||
s = "python3 -m http.server 80 &> {}&".format(HTTP.SERVER_LOG)
|
||||
logging.info(s)
|
||||
return s
|
||||
|
||||
def getHTTPClientCmd(self):
|
||||
def get_http_client_cmd(self):
|
||||
s = "(time {} http://{}/{} --no-check-certificate) &> {}".format(HTTP.WGET_BIN,
|
||||
self.topo_config.get_server_ip(), self.file, HTTP.CLIENT_LOG)
|
||||
logging.info(s)
|
||||
@ -41,12 +40,12 @@ class HTTP(RandomFileExperiment):
|
||||
super(HTTP, self).clean()
|
||||
|
||||
def run(self):
|
||||
cmd = self.getHTTPServerCmd()
|
||||
cmd = self.get_http_server_cmd()
|
||||
self.topo.command_to(self.topo_config.server, "netstat -sn > netstat_server_before")
|
||||
self.topo.command_to(self.topo_config.server, cmd)
|
||||
|
||||
self.topo.command_to(self.topo_config.client, "sleep 2")
|
||||
cmd = self.getHTTPClientCmd()
|
||||
cmd = self.get_http_client_cmd()
|
||||
self.topo.command_to(self.topo_config.client, "netstat -sn > netstat_client_before")
|
||||
self.topo.command_to(self.topo_config.client, cmd)
|
||||
self.topo.command_to(self.topo_config.server, "netstat -sn > netstat_server_after")
|
||||
|
@ -48,12 +48,12 @@ class SiriHTTP(Siri, RandomFileExperiment):
|
||||
self.topo.command_to(self.topo_config.server, "rm " + \
|
||||
SiriHTTP.HTTP_SERVER_LOG)
|
||||
|
||||
def getHTTPServerCmd(self):
|
||||
def get_http_server_cmd(self):
|
||||
s = "/etc/init.d/apache2 restart &>" + SiriHTTP.SERVER_LOG + "&"
|
||||
print(s)
|
||||
return s
|
||||
|
||||
def getHTTPClientCmd(self):
|
||||
def get_http_client_cmd(self):
|
||||
s = SiriHTTP.WGET_BIN + " http://" + self.topo_config.get_server_ip() + \
|
||||
"/" + self.file + " --no-check-certificate"
|
||||
print(s)
|
||||
@ -66,12 +66,12 @@ class SiriHTTP(Siri, RandomFileExperiment):
|
||||
cmd = self.get_siri_server_cmd()
|
||||
self.topo.command_to(self.topo_config.server, "netstat -sn > netstat_server_before")
|
||||
self.topo.command_to(self.topo_config.server, cmd)
|
||||
cmd = self.getHTTPServerCmd()
|
||||
cmd = self.get_http_server_cmd()
|
||||
self.topo.command_to(self.topo_config.server, cmd)
|
||||
|
||||
self.topo.command_to(self.topo_config.client, "sleep 2")
|
||||
self.topo.command_to(self.topo_config.client, "netstat -sn > netstat_client_before")
|
||||
cmd = self.getHTTPClientCmd()
|
||||
cmd = self.get_http_client_cmd()
|
||||
self.topo.command_to(self.topo_config.client, "for i in {1..200}; do " + cmd + "; done &")
|
||||
cmd = self.get_siri_client_cmd()
|
||||
self.topo.command_to(self.topo_config.client, cmd)
|
||||
|
@ -1,27 +0,0 @@
|
||||
'''
|
||||
From :
|
||||
http://code.activestate.com/recipes/442473-simple-http-server-supporting-ssl-secure-communica/
|
||||
|
||||
SimpleHTTPServer.py - simple HTTP server supporting SSL.
|
||||
|
||||
- the default port is 80.
|
||||
|
||||
usage: python SimpleHTTPServer.py
|
||||
'''
|
||||
|
||||
import sys
|
||||
if sys.version_info[0] == 3:
|
||||
# Python 3
|
||||
import http.server
|
||||
server_address = ('', 80)
|
||||
httpd = http.server.HTTPServer(server_address, http.server.SimpleHTTPRequestHandler)
|
||||
print("Serving HTTP on 0.0.0.0 port 80...")
|
||||
httpd.serve_forever()
|
||||
else:
|
||||
# Python2
|
||||
import BaseHTTPServer, SimpleHTTPServer
|
||||
import os
|
||||
|
||||
httpd = BaseHTTPServer.HTTPServer(('', 443), SimpleHTTPServer.SimpleHTTPRequestHandler)
|
||||
print("Serving HTTP on 0.0.0.0 port 80...")
|
||||
httpd.serve_forever()
|
Loading…
Reference in New Issue
Block a user