Exemplo n.º 1
0
KineticClient * KineticClient_Init(KineticClientConfig *config)
{
    KineticLogger_Init(config->logFile, config->logLevel);
    KineticClient * client = KineticCalloc(1, sizeof(*client));
    if (client == NULL) { 
        KineticLogger_Close();
        return NULL; 
    }

    /* Use defaults if set to 0. */
    if (config->readerThreads == 0) {
        config->readerThreads = KINETIC_CLIENT_DEFAULT_READER_THREADS;
    }
    if (config->maxThreadpoolThreads == 0) {
        config->maxThreadpoolThreads = KINETIC_CLIENT_DEFAULT_MAX_THREADPOOL_THREADS;
    }

    bool success = KineticBus_Init(client, config);
    if (!success) {
        KineticFree(client);
        KineticLogger_Close();
        return NULL;
    }
    return client;
}
Exemplo n.º 2
0
void test_KineticLogger_Init_should_initialize_the_logger_with_specified_output_file(void)
{
    KineticLogger_Init(TEST_LOG_FILE, 3);
    KineticLogger_Log(0, "Some message to log file...");
    TEST_ASSERT_FILE_EXISTS(TEST_LOG_FILE);
    TEST_ASSERT_EQUAL(3, KineticLogLevel);
}
Exemplo n.º 3
0
void setUp(void)
{
    KineticLogger_Init("stdout", 1);
    Session = (KineticSession) {.connected = true};
    Operation = (KineticOperation) {.session = &Session};
    KineticRequest_Init(&Request, &Session);
    Operation.request = &Request;
}

void tearDown(void)
{
    KineticLogger_Close();
}

/*******************************************************************************
 * Client Operations
*******************************************************************************/

void test_KineticBuilder_BuildNoop_should_build_and_execute_a_NOOP_operation(void)
{
    KineticOperation_ValidateOperation_Expect(&Operation);

    KineticBuilder_BuildNoop(&Operation);

    TEST_ASSERT_TRUE(Request.message.command.header->has_messagetype);
    TEST_ASSERT_FALSE(Request.pinAuth);
    TEST_ASSERT_EQUAL(0, Operation.timeoutSeconds);
    TEST_ASSERT_EQUAL(COM__SEAGATE__KINETIC__PROTO__COMMAND__MESSAGE_TYPE__NOOP, Request.message.command.header->messagetype);
    TEST_ASSERT_NULL(Operation.response);
}
Exemplo n.º 4
0
void test_KineticLogger_Log_should_write_log_message_to_file(void)
{
    const char* msg = "Some really important message!";
    KineticLogger_Init(TEST_LOG_FILE, 3);
    KineticLogger_LogPrintf(0, msg);
    // TEST_ASSERT_EQUAL_FILE_CONTENT(TEST_LOG_FILE, content, length);
    TEST_ASSERT_FILE_EXISTS(TEST_LOG_FILE);
}
Exemplo n.º 5
0
void setUp(void)
{
    KineticLogger_Init("stdout", 1);
    Session = (KineticSession) {
        .config = (KineticSessionConfig) {
            .host = "anyhost",
            .port = KINETIC_PORT
        },
        .connectionID = 12345,
    };
    KineticRequest_Init(&Request, &Session);
    Operation = (KineticOperation) {
        .session = &Session,
        .request = &Request,
    };
}
void setUp(void)
{
    KineticLogger_Init("stdout", 3);

    // Configure start and end key buffers
    StartKey = ByteBuffer_Create(StartKeyData, sizeof(StartKeyData), sizeof(StartKeyData));
    EndKey = ByteBuffer_Create(EndKeyData, sizeof(EndKeyData), sizeof(EndKeyData));

    // Initialize buffers to hold returned keys in requested range
    for (int i = 0; i < MAX_KEYS_RETRIEVED; i++) {
        Keys[i] = ByteBuffer_Create(&KeyRangeData[i], sizeof(KeyRangeData[i]), sizeof(KeyRangeData[i]));
        char keyBuf[64];
        snprintf(keyBuf, sizeof(keyBuf), "key_range_00_%02d", i);
        ByteBuffer_AppendCString(&Keys[i], keyBuf);
    }
}
Exemplo n.º 7
0
void setUp(void)
{
    KineticLogger_Init("stdout", 3);
    Session = (KineticSession) {.connected = false};
}

