Commit 4b2af9f9 authored by Greg Williams's avatar Greg Williams
Browse files

Merged in 0.8.0 release branch

parents 32a55f5c 3d622e94
Loading
Loading
Loading
Loading
+1 −5
Original line number Diff line number Diff line
@@ -5,12 +5,8 @@
[submodule "kinetic-protocol"]
	path = vendor/kinetic-protocol
	url = https://github.com/Seagate/kinetic-protocol.git
	branch = 2.0.6
	branch = 3.0.5
[submodule "socket99"]
	path = vendor/socket99
	url = https://github.com/silentbicycle/socket99.git
	branch = master
[submodule "zlog"]
	path = vendor/zlog
	url = https://github.com/zma/zlog.git
	branch = master
+0 −1
Original line number Diff line number Diff line
@@ -7,6 +7,5 @@ compiler:
  - gcc
install:
  - bundle install
  - bundle exec ruby ./config/travis_install.rb
script:
  - make all
+100 −64
Original line number Diff line number Diff line
@@ -10,10 +10,10 @@ PUB_INC = ./include
#===============================================================================
CC ?= gcc
OPTIMIZE = -O3
WARN = -Wall -Wextra -pedantic
CDEFS += -D_POSIX_C_SOURCE=1 -D_C99_SOURCE=1
WARN = -Wall -Wextra -Wstrict-prototypes -Wcast-align -pedantic -Wno-missing-field-initializers
CDEFS += -D_POSIX_C_SOURCE=199309L -D_C99_SOURCE=1
CFLAGS += -std=c99 -fPIC -g $(WARN) $(CDEFS) $(OPTIMIZE)
LDFLAGS += -lm -l crypto -l ssl
LDFLAGS += -lm -l crypto -l ssl -l pthread

#===============================================================================
# Kinetic-C Library Build Support
@@ -28,27 +28,35 @@ LIB_DIR = ./src/lib
VENDOR = ./vendor
PROTOBUFC = $(VENDOR)/protobuf-c
SOCKET99 = $(VENDOR)/socket99
VERSION_FILE = ./VERSION
VERSION_FILE = ./config/VERSION
VERSION = ${shell head -n1 $(VERSION_FILE)}

KINETIC_LIB_NAME = $(PROJECT).$(VERSION)
KINETIC_LIB = $(BIN_DIR)/lib$(KINETIC_LIB_NAME).a
LIB_INCS = -I$(LIB_DIR) -I$(PUB_INC) -I$(PROTOBUFC) -I$(VENDOR)
LIB_DEPS = $(PUB_INC)/kinetic_client.h \
	   $(PUB_INC)/byte_array.h \
	   $(PUB_INC)/kinetic_types.h \
	   $(LIB_DIR)/kinetic_connection.h \
	   $(LIB_DIR)/kinetic_hmac.h \
	   $(LIB_DIR)/kinetic_logger.h \
	   $(LIB_DIR)/kinetic_message.h \
LIB_DEPS = \
	$(PROTOBUFC)/protobuf-c/protobuf-c.h \
	$(SOCKET99)/socket99.h \
	$(LIB_DIR)/kinetic_allocator.h \
	$(LIB_DIR)/kinetic_nbo.h \
	$(LIB_DIR)/kinetic_operation.h \
	$(LIB_DIR)/kinetic_pdu.h \
	$(LIB_DIR)/kinetic_proto.h \
	$(LIB_DIR)/kinetic_socket.h \
	   $(LIB_DIR)/kinetic_types_internal.h
	$(LIB_DIR)/kinetic_message.h \
	$(LIB_DIR)/kinetic_logger.h \
	$(LIB_DIR)/kinetic_hmac.h \
	$(LIB_DIR)/kinetic_connection.h \
	$(LIB_DIR)/kinetic_types_internal.h \
	$(PUB_INC)/kinetic_types.h \
	$(PUB_INC)/byte_array.h \
	$(PUB_INC)/kinetic_client.h

# LIB_OBJ = $(patsubst %,$(OUT_DIR)/%,$(LIB_OBJS))
LIB_OBJS = $(OUT_DIR)/kinetic_allocator.o \
LIB_OBJS = \
	$(OUT_DIR)/socket99.o \
	$(OUT_DIR)/protobuf-c.o \
	$(OUT_DIR)/kinetic_allocator.o \
	$(OUT_DIR)/kinetic_nbo.o \
	$(OUT_DIR)/kinetic_operation.o \
	$(OUT_DIR)/kinetic_pdu.o \
