Example #1
0
 // ENG-2553. Connection shouldn't timeout.
 void testLargeReply() {
     (m_client)->createConnection("localhost");
     std::vector<Parameter> signature;
     signature.push_back(Parameter(WIRE_TYPE_STRING));
     signature.push_back(Parameter(WIRE_TYPE_STRING));
     signature.push_back(Parameter(WIRE_TYPE_STRING));
     Procedure proc("Insert", signature);
     ParameterSet *params = proc.params();
     params->addString("Hello").addString("World").addString("English");
     m_voltdb->filenameForNextResponse("mimicLargeReply");
     InvocationResponse response = (m_client)->invoke(proc);
     CPPUNIT_ASSERT(response.success());
 }
Example #2
0
    void testBreakEventLoopViaCallback() {
        (m_client)->createConnection("localhost");
        std::vector<Parameter> signature;
        signature.push_back(Parameter(WIRE_TYPE_STRING));
        signature.push_back(Parameter(WIRE_TYPE_STRING));
        signature.push_back(Parameter(WIRE_TYPE_STRING));
        Procedure proc("Insert", signature);
        ParameterSet *params = proc.params();
        params->addString("Hello").addString("World").addString("English");
        m_voltdb->filenameForNextResponse("invocation_response_success.msg");

        BreakingSyncCallback *cb = new BreakingSyncCallback();
        boost::shared_ptr<ProcedureCallback> callback(cb);
        (m_client)->invoke(proc, callback);

        (m_client)->run();
    }
Example #3
0
 void testSyncInvoke() {
     m_client->createConnection("localhost");
     std::vector<Parameter> signature;
     signature.push_back(Parameter(WIRE_TYPE_STRING));
     signature.push_back(Parameter(WIRE_TYPE_STRING));
     signature.push_back(Parameter(WIRE_TYPE_STRING));
     Procedure proc("Insert", signature);
     ParameterSet *params = proc.params();
     params->addString("Hello").addString("World").addString("English");
     m_voltdb->filenameForNextResponse("invocation_response_success.msg");
     InvocationResponse response = (m_client)->invoke(proc);
     CPPUNIT_ASSERT(response.success());
     CPPUNIT_ASSERT(response.statusString() == "");
     CPPUNIT_ASSERT(response.appStatusCode() == -128);
     CPPUNIT_ASSERT(response.appStatusString() == "");
     CPPUNIT_ASSERT(response.results().size() == 0);
 }
Example #4
0
    void testCallbackThrows() {
        class Listener : public StatusListener {
        public:
            bool reported;
           Listener() : reported(false) {}
            virtual bool uncaughtException(
                    std::exception exception,
                    boost::shared_ptr<voltdb::ProcedureCallback> callback,
                    InvocationResponse response) {
                reported = true;
                return true;
            }
            virtual bool connectionLost(std::string hostname, int32_t connectionsLeft) {
                CPPUNIT_ASSERT(false);
                return false;
            }
            virtual bool backpressure(bool hasBackpressure) {
                CPPUNIT_ASSERT(false);
                return false;
            }
        }  listener;
        (*m_dlistener)->m_listener = &listener;

        (m_client)->createConnection("localhost");
        std::vector<Parameter> signature;
        signature.push_back(Parameter(WIRE_TYPE_STRING));
        signature.push_back(Parameter(WIRE_TYPE_STRING));
        signature.push_back(Parameter(WIRE_TYPE_STRING));
        Procedure proc("Insert", signature);
        ParameterSet *params = proc.params();
        params->addString("Hello").addString("World").addString("English");
        m_voltdb->filenameForNextResponse("invocation_response_success.msg");

        ThrowingCallback *cb = new ThrowingCallback();
        boost::shared_ptr<ProcedureCallback> callback(cb);
        (m_client)->invoke(proc, callback);

        (m_client)->run();
    }
Example #5
0
    void testAsyncInvoke() {
        (m_client)->createConnection("localhost");
        std::vector<Parameter> signature;
        signature.push_back(Parameter(WIRE_TYPE_STRING));
        signature.push_back(Parameter(WIRE_TYPE_STRING));
        signature.push_back(Parameter(WIRE_TYPE_STRING));
        Procedure proc("Insert", signature);
        ParameterSet *params = proc.params();
        params->addString("Hello").addString("World").addString("English");
        m_voltdb->filenameForNextResponse("invocation_response_success.msg");

        SyncCallback *cb = new SyncCallback();
        boost::shared_ptr<ProcedureCallback> callback(cb);
        (m_client)->invoke(proc, callback);
        while (!cb->m_hasResponse) {
            (m_client)->runOnce();
        }
        InvocationResponse response = cb->m_response;
        CPPUNIT_ASSERT(response.success());
        CPPUNIT_ASSERT(response.statusString() == "");
        CPPUNIT_ASSERT(response.appStatusCode() == -128);
        CPPUNIT_ASSERT(response.appStatusString() == "");
        CPPUNIT_ASSERT(response.results().size() == 0);
    }