diff --git a/tests/http/README.md b/tests/http/README.md new file mode 100644 index 000000000..ae7f08f10 --- /dev/null +++ b/tests/http/README.md @@ -0,0 +1,5 @@ +HTTP one-to-all test +====== + +This code can be deployed across a large number of VMs or containers to test and benchmark HTTP traffic within a virtual network at scale. The agent acts as a server and can query other agents, while the server collects agent data and tells agents about each other. It's designed to use RFC4193-based ZeroTier IPv6 addresses within the cluster, which allows the easy provisioning of a large cluster without IP conflicts. + diff --git a/tests/http/agent.js b/tests/http/agent.js new file mode 100644 index 000000000..14964d873 --- /dev/null +++ b/tests/http/agent.js @@ -0,0 +1,224 @@ +// --------------------------------------------------------------------------- +// Customizable parameters: + +// How frequently in ms to run tests +//var RUN_TEST_EVERY = (60 * 5 * 1000); +var RUN_TEST_EVERY = 1000; + +// Maximum test duration in milliseconds (must be less than RUN_TEST_EVERY) +var TEST_DURATION = (60 * 1000); + +// Where should I contact to register and query a list of other nodes? +var SERVER_HOST = '127.0.0.1'; +var SERVER_PORT = 18080; + +// Which port should agents use for their HTTP? +var AGENT_PORT = 18888; + +// Payload size in bytes +var PAYLOAD_SIZE = 4096; + +// --------------------------------------------------------------------------- + +var ipaddr = require('ipaddr.js'); +var os = require('os'); +var http = require('http'); +var async = require('async'); + +var express = require('express'); +var app = express(); + +// Find our ZeroTier-assigned RFC4193 IPv6 address +var thisAgentId = null; +var interfaces = os.networkInterfaces(); +if (!interfaces) { + console.error('FATAL: os.networkInterfaces() failed.'); + process.exit(1); +} +for(var ifname in interfaces) { + var ifaddrs = interfaces[ifname]; + if (Array.isArray(ifaddrs)) { + for(var i=0;i