@@ -58,48 +66,35 @@ LIB_OBJS = $(OUT_DIR)/kinetic_allocator.o \
	$(OUT_DIR)/kinetic_logger.o \
	$(OUT_DIR)/kinetic_hmac.o \
	$(OUT_DIR)/kinetic_connection.o \
   	   $(OUT_DIR)/kinetic_types.o \
	$(OUT_DIR)/kinetic_types_internal.o \
	$(OUT_DIR)/kinetic_types.o \
	$(OUT_DIR)/byte_array.o \
   	   $(OUT_DIR)/kinetic_client.o \
   	   $(OUT_DIR)/socket99.o \
   	   $(OUT_DIR)/protobuf-c.o
	$(OUT_DIR)/kinetic_client.o
KINETIC_LIB_OTHER_DEPS = Makefile Rakefile $(VERSION_FILE)

default: $(KINETIC_LIB)

all: clean test default run

ci: uninstall all install
	@echo
	@echo --------------------------------------------------------------------------------
	@echo $(PROJECT) build completed successfully!
	@echo --------------------------------------------------------------------------------
	@echo $(PROJECT) v$(VERSION) is in working order
	@echo

test: Rakefile $(LIB_OBJS)
	@echo
	@echo --------------------------------------------------------------------------------
	@echo Testing $(PROJECT)
	@echo --------------------------------------------------------------------------------
	bundle install
	bundle exec rake test_all

