Commit a31a23b5 authored by Greg Williams's avatar Greg Williams
Browse files

Disabled logging to file in test_kinetic_socket, since causes deadlock on...

Disabled logging to file in test_kinetic_socket, since causes deadlock on socket which causes subsequent tests to fail after a raw protobuf write to test server.
Removed socket flush and unnecessary sleep from test_kinetic_socket since appears to not be necessary.
Updated to kinetic-ruby gem v0.6.3
parent f38e5eb0
Loading
Loading
Loading
Loading
+1 −1
Original line number Diff line number Diff line
@@ -25,7 +25,7 @@ GEM
      net-http-pipeline
    highline (1.6.21)
    json (1.8.1)
    kinetic-ruby (0.6.2)
    kinetic-ruby (0.6.3)
      beefcake
      rake (>= 0.9.2.2)
      rspec
+13 −11
Original line number Diff line number Diff line
@@ -239,17 +239,19 @@ int KineticSocket_Connect(const char* host, int port, bool blocking)
        // On BSD-like systems we can set SO_NOSIGPIPE on the socket to prevent it from sending a
        // PIPE signal and bringing down the whole application if the server closes the socket
        // forcibly
// #ifdef SO_NOSIGPIPE
//         int set = 1;
//         int setsockopt_result = setsockopt(socket_fd, SOL_SOCKET, SO_NOSIGPIPE, &set, sizeof(set));
//         // Allow ENOTSOCK because it allows tests to use pipes instead of real sockets
//         if (setsockopt_result != 0 && setsockopt_result != ENOTSOCK)
//         {
//             LOG("Failed to set SO_NOSIGPIPE on socket");
//             close(socket_fd);
//             continue;
//         }
// #endif
#if defined(SO_NOSIGPIPE) && !defined(__APPLE__)
        {
            int set = 1;
            int setsockopt_result = setsockopt(socket_fd, SOL_SOCKET, SO_NOSIGPIPE, &set, sizeof(set));
            // Allow ENOTSOCK because it allows tests to use pipes instead of real sockets
            if (setsockopt_result != 0 && setsockopt_result != ENOTSOCK)
            {
                LOG("Failed to set SO_NOSIGPIPE on socket");
                close(socket_fd);
                continue;
            }
        }
#endif

        if (connect(socket_fd, ai->ai_addr, ai->ai_addrlen) == -1)
        {
+4 −0
Original line number Diff line number Diff line
@@ -59,3 +59,7 @@ void test_KineticLogger_Log_should_write_log_message_to_file(void)
    TEST_ASSERT_EQUAL_FILE_CONTENT(TEST_LOG_FILE, content, length);
}

void test_KineticLogger_should_handle_logging_to_file(void)
{
    TEST_IGNORE_MESSAGE("Need fix deadlock when logging to a file!");
}
+7 −7
Original line number Diff line number Diff line
@@ -49,7 +49,7 @@ void setUp(void)
    pProto = NULL;
    if (!LogInitialized)
    {
        KineticLogger_Init("test_kinetic_socket.log");
        KineticLogger_Init(NULL);//"test_kinetic_socket.log");
        LogInitialized = true;
    }
    LOG("--------------------------------------------------------------------------------");
@@ -68,7 +68,7 @@ void tearDown(void)
    {
        LOG("Shutting down socket...");
        KineticSocket_Close(FileDesc);
        sleep(2);
        FileDesc = 0;
    }
}

@@ -97,8 +97,8 @@ void test_KineticSocket_Write_should_write_the_data_to_the_specified_socket(void
    success = KineticSocket_Write(FileDesc, TestData, strlen(TestData));
    TEST_ASSERT_TRUE_MESSAGE(success, "Failed to write to socket!");

    LOG("Flushing socket read pipe...");
    KineticSocket_Read(FileDesc, data, sizeof(data));
    // LOG("Flushing socket read pipe...");
    // KineticSocket_Read(FileDesc, data, sizeof(data));
}

void test_KineticSocket_WriteProtobuf_should_write_serialized_protobuf_to_the_specified_socket(void)
@@ -120,14 +120,14 @@ void test_KineticSocket_WriteProtobuf_should_write_serialized_protobuf_to_the_sp
    success = KineticSocket_WriteProtobuf(FileDesc, &Msg.proto);
    TEST_ASSERT_TRUE_MESSAGE(success, "Failed to write to socket!");

    LOG("Flushing socket read pipe...");
    KineticSocket_Read(FileDesc, data, sizeof(data));
    // LOG("Flushing socket read pipe...");
    // KineticSocket_Read(FileDesc, data, sizeof(data));
}

void test_KineticSocket_Read_should_read_data_from_the_specified_socket(void)
{
    bool success = false;
    const char* readRequest = "read(5)\0";
    const char* readRequest = "read(5)";
    char data[5];
    LOG(__func__);