Commit 46551fdb authored by Greg Williams's avatar Greg Williams
Browse files

Reenabled Put operation in utility as well as utility tests for Put

parent 3abe64d2
Loading
Loading
Loading
Loading
+3 −1
Original line number Diff line number Diff line
@@ -331,7 +331,7 @@ namespace :tests do
    'release',
    'ruby_sim:shutdown',
    'tests:utility:noop',
    # 'tests:utility:put',
    'tests:utility:put',
  ]

  namespace :utility do
@@ -346,6 +346,7 @@ namespace :tests do
    end

    task :noop => ['release', 'ruby_sim:shutdown'] do
      java_sim_erase_drive
      with_test_server("Testing NoOp Operation") do
        execute_command "./kinetic-c noop"
        execute_command "./kinetic-c --host localhost noop"
@@ -355,6 +356,7 @@ namespace :tests do
    end

    task :put => ['release', 'ruby_sim:shutdown'] do
      java_sim_erase_drive
      with_test_server("Testing Put operation") do
        execute_command "./kinetic-c put"
      end
+1 −0
Original line number Diff line number Diff line
@@ -48,5 +48,6 @@ int NoOp(const char* host,
        return 0;
    }

    KineticClient_Disconnect(&connection);
    return status;
}
+29 −29
Original line number Diff line number Diff line
@@ -20,39 +20,39 @@

#include "put.h"

int Put(
    const char* host,
int Put(const char* host,
        int port,
        bool nonBlocking,
        int64_t clusterVersion,
        int64_t identity,
    const char* hmacKey,
    const uint8_t* value,
        char* hmacKey,
        uint8_t* value,
        int64_t valueLength,
    const char* valueKey,
    const char* version,
    const char* newVersion)
        char* valueKey,
        char* valueTag,
        char* version,
        char* newVersion)
{
    // KineticOperation operation;
    // KineticPDU request, response;
    // KineticConnection connection;
    // KineticMessage requestMsg;
    KineticOperation operation;
    KineticPDU request, response;
    KineticConnection connection;
    KineticMessage requestMsg;
    KineticProto_Status_StatusCode status = KINETIC_PROTO_STATUS_STATUS_CODE_INVALID_STATUS_CODE;
    // bool success;
    // uint8_t value[PDU_VALUE_MAX_LEN];
    bool success;

    // KineticClient_Init(NULL);
    // success = KineticClient_Connect(&connection, host, port, false, clusterVersion);
    // assert(success);
    // success = KineticClient_ConfigureExchange(&exchange, &connection, clusterVersion, identity, key, strlen(key));
    // assert(success);
    // operation = KineticClient_CreateOperation(&exchange, &request, &requestMsg, &response);
    // status = KineticClient_Put(&operation, value, sizeof(value));
    KineticClient_Init(NULL);
    success = KineticClient_Connect(&connection, host, port, nonBlocking,
                                    clusterVersion, identity, hmacKey);
    assert(success);
    operation = KineticClient_CreateOperation(&connection, &request, &requestMsg, &response);
    status = KineticClient_Put(&operation, newVersion, hmacKey, version, valueTag, value, sizeof(value));

    // if (status == KINETIC_PROTO_STATUS_STATUS_CODE_SUCCESS)
    // {
    //     printf("Put operation completed successfully. Your data has been stored!\n");
    // }
    if (status == KINETIC_PROTO_STATUS_STATUS_CODE_SUCCESS)
    {
        printf("Put operation completed successfully. Your data has been stored!\n");
        return 0;
    }

    // KineticClient_Disconnect(&connection);
    KineticClient_Disconnect(&connection);
    return status;
}
+7 −5
Original line number Diff line number Diff line
@@ -38,13 +38,15 @@
 */
int Put(const char* host,
        int port,
        bool nonBlocking,
        int64_t clusterVersion,
        int64_t identity,
        const char* hmacKey,
        const uint8_t* value,
        char* hmacKey,
        uint8_t* value,
        int64_t valueLength,
        const char* valueKey,
        const char* version,
        const char* newVersion);
        char* valueKey,
        char* valueTag,
        char* version,
        char* newVersion);

#endif // _PUT_H
+39 −37
Original line number Diff line number Diff line
@@ -26,7 +26,7 @@

#include "kinetic.h"
#include "noop.h"
// #include "put.h"
#include "put.h"
// #include "get.h"

typedef struct _Arguments {
@@ -120,7 +120,7 @@ int main(int argc, char** argv)
                (long long int)cfg.clusterVersion,
                (long long int)cfg.identity,
                cfg.hmacKey);
            status = NoOp(cfg.host, cfg.port, false, cfg.clusterVersion, cfg.identity, cfg.hmacKey);
            status = NoOp(cfg.host, cfg.port, cfg.nonBlocking, cfg.clusterVersion, cfg.identity, cfg.hmacKey);
            if (status == 0)
            {
                printf("\nNoOp executed successfully!\n\n");
@@ -132,43 +132,45 @@ int main(int argc, char** argv)
            }
        }

        // else if (strcmp("put", op) == 0)
        // {
        //     unsigned int i;
        //     for (i = 0; i < sizeof(cfg.value); i++)
        //     {
        //         cfg.value[i] = (uint8_t)(0x0ff & i);
        //     }
        else if (strcmp("put", op) == 0)
        {
            unsigned int i;
            for (i = 0; i < sizeof(cfg.value); i++)
            {
                cfg.value[i] = (uint8_t)(0x0ff & i);
            }

        //     printf("\n"
        //            "Executing Put w/configuration:\n"
        //            "-------------------------------\n"
        //            "  host: %s\n"
        //            "  port: %d\n"
        //            "  non-blocking: %s\n"
        //            "  clusterVersion: %lld\n"
        //            "  identity: %lld\n"
        //            "  key: '%s'\n"
        //            "  value: %zd bytes\n",
        //         cfg.host,
        //         cfg.port,
        //         cfg.nonBlocking ? "true" : "false",
        //         (long long int)cfg.clusterVersion,
        //         (long long int)cfg.identity,
        //         cfg.key,
        //         sizeof(cfg.value));
            printf("\n"
                   "Executing Put w/configuration:\n"
                   "-------------------------------\n"
                   "  host: %s\n"
                   "  port: %d\n"
                   "  non-blocking: %s\n"
                   "  clusterVersion: %lld\n"
                   "  identity: %lld\n"
                   "  key: '%s'\n"
                   "  value: %zd bytes\n",
                cfg.host,
                cfg.port,
                cfg.nonBlocking ? "true" : "false",
                (long long int)cfg.clusterVersion,
                (long long int)cfg.identity,
                cfg.hmacKey,
                sizeof(cfg.value));

        //     status = Put(cfg.host, cfg.port, cfg.clusterVersion, cfg.identity, cfg.key, cfg.value, sizeof(cfg.value));
        //     if (status == 0)
        //     {
        //         printf("\nPut executed successfully!\n\n");
        //     }
        //     else
        //     {
        //         printf("\nPut operation failed! status=%d\n\n", status);
        //         return -1;
        //     }
        // }
            status = Put(cfg.host, cfg.port, cfg.nonBlocking, cfg.clusterVersion, cfg.identity, cfg.hmacKey,
                         cfg.value, sizeof(cfg.value),
                         "some_value_key...", "some_value_tag...", NULL, "v1.0");
            if (status == 0)
            {
                printf("\nPut executed successfully!\n\n");
            }
            else
            {
                printf("\nPut operation failed! status=%d\n\n", status);
                return -1;
            }
        }

        // else if (strcmp("get", op) == 0)
        // {