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

Fixed issues in test_system_bus and test_system_flush which were preventing...

Fixed issues in test_system_bus and test_system_flush which were preventing them from being able to be run against physical drives
parent 392d9165
Loading
Loading
Loading
Loading
+2 −2
Original line number Diff line number Diff line
@@ -265,7 +265,7 @@ void test_that_we_can_register_sockets(void)
    socket_info * si = calloc(1, sizeof(socket_info) + 2 * PDU_PROTO_MAX_LEN);
    assert(si != NULL);

    int fd = KineticSocket_Connect("localhost", KINETIC_PORT);
    int fd = KineticSocket_Connect(SYSTEM_TEST_HOST, KINETIC_PORT);
    assert(fd != KINETIC_SOCKET_DESCRIPTOR_INVALID);
    bool result = bus_register_socket(res.bus, BUS_SOCKET_PLAIN, fd, si);
    assert(result);
@@ -303,7 +303,7 @@ void test_that_we_can_register_SSL_sockets(void)
    socket_info * si = calloc(1, sizeof(socket_info) + 2 * PDU_PROTO_MAX_LEN);
    assert(si != NULL);

    int fd = KineticSocket_Connect("localhost", KINETIC_TLS_PORT);
    int fd = KineticSocket_Connect(SYSTEM_TEST_HOST, KINETIC_TLS_PORT);
    assert(fd != KINETIC_SOCKET_DESCRIPTOR_INVALID);
    bool result = bus_register_socket(res.bus, BUS_SOCKET_SSL, fd, si);
    assert(result);
+29 −39
Original line number Diff line number Diff line
@@ -101,28 +101,26 @@ void test_Flush_should_flush_pending_async_PUTs_and_DELETEs(void)
    }

    // Arguments shared between entries
    uint8_t VersionData[1024];
    ByteBuffer VersionBuffer = ByteBuffer_Create(VersionData, sizeof(VersionData), 0);
    uint8_t TagData[1024];
    ByteBuffer TagBuffer = ByteBuffer_CreateAndAppendCString(TagData, sizeof(TagData), "tag_val");
    ByteBuffer tagBuffer = ByteBuffer_CreateAndAppendCString(TagData, sizeof(TagData), "tag_val");

    uint8_t key1[] = "key1";
    uint8_t value1[] = "value1";
    ByteBuffer KeyBuffer1 = ByteBuffer_Create(key1, sizeof(key1), 0);
    ByteBuffer ValueBuffer1 = ByteBuffer_Create(value1, sizeof(value1), 0);
    uint8_t key1[10];
    ByteBuffer keyBuffer1 = ByteBuffer_CreateAndAppendCString(key1, sizeof(key1), "key1");
    uint8_t value1[10];
    ByteBuffer valueBuffer1 = ByteBuffer_CreateAndAppendCString(value1, sizeof(value1), "value1");

    uint8_t key2[] = "key2";
    uint8_t value2[] = "value2";
    ByteBuffer KeyBuffer2 = ByteBuffer_Create(key2, sizeof(key2), 0);
    ByteBuffer ValueBuffer2 = ByteBuffer_Create(value2, sizeof(value2), 0);
    uint8_t key2[10];
    ByteBuffer keyBuffer2 = ByteBuffer_CreateAndAppendCString(key2, sizeof(key2), "key2");
    uint8_t value2[10];
    ByteBuffer valueBuffer2 = ByteBuffer_CreateAndAppendCString(value2, sizeof(value2), "value2");

    // Do a blocking PUT ("key1" => "value1") so we can delete it later
    KineticEntry Entry = (KineticEntry) {
        .key = KeyBuffer1,
        .newVersion = VersionBuffer,
        .tag = TagBuffer,
        .key = keyBuffer1,
        .tag = tagBuffer,
        .algorithm = KINETIC_ALGORITHM_SHA1,
        .value = ValueBuffer1,
        .value = valueBuffer1,
        .synchronization = KINETIC_SYNCHRONIZATION_WRITEBACK,
        .force = true,
    };
    KineticStatus status = KineticClient_Put(&Fixture.session, &Entry, NULL);
@@ -130,25 +128,23 @@ void test_Flush_should_flush_pending_async_PUTs_and_DELETEs(void)

    // Do an async PUT ("key2" => "value2") so we can flush to complete it
    Entry = (KineticEntry) {
        .key = KeyBuffer2,
        .newVersion = VersionBuffer,
        .tag = TagBuffer,
        .key = keyBuffer2,
        .tag = tagBuffer,
        .algorithm = KINETIC_ALGORITHM_SHA1,
        .value = ValueBuffer2,
        .value = valueBuffer2,
        .synchronization = KINETIC_SYNCHRONIZATION_WRITEBACK,
        .force = true,
    };
    KineticCompletionClosure no_op_closure = {
        .callback = &no_op_callback,
    };

    // Include a closure to signal that the PUT should be non-blocking.
    status = KineticClient_Put(&Fixture.session, &Entry, &no_op_closure);
    status = KineticClient_Put(&Fixture.session, &Entry, NULL);
    TEST_ASSERT_EQUAL_KineticStatus(KINETIC_STATUS_SUCCESS, status);

    // Do an async DELETE so we can flush to complete it
    KineticEntry deleteEntry = {
        .key = KeyBuffer1,
        .key = keyBuffer1,
    };
    KineticCompletionClosure no_op_closure = {
        .callback = &no_op_callback,
    };
    status = KineticClient_Delete(&Fixture.session, &deleteEntry, &no_op_closure);

@@ -158,29 +154,23 @@ void test_Flush_should_flush_pending_async_PUTs_and_DELETEs(void)
    TEST_ASSERT_EQUAL_KineticStatus(KINETIC_STATUS_SUCCESS, status);

    // Reset buffers for GET requests
    ByteBuffer_Reset(&ValueBuffer1);
    ByteBuffer_Reset(&ValueBuffer2);
    ByteBuffer_Reset(&valueBuffer1);
    ByteBuffer_Reset(&valueBuffer2);

    // GET key1 --> expect NOT FOUND
    KineticEntry getEntry1 = {
        .key = KeyBuffer1,
        .dbVersion = VersionBuffer,
        .tag = TagBuffer,
        .algorithm = KINETIC_ALGORITHM_SHA1,
        .value = ValueBuffer1,
        .force = true,
        .key = keyBuffer1,
        .tag = tagBuffer,
        .value = valueBuffer1,
    };
    status = KineticClient_Get(&Fixture.session, &getEntry1, NULL);
    TEST_ASSERT_EQUAL_KineticStatus(KINETIC_STATUS_NOT_FOUND, status);

    // GET key2 --> present
    KineticEntry getEntry2 = {
        .key = KeyBuffer2,
        .dbVersion = VersionBuffer,
        .tag = TagBuffer,
        .algorithm = KINETIC_ALGORITHM_SHA1,
        .value = ValueBuffer2,
        .force = true,
        .key = keyBuffer2,
        .tag = tagBuffer,
        .value = valueBuffer2,
    };
    status = KineticClient_Get(&Fixture.session, &getEntry2, NULL);
    TEST_ASSERT_EQUAL_KineticStatus(KINETIC_STATUS_SUCCESS, status);