def testStream(self): with WsgiDavTestServer(provider=self.provider): with Timing("testStream", self.SIZE): with open(self.test_file, "rb") as f: r = requests.put("http://127.0.0.1:8080/bar.txt", data=f) self.assertEqual(r.status_code, 204) self.assertEqual(os.path.getsize(self.target_path), self.SIZE)
def _bench_litmus(opts): try: with Timing("litmus test suite"): # Run litmus test suite without printing output res = subprocess.check_output( ["litmus", "http://127.0.0.1:8080/", "tester", "secret"]) # res = subprocess.check_call(["litmus", "http://127.0.0.1:8080/", "tester", "secret"], # stdout=DEVNULL, stderr=subprocess.STDOUT) except OSError: print("This test requires the litmus test suite (see http://www.webdav.org/neon/litmus/)") raise return res
def _runner(opts): with Timing(">>> Summary >>>:"): _bench_litmus(opts) _bench_script(opts) return
def _bench_script(opts): # print("Scriptes benchmarks") # print("_bench_script(), {}...".format(opts)) from tests import davclient server_url = opts.get("external_server") or "http://localhost:8080/" client = davclient.DAVClient(server_url) client.set_basic_auth("tester", "secret") # Prepare file content data_1k = b"." * 1000 # Prepare big file with 10 MB lines = [] line = "." * (1000 - 6 - len("\n")) for i in compat.xrange(10 * 1000): lines.append("%04i: %s\n" % (i, line)) data_10m = "".join(lines) data_10m = compat.to_bytes(data_10m) with Timing("Setup fixture"): _setup_fixture(opts, client) # PUT files with Timing("1000 x PUT 1 kB", 1000, "{:>6.1f} req/sec", 1, "{:>7,.3f} MB/sec"): for _ in compat.xrange(1000): client.put("/test/file1.txt", data_1k) client.check_response() with Timing("10 x PUT 10 MB", 10, "{:>6.1f} req/sec", 100, "{:>7,.3f} MB/sec"): for _ in compat.xrange(10): client.put("/test/bigfile.txt", data_10m) client.check_response() with Timing("1000 x GET 1 kB", 1000, "{:>6.1f} req/sec", 1, "{:>7,.3f} MB/sec"): for _ in compat.xrange(1000): body = client.get("/test/file1.txt") client.check_response() with Timing("10 x GET 10 MB", 10, "{:>6.1f} req/sec", 100, "{:>7,.3f} MB/sec"): for _ in compat.xrange(10): body = client.get("/test/bigfile.txt") # noqa F841 client.check_response() with Timing("10 x COPY 10 MB", 10, "{:>6.1f} req/sec", 100, "{:>7,.3f} MB/sec"): for _ in compat.xrange(10): client.copy( "/test/bigfile.txt", "/test/bigfile-copy.txt", depth="infinity", overwrite=True, ) client.check_response() with Timing("100 x MOVE 10 MB", 100, "{:>6.1f} req/sec"): name_from = "/test/bigfile-copy.txt" for i in compat.xrange(100): name_to = "/test/bigfile-copy-{}.txt".format(i) client.move(name_from, name_to, depth="infinity", overwrite=True) name_from = name_to client.check_response() with Timing("100 x LOCK/UNLOCK", 200, "{:>6.1f} req/sec"): for _ in compat.xrange(100): locks = client.set_lock( "/test/lock-0", owner="test-bench", locktype="write", lockscope="exclusive", depth="infinity", ) token = locks[0] client.unlock("/test/lock-0", token) client.check_response() with Timing("1000 x PROPPATCH", 1000, "{:>6.1f} req/sec"): for _ in compat.xrange(1000): client.proppatch( "/test/file1.txt", set_props=[("{testns:}testname", "testval")], remove_props=None, ) client.check_response() with Timing("500 x PROPFIND", 500, "{:>6.1f} req/sec"): for _ in compat.xrange(500): client.propfind("/", properties="allprop", namespace="DAV:", depth=None, headers=None) client.check_response()