clean:
	bundle exec rake clobber
	rm -rf $(BIN_DIR)/* $(OUT_DIR)/*.o *.core
	git submodule update --init

.PHONY: clean

# $(OUT_DIR)/%.o: %.c $(DEPS)
# 	$(CC) -c -o $@ $< $(CFLAGS)
$(OUT_DIR)/socket99.o: $(SOCKET99)/socket99.c $(SOCKET99)/socket99.h
	$(CC) -c -o $@ $< $(CFLAGS) -I$(SOCKET99)
$(OUT_DIR)/protobuf-c.o: $(PROTOBUFC)/protobuf-c/protobuf-c.c $(PROTOBUFC)/protobuf-c/protobuf-c.h
	$(CC) -c -o $@ $< -std=c99 -fPIC -g -Wall -Wno-unused-parameter $(OPTIMIZE) -I$(PROTOBUFC)
$(OUT_DIR)/kinetic_allocator.o: $(LIB_DIR)/kinetic_allocator.c $(LIB_DEPS)
	$(CC) -c -o $@ $< $(CFLAGS) $(LIB_INCS)
$(OUT_DIR)/kinetic_types_internal.o: $(LIB_DIR)/kinetic_types_internal.c $(LIB_DEPS)
	$(CC) -c -o $@ $< $(CFLAGS) $(LIB_INCS)
$(OUT_DIR)/kinetic_nbo.o: $(LIB_DIR)/kinetic_nbo.c $(LIB_DEPS)
	$(CC) -c -o $@ $< $(CFLAGS) $(LIB_INCS)
$(OUT_DIR)/kinetic_operation.o: $(LIB_DIR)/kinetic_operation.c $(LIB_DEPS)
	$(CC) -c -o $@ $< $(CFLAGS) $(LIB_INCS)
$(OUT_DIR)/kinetic_pdu.o: $(LIB_DIR)/kinetic_pdu.c $(LIB_DEPS)
	$(CC) -c -o $@ $< $(CFLAGS) $(LIB_INCS)
$(OUT_DIR)/kinetic_proto.o: $(LIB_DIR)/kinetic_proto.c $(LIB_DEPS)
@@ -114,20 +109,40 @@ $(OUT_DIR)/kinetic_hmac.o: $(LIB_DIR)/kinetic_hmac.c $(LIB_DEPS)
	$(CC) -c -o $@ $< $(CFLAGS) $(LIB_INCS)
$(OUT_DIR)/kinetic_connection.o: $(LIB_DIR)/kinetic_connection.c $(LIB_DEPS)
	$(CC) -c -o $@ $< $(CFLAGS) $(LIB_INCS)
$(OUT_DIR)/kinetic_operation.o: $(LIB_DIR)/kinetic_operation.c $(LIB_DEPS)
$(OUT_DIR)/kinetic_types_internal.o: $(LIB_DIR)/kinetic_types_internal.c $(LIB_DEPS)
	$(CC) -c -o $@ $< $(CFLAGS) $(LIB_INCS)
$(OUT_DIR)/kinetic_types.o: $(LIB_DIR)/kinetic_types.c $(LIB_DEPS)
	$(CC) -c -o $@ $< $(CFLAGS) $(LIB_INCS)
$(OUT_DIR)/byte_array.o: $(LIB_DIR)/byte_array.c $(LIB_DEPS)
	$(CC) -c -o $@ $< $(CFLAGS) $(LIB_INCS)
$(OUT_DIR)/socket99.o: $(SOCKET99)/socket99.c $(SOCKET99)/socket99.h
	$(CC) -c -o $@ $< $(CFLAGS) -I$(SOCKET99)
$(OUT_DIR)/protobuf-c.o: $(PROTOBUFC)/protobuf-c/protobuf-c.c $(PROTOBUFC)/protobuf-c/protobuf-c.h
	$(CC) -c -o $@ $< -std=c99 -fPIC -g -Wall $(OPTIMIZE) -Wno-unused-parameter -I$(PROTOBUFC)
$(OUT_DIR)/kinetic_client.o: $(LIB_DIR)/kinetic_client.c $(LIB_DEPS)
	$(CC) -c -o $@ $< $(CFLAGS) $(LIB_INCS)


ci: uninstall all install
	@echo
	@echo --------------------------------------------------------------------------------
	@echo $(PROJECT) build completed successfully!
	@echo --------------------------------------------------------------------------------
	@echo $(PROJECT) v$(VERSION) is in working order
	@echo


#-------------------------------------------------------------------------------
# Test Support
#-------------------------------------------------------------------------------

test: Rakefile $(LIB_OBJS)
	@echo
	@echo --------------------------------------------------------------------------------
	@echo Testing $(PROJECT)
	@echo --------------------------------------------------------------------------------
	bundle install
	bundle exec rake test_all

JAVA_HOME ?= /usr
JAVA_BIN = $(JAVA_HOME)/bin/java


#-------------------------------------------------------------------------------
# Static and Dynamic Library Build Support
@@ -188,6 +203,28 @@ uninstall:
	$(RM) -f $(PREFIX)/include/protobuf-c.h


#===============================================================================
# Java Simulator Support
#===============================================================================

update_simulator:
	cd vendor/kinetic-java; mvn clean package; cd -
	cp vendor/kinetic-java/kinetic-simulator/target/*.jar vendor/kinetic-java-simulator/

start_simulator:
	./vendor/kinetic-simulator/startSimulator.sh &
	sleep 4

erase_simulator: start_simulator
	./vendor/kinetic-simulator/eraseSimulator.sh
	sleep 1

stop_simulator:
	./vendor/kinetic-simulator/stopSimulator.sh

.PHONY: start_simulator erase_simulator stop_simulator


#===============================================================================
# Test Utility Build Support
#===============================================================================
@@ -196,7 +233,7 @@ UTILITY = kinetic-c-util
UTIL_DIR = ./src/utility
UTIL_EXEC = $(BIN_DIR)/$(UTILITY)
UTIL_OBJ = $(OUT_DIR)/main.o
UTIL_LDFLAGS += -lm -l ssl $(KINETIC_LIB) -l crypto
UTIL_LDFLAGS += -lm -l ssl $(KINETIC_LIB) -l crypto -l pthread

$(UTIL_OBJ): $(UTIL_DIR)/main.c
	$(CC) -c -o $@ $< $(CFLAGS) -I$(PUB_INC) -I$(UTIL_DIR)
@@ -221,17 +258,16 @@ CLASSPATH = $(JAVA_HOME)/lib/tools.jar:$(SIM_JARS_PREFIX)-jar-with-dependencies.
SIM_RUNNER = com.seagate.kinetic.simulator.internal.SimulatorRunner
SIM_ADMIN = com.seagate.kinetic.admin.cli.KineticAdminCLI

run: $(UTIL_EXEC)
run: $(UTIL_EXEC) start_simulator
	@echo
	@echo --------------------------------------------------------------------------------
	@echo Running test utility: $(UTIL_EXEC)
	@echo --------------------------------------------------------------------------------
	@sleep 2
	exec java -classpath "$(CLASSPATH)" $(SIM_RUNNER) "$@" &
	@sleep 5
	exec java -classpath "$(CLASSPATH)" $(SIM_ADMIN) -setup -erase true
	$(UTIL_EXEC) noop put get delete
	exec pkill -f 'java.*kinetic-simulator'
	@echo
	$(UTIL_EXEC) noop
	exec $(UTIL_EXEC) put get delete
	@echo
	@echo Test Utility integration tests w/ kinetic-c lib passed!
	@echo
	@echo Stopping simulator...
	./vendor/kinetic-simulator/stopSimulator.sh
+27 −20
Original line number Diff line number Diff line
@@ -3,12 +3,13 @@ Kinetic C Client Library
========================
The [Github kinetic-c Git repository](https://github.com/Seagate/kinetic-c) contains code for producing Kinetic C clients for interacting with Kinetic storage object-based storage. The library uses the cross-platform Seagate Kinetic protocol for standardizing interaces between the Java simulator and Kinetic Device storage clusters.

[Code examples](https://github.com/Seagate/kinetic-c/tree/master/src/utility/examples) are included for reference as part of the [kinetic-c client library test utility (`kinetic-c-client-utility`)](https://github.com/Seagate/kinetic-c/tree/master/src/utility), which builds and links against the installed `kinetic-c-client` static library.
[Code examples](https://github.com/Seagate/kinetic-c/tree/master/src/utility/examples) are included for reference as part of the [kinetic-c client library test utility (`kinetic-c-util`)](https://github.com/Seagate/kinetic-c/tree/master/src/utility), which builds and links against the installed `kinetic-c-client` static library.

The [project Makefile](https://github.com/Seagate/kinetic-c/blob/master/Makefile) can be used as a reference for developing a Makefile-based project for building for a custom Kinetic Storage C client driver and/or a high-level C library.

Prerequisites
-------------

* [Open SSL](https://www.openssl.org/) for security and encryption
    * Installation (if you don't already have OpenSSL installed)
        * Linux (using apt-get)
@@ -18,31 +19,42 @@ Prerequisites

Getting Started
---------------

**Clone the repo**

    > git clone --recursive https://github.com/atomicobject/kinetic-c.git
    > cd kinetic-c
    > bundle install # ensure you have all RubyGems at the proper versions

**Update to the latest version (previously cloned)**

    > git pull
    > git submodule update --init # Ensure submodules are up to date
    > bundle install # Ensure you have all RubyGems at the proper versions
    > make clean

**Build and install static library**

    > make
    > sudo make install

**Clean and uninstall old versions**

    > make clean
    > sudo uninstall
    > sudo make uninstall

**Build example utility and run tests against Kinetic Device simulator**
    > make all # this is what Travis-CI build does to ensure it all keeps working

    > make all # this is what Travis-CI build does does for regression testing

API Documentation
=================
[Kinetic-C API Documentation](http://seagate.github.io/kinetic-c) (generated with Doxygen)
* [Kinetic-C API](http://seagate.github.io/kinetic-c/kinetic__client_8h.html)
* [Kinetic-C types](http://seagate.github.io/kinetic-c/kinetic__types_8h.html)

[Kinetic-C API Documentation](index.html) (generated with Doxygen)
* [Kinetic-C API](kinetic__client_8h.html)
* [Kinetic-C types](kinetic__types_8h.html)

Example Client/Test Utility
===========================

Code examples are included for reference as part of a test utility. The source code for the utility is used to build both a static and dynamically linked verion of the kinetic-c-client library.

* 'kinetic-c-util' builds/links against installed Kinetic C static library (.a)
@@ -50,25 +62,20 @@ Code examples are included for reference as part of a test utility. The source c

The project Makefile can be used as a reference for developing a Makefile for building for a new custom Kinetic C client.

In order to execute a given example, after building it, you must first do:

    > cd bin

You can then execute `kinetic-c-client-util` with a valid example name, optionally preceeded with any of the optional arguments.

Options
-------

* `--host [HostName/IP]` or `-h [HostName/IP]` - Set the Kinetic Device host
* `--tls` - Use the TLS port to execute the specified operation(s)

Operations
----------
* `kinetic-c-client [--host|-h hostname|123.253.253.23] noop put get`
    * `kinetic-c-client-util noop`

* `kinetic-c-util [--host|-h hostname|123.253.253.23] [noop] [put] [get] [delete]`
    * `./bin/kinetic-c-util noop`
        * Execute a NoOp (ping) operation to verify the Kinetic Device is ready
    * `kinetic-c-client-util put`
    * `./bin/kinetic-c-util put`
        * Execute a Put operation to store a key/value entry
    * `kinetic-c-client-util get`
    * `./bin/kinetic-c-util get`
        * Execute a Get operation to retrieve a key/value entry
    * `kinetic-c-client-util delete`
    * `./bin/kinetic-c-util delete`
        * Execute a Delete operation to destroy a key/value entry
+19 −16
Original line number Diff line number Diff line
@@ -3,16 +3,20 @@ require 'kinetic-ruby'
compiler = ENV.fetch('CC', 'gcc')
compiler_location = `which #{compiler}`.strip
compiler_info = `#{compiler} --version 2>&1`.strip
puts "" +
"Configuration:\n" +


task :report_toolchain do
  report_banner("Toolchain Configuration")
  report "" +
    "  compiler:\n" +
    "    location: #{compiler_location}\n" +
    "    info:\n" +
"      " + compiler_info.gsub(/\n/, "\n      ") + "\n\n"
    "      " + compiler_info.gsub(/\n/, "\n      ") + "\n"
end

KineticRuby::Rake::load_tasks
require 'ceedling'
Ceedling.load_project(config: './project.yml')
Ceedling.load_project(config: './config/project.yml')

def report(message='')
  $stderr.flush
@@ -60,12 +64,12 @@ task :proto => [PROTO_OUT] do

  report_banner "Building protobuf v2.5.0"
  cd PROTOBUF_CORE do
    execute_command "./configure --disable-shared; make; make check; make install"
    execute_command "./configure --disable-shared; make; make check; sudo make install"
  end

  report_banner "Building protobuf-c and installing protoc-c"
  cd PROTOBUF_C do
    execute_command "./autogen.sh && ./configure && make && make install"
    execute_command "./autogen.sh && ./configure && make && sudo make install"
    protoc_c = `which protoc-c`
    raise "Failed to find protoc-c utility" if protoc_c.strip.empty?
    versions = `protoc-c --version`
@@ -93,7 +97,7 @@ namespace :doxygen do
  DOCS_PATH = "./docs/"
  directory DOCS_PATH
  CLOBBER.include DOCS_PATH
  VERSION = File.read('VERSION').strip
  VERSION = File.read('./config/VERSION').strip

  task :checkout_github_pages => ['clobber', DOCS_PATH] do
    git "clone git@github.com:seagate/kinetic-c.git -b gh-pages #{DOCS_PATH}"
@@ -126,7 +130,6 @@ namespace :doxygen do
end

namespace :java_sim do

  JAVA_HOME = ENV.fetch('JAVA_HOME', '/usr')
  JAVA_BIN = File.join(JAVA_HOME, 'bin/java')
  $java_sim = nil
@@ -140,15 +143,15 @@ namespace :java_sim do
    java_sim_cleanup

    # Find the java simulator jar
    jars = Dir["vendor/kinetic-java/kinetic-simulator*.jar"]
    jars = Dir["vendor/kinetic-simulator/kinetic-simulator*.jar"]
    raise "No Kinetic Java simulator .jar files found!" if jars.empty?

    # Configure the classpath
    ENV['CLASSPATH'] = '' unless ENV['CLASSPATH']
    jars += [File.join(JAVA_HOME, 'lib/tools.jar')]
    jars.each {|jar| ENV['CLASSPATH'] += ':' + jar }
    $java_sim = spawn("#{JAVA_BIN} -classpath #{ENV['CLASSPATH']} com.seagate.kinetic.simulator.internal.SimulatorRunner")
    sleep 5 # wait for simulator to start up and server ready to receive connections
    $java_sim = spawn("#{JAVA_BIN} -classpath #{ENV['CLASSPATH']} com.seagate.kinetic.simulator.internal.SimulatorRunner") # &> ./build/kinetic-simulator.log") # &> ./build/kinetic-simulator-test.log")
    sleep 3 # wait for simulator to start up and server ready to receive connections
    # TODO: use netstat or something to just wait until the server opens the port
    #       since it might take longer than the hardcoded sleep(x) above :-/
  end
@@ -166,7 +169,7 @@ namespace :java_sim do

  def java_sim_erase_drive
    java_sim_start
    sh "#{JAVA_BIN} -classpath #{ENV['CLASSPATH']} com.seagate.kinetic.admin.cli.KineticAdminCLI -setup -erase true"
    sh "\"#{JAVA_BIN}\" -classpath \"#{ENV['CLASSPATH']}\" com.seagate.kinetic.admin.cli.KineticAdminCLI -instanterase" # &> ./build/kinetic-simulator-setup.log"
  end

  def java_sim_cleanup
@@ -368,7 +371,7 @@ namespace :tests do

end

task :test_all => ['tests:unit', 'tests:integration', 'tests:system']
task :test_all => ['report_toolchain', 'tests:unit', 'tests:integration', 'tests:system']

desc "Build all and run test utility"
task :all => ['test_all']
Loading