static bool run(TestRunner& tr) { if(tr.isTestEnabled("fixme")) { // load and start node Node* node = Tester::loadNode(tr, "test-services-customcatalog"); assertNoException( node->start()); Config cfg = tr.getApp()->getConfig(); sTestDataDir = cfg["test"]["dataPath"]->getString(); //config["node"]["modulePath"] = append BPE_MODULES_DIRECTORY; //config["bitmunk.catalog.CustomCatalog"]["uploadListings"] = false; // run tests customCatalogTests(*node, tr); // stop and unload node node->stop(); Tester::unloadNode(tr); } if(tr.isTestEnabled("fixme")) { // load and start node Node* node = Tester::loadNode(tr, "test-services-customcatalog"); assertNoException( node->start()); Config cfg = tr.getApp()->getConfig(); sTestDataDir = cfg["test"]["dataPath"]->getString(); //config["node"]["modulePath"] = BPE_MODULES_DIRECTORY; //config["bitmunk.catalog.CustomCatalog"]["uploadListings"] = true; // run tests interactiveCustomCatalogTests(*node, tr); // stop and unload node node->stop(); Tester::unloadNode(tr); } return true; };
static bool run(TestRunner& tr) { if(tr.isTestEnabled("dyno-perf")) { Config cfg = tr.getApp()->getConfig(); // number of loops for each test int loops = cfg->hasMember("loops") ? cfg["loops"]->getInt32() : 1; for(int i = 0; i < loops; ++i) { runDynoIterTest(tr); } } return true; }
static void pingPerfTest(Node& node, TestRunner& tr) { tr.group("ping perf"); Messenger* messenger = node.getMessenger(); // number of loops for each test Config cfg = tr.getApp()->getConfig(); //node.getConfigManager()->getConfig( // tester->getApp()->getMetaConfig()["groups"]["main"]->getString()); int n = cfg->hasMember("loops") ? cfg["loops"]->getInt32() : 50; tr.test("insecure get"); { Url url("/api/3.0/system/test/ping"); DynamicObject dummy; uint64_t startTime = Timer::startTiming(); for(int i = 0; i < n; ++i) { messenger->getFromBitmunk(&url, dummy); } double dt = Timer::getSeconds(startTime); printf("t=%g ms, r=%g ms, r/s=%g", dt * 1000.0, dt/n * 1000.0, n/dt); } tr.passIfNoException(); tr.test("secure get"); { Url url("/api/3.0/system/test/ping"); DynamicObject dummy; uint64_t startTime = Timer::startTiming(); for(int i = 0; i < n; ++i) { messenger->getSecureFromBitmunk(&url, dummy, node.getDefaultUserId()); } double dt = Timer::getSeconds(startTime); printf("t=%g ms, r=%g ms, r/s=%g", dt * 1000.0, dt/n * 1000.0, n/dt); } tr.passIfNoException(); tr.ungroup(); }
static void runDynoIterTest(TestRunner& tr) { tr.group("DynamicObject iter perf"); bool all = false; Config cfg = tr.getApp()->getConfig(); if(cfg->hasMember("all")) { all = cfg["all"]->getBoolean(); } if(all) { //runDynoIterTest1(tr, "array s:10M i:1 ", 10000000, 1); runDynoIterTest1(tr, "array s:1M i:1 ", 1000000, 1); runDynoIterTest1(tr, "array s:1M i:2 ", 1000000, 2); runDynoIterTest1(tr, "array s:1M i:5 ", 1000000, 5); runDynoIterTest1(tr, "array s:1M i:10 ", 1000000, 10); } runDynoIterTest1(tr, "array s:100K i:100 ", 100000, 100); runDynoIterTest1(tr, "array s:10K i:1K ", 10000, 1000); runDynoIterTest1(tr, "array s:1K i:10K ", 1000, 10000); runDynoIterTest1(tr, "array s:100 i:100K ", 100, 100000); runDynoIterTest1(tr, "array s:10 i:1M ", 10, 1000000); if(all) { runDynoIterTest1(tr, "array s:5 i:1M ", 5, 1000000); runDynoIterTest1(tr, "array s:2 i:1M ", 2, 1000000); runDynoIterTest1(tr, "array s:1 i:1M ", 1, 1000000); runDynoIterTest1(tr, "array s:0 i:1M ", 0, 1000000); //runDynoIterTest1(tr, "array s:5 i:2M ", 5, 2000000); //runDynoIterTest1(tr, "array s:2 i:5M ", 2, 5000000); //runDynoIterTest1(tr, "array s:1 i:10M ", 1, 10000000); } tr.ungroup(); }
static void runPingTest(TestRunner& tr) { tr.test("Ping"); Config cfg = tr.getApp()->getConfig()["pong"]; // Stats and control PingPong pingPong(cfg); // create kernel Kernel k; // set thread stack size in engine (128k) k.getEngine()->getThreadPool()->setThreadStackSize( cfg["threadStackSize"]->getUInt32()); // optional for testing -- // limit threads to 2: one for accepting, 1 for handling //k.getEngine()->getThreadPool()->setPoolSize(2); k.getEngine()->getThreadPool()->setPoolSize(cfg["threads"]->getUInt32()); // start engine k.getEngine()->start(); // create server Server server; server.setMaxConnectionCount(cfg["maxConnections"]->getInt32()); InternetAddress address("0.0.0.0", cfg["port"]->getUInt32()); // create SSL/generic http connection servicer HttpConnectionServicer hcs; // SslContext context; // SslSocketDataPresenter presenter1(&context); // NullSocketDataPresenter presenter2; // SocketDataPresenterList list(false); // list.add(&presenter1); // list.add(&presenter2); //server.addConnectionService(&address, &hcs);//, &list); server.addConnectionService( &address, &hcs, NULL, "pong", cfg["maxConnections"]->getInt32(), cfg["backlog"]->getInt32()); // create test http request servicer NoContentServicer noContentSrv(&pingPong, "/"); hcs.addRequestServicer(&noContentSrv, false); PingServicer ping(&pingPong, "/pong"); hcs.addRequestServicer(&ping, false); const int bufsize = 4096; char buf[bufsize]; memset(buf, '.', bufsize); DataServicer data(&pingPong, "/data", buf, bufsize); hcs.addRequestServicer(&data, false); StatsServicer stats(&pingPong, "/stats"); hcs.addRequestServicer(&stats, false); ResetServicer reset(&pingPong, "/reset"); hcs.addRequestServicer(&reset, false); QuitServicer quit(&pingPong, "/quit"); hcs.addRequestServicer(&quit, false); if(server.start(&k)) { uint64_t num = cfg["num"]->getUInt64(); MO_INFO("Server started."); if(num == 0) { MO_INFO("Servicing forever. CTRL-C to quit."); } { MO_INFO("Servicing approximately %" PRIu64 " connections.", num); } } else if(Exception::get() != NULL) { MO_ERROR("Server started with errors=%s\n", Exception::get()->getMessage()); } // start timing pingPong.reset(); // either serve for limited time, or wait for lock uint32_t time = cfg["time"]->getUInt32(); if(time != 0) { Thread::sleep(time); } else { pingPong.getLock().wait(); } server.stop(); MO_INFO("Server stopped."); // stop kernel engine k.getEngine()->stop(); tr.passIfNoException(); }
static bool run(TestRunner& tr) { if(tr.isTestEnabled("fixme")) { // load and start node Node* node = Tester::loadNode(tr/*, "test-node-services"*/); assertNoException( node->start()); //cout << "You may need to remove testuser5.profile from /tmp/ to " // "run the password update test." << endl; // login the devuser //node.login("devuser", "password"); //node.login("testuser5", "password"); assertNoExceptionSet(); // run tests //mediaGetTest(node, tr); //userGetTest(node, tr); //userAddTest(node, tr); //userUpdateTest(node, tr); //accountGetTest(node, tr); //contributorGetTest(node, tr); //permissionGetTest(node, tr); //reviewGetTest(node, tr); //acquireLicenseTest(node, tr); // performance tests //accountGetPerfTest(node, tr); // stop and unload node node->stop(); Tester::unloadNode(tr); } if(tr.isTestEnabled("fixme")) { // load and start node Node* node = Tester::loadNode(tr/*, "test-node-services"*/); assertNoException( node->start()); // login the devuser //node.login("devuser", "password"); //node.login("testuser5", "password"); assertNoExceptionSet(); Config cfg = tr.getApp()->getConfig(); const char* test = cfg["monarch.test.Tester"]["test"]->getString(); bool all = (strcmp(test, "all") == 0); if(all || (strcmp(test, "ping") == 0)) { pingPerfTest(*node, tr); } // stop and unload node node->stop(); Tester::unloadNode(tr); } return true; };