void tearDown(void)
{
    KineticLogger_Close();
}

void test_KineticAllocator_NewSession_should_return_null_if_calloc_returns_null(void)
{
    KineticCalloc_ExpectAndReturn(1, sizeof(KineticSession), NULL);
    KineticSession * session =  KineticAllocator_NewSession(&MessageBus, &Config);
    TEST_ASSERT_NULL(session);
}
Exemplo n.º 8
0
void setUp(void)
{
    KineticLogger_Init("stdout", 3);
    Session = (KineticSession) {
        .connected = true,
        .socket = 456,
        .config = (KineticSessionConfig) {
            .port = 1234,
            .host = "valid-host.com",
            .hmacKey = ByteArray_CreateWithCString("some valid HMAC key..."),
            .clusterVersion = ClusterVersion,
        }
    };
    KineticRequest_Init(&Request, &Session);
    ByteArray_FillWithDummyData(Value);

    memset(si_buf, 0, SI_BUF_SIZE);
}
Exemplo n.º 9
0
void setUp(void)
{
    KineticLogger_Init("stdout", 3);

    // Create and configure a new Kinetic protocol instance
;
    Session = (KineticSession) {
        .connected = true,
        .socket = 456,
        .config = (KineticSessionConfig) {
            .port = 1234,
            .host = "valid-host.com",
            .hmacKey = ByteArray_CreateWithCString("some valid HMAC key..."),
            .clusterVersion = ClusterVersion,
        }
    };
    ByteArray_FillWithDummyData(Value);
}
Exemplo n.º 10
0
void setUp(void)
{
    // Create and configure a new Kinetic protocol instance
    Key = ByteArray_CreateWithCString("some valid HMAC key...");
    Session = (KineticSession) {
        .nonBlocking = false,
         .port = 1234,
          .host = "valid-host.com",
        .hmacKey = (ByteArray) {.data = &Session.keyData[0], .len = Key.len},
    };
    memcpy(Session.hmacKey.data, Key.data, Key.len);

    KINETIC_CONNECTION_INIT(&Connection);
    Connection.connected = true;
    Connection.socket = 456;
    Connection.session = Session;

    KINETIC_PDU_INIT(&PDU, &Connection);
    ByteArray_FillWithDummyData(Value);
    KineticLogger_Init(NULL);
}
Exemplo n.º 11
0
void test_LOG_LOCATION_should_log_location(void)
{
    KineticLogger_Init(TEST_LOG_FILE, 2);
}
Exemplo n.º 12
0
void setUp(void)
{
    KineticLogger_Init("stdout", 3);
    SessionHandle = KINETIC_HANDLE_INVALID;
}
Exemplo n.º 13
0
void setUp(void)
{
    KineticLogger_Init("stdout", 3);
    FileDesc = -1;
}
Exemplo n.º 14
0
void setUp(void)
{
    KineticLogger_Init(NULL);
    SessionHandle = KINETIC_HANDLE_INVALID;
}
Exemplo n.º 15
0
void setUp(void)
{
    KineticLogger_Init("stdout", 3);
    memset(&Session, 0, sizeof(KineticSession));
    memset(&MessageBus, 0, sizeof(MessageBus));
}
Exemplo n.º 16
0
void test_KineticLogger_Init_should_log_to_stdout_if_specified(void)
{
    KineticLogger_Init("stdout", 0);
    TEST_ASSERT_EQUAL(0, KineticLogLevel);
    KineticLogger_Log(0, "This message should be logged to stdout!");
}
Exemplo n.º 17
0
void test_KineticLogger_Init_should_be_disabled_if_logFile_is_NULL(void)
{
    KineticLogger_Init(NULL, 3);
    TEST_ASSERT_EQUAL(-1, KineticLogLevel);
    KineticLogger_Log(0, "This message should be discarded and not logged!");
}
Exemplo n.º 18
0
void setUp(void)
{
    DELETE_FILE(TEST_LOG_FILE);
    KineticLogger_Init(NULL, -1);
}
void setUp(void)
{
    KineticLogger_Init("stdout", 3);
}
Exemplo n.º 20
0
void KineticClient_Init(const char* log_file, int log_level)
{
    KineticLogger_Init(log_file, log_level);
}