Commit 9411a576 authored by Greg Williams's avatar Greg Williams
Browse files

Replaced ad-hoc parser for client utility with getopt_long implementation.

Stubbed out PUT operation.
Updated Rakefile to break out unit, integration, system and utility tests, and to also test various command line options for utility tests.
parent e7afb1c7
Loading
Loading
Loading
Loading
+48 −19
Original line number Diff line number Diff line
@@ -128,6 +128,8 @@ namespace :java_sim do

  def java_sim_start

    return if $java_sim

    report_banner "Starting Kinetic Java Simulator"

    java_sim_cleanup
@@ -188,6 +190,8 @@ end
namespace :ruby_sim do

  def start_ruby_server
    return if $kinetic_server

    port = KineticRuby::DEFAULT_KINETIC_PORT
    # port = KineticRuby::TEST_KINETIC_PORT
    $kinetic_server ||= KineticRuby::Server.new(port)
@@ -234,7 +238,7 @@ end

desc "Run client test utility"
task :run do
  execute_command "./build/artifacts/release/kinetic-c", "Running client test utility"
  execute_command "./build/artifacts/release/kinetic-c --noop", "Running client test utility"
end

desc "Prepend license to source files"
@@ -261,27 +265,52 @@ task :default => [
  'release'
]

task :test_all do

namespace :test do
  desc "Run unit tests"
  task :unit do
    report_banner "Running Unit Tests"
    Rake::Task['test:path'].reenable
    Rake::Task['test:path'].invoke('test/unit')
  end

  desc "Run integration tests"
  task :integration => ['ruby_sim:start'] do
    report_banner "Running Integration Tests"
    java_sim_shutdown
    start_ruby_server
    Rake::Task['test:path'].reenable
    Rake::Task['test:path'].invoke('test/integration')
    shutdown_ruby_server
  end

  desc "Run system tests"
  task :system => ['java_sim:start'] do
    report_banner "Running System Tests"
    shutdown_ruby_server
    java_sim_start
    Rake::Task['test:path'].reenable
    Rake::Task['test:path'].invoke('test/system')
  Rake::Task['release'].invoke
  Rake::Task['run'].invoke
    java_sim_shutdown
  end

  desc "Run Kinetic Client Utility tests"
  task :utility => ['ruby_sim:shutdown'] do
    report_banner "Running Kinetic Client Utility Tests"
    shutdown_ruby_server
    java_sim_start
    Rake::Task['release'].invoke
    cd "./build/artifacts/release/" do
      execute_command "./kinetic-c noop"
      execute_command "./kinetic-c --host localhost noop"
      execute_command "./kinetic-c --host 127.0.0.1 noop"
      execute_command "./kinetic-c --blocking --host 127.0.0.1 noop"
    end
  end
end

  report_banner "Finished executing all test suites"
task :test_all => ['test:unit', 'test:integration', 'test:system', 'test:utility'] do
  report_banner "Finished executing all test suites!"
end

desc "Build all and run test utility"
+2 −2
Original line number Diff line number Diff line
@@ -88,7 +88,7 @@
      - -D"$": DEFINES_TEST_PREPROCESS
      - -DGNU_COMPILER
      # - -std=c99
      # - -Wall
      - -Wall
      - ${1}
  :test_linker:
    :executable: gcc
@@ -113,7 +113,7 @@
      - -D"$": 'COLLECTION_DEFINES_RELEASE_AND_VENDOR'
      - -DGNU_COMPILER
      # - -std=c99
      # - -Wall
      - -Wall
      - "-c \"${1}\""
      - "-o \"${2}\""
  :release_linker:
+22 −0
Original line number Diff line number Diff line
@@ -163,3 +163,25 @@ KineticProto_Status_StatusCode KineticApi_NoOp(KineticOperation* operation)

	return status;
}

KineticProto_Status_StatusCode KineticApi_Put(
    KineticOperation* operation,
    uint8_t* value,
    int64_t len)
{
    KineticProto_Status_StatusCode status =
        KINETIC_PROTO_STATUS_STATUS_CODE_INVALID_STATUS_CODE;

    assert(operation->exchange != NULL);
    assert(operation->exchange->connection != NULL);
    assert(operation->request != NULL);
    assert(operation->request->message != NULL);
    assert(operation->response != NULL);
    assert(operation->response->message == NULL);
    assert(value != NULL);
    assert(len < 1024*1024);

    // TODO: Make it happen!!!

    return status;
}
+19 −0
Original line number Diff line number Diff line
@@ -41,6 +41,7 @@ void KineticApi_Init(
 * @param host              Host name or IP address to connect to
 * @param port              Port to establish socket connection on
 * @param blocking          Set to true for blocking or false for non-bloocking I/O
 *
 * @return                  Returns true if connection succeeded
 */
bool KineticApi_Connect(
@@ -58,6 +59,7 @@ bool KineticApi_Connect(
 * @param identity          Identity to use for the exchange
 * @param key               Key to use for HMAC calculations
 * @param keyLength         Length of HMAC key
 *
 * @return                  Returns true if configuration succeeded
 */
bool KineticApi_ConfigureExchange(
@@ -75,6 +77,7 @@ bool KineticApi_ConfigureExchange(
 * @param request           KineticPDU instance to use for request
 * @param requestMsg        KineticMessage instance to use for request
 * @param response          KineticPDU instance to use for reponse
 *
 * @return                  Returns a configured operation instance
 */
KineticOperation KineticApi_CreateOperation(
@@ -87,10 +90,26 @@ KineticOperation KineticApi_CreateOperation(
 * @brief Executes a NOOP command to test whether the Kinetic Device is operational
 *
 * @param operation         KineticOperation instance to use for the operation
 *
 * @return                  Returns the resultant status code
 */
KineticProto_Status_StatusCode KineticApi_NoOp(
    KineticOperation* operation
    );

/**
 * @brief Executes a PUT command to write data to the Kinetic Device
 *
 * @param operation         KineticOperation instance to use for the operation
 * @param value             Value payload buffer
 * @param valueLength       Value payload length (in bytes)
 *
 * @return                  Returns the resultant status code
 */
KineticProto_Status_StatusCode KineticApi_Put(
    KineticOperation* operation,
    uint8_t* value,
    int64_t len
    );

#endif // _KINETIC_API_H
+1 −0
Original line number Diff line number Diff line
@@ -38,6 +38,7 @@
#include <openssl/sha.h>

#define KINETIC_PORT            8123
#define KINETIC_TLS_PORT        8443
#define KINETIC_HMAC_SHA1_LEN   (SHA_DIGEST_LENGTH)
#define KINETIC_HMAC_MAX_LEN    (KINETIC_HMAC_SHA1_LEN)
#define KINETIC_MAX_KEY_LEN     128
Loading