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

Added a second throughput test run with a slew of small objects. Removed...

Added a second throughput test run with a slew of small objects. Removed starting/stopping simulator from build runs, which must now be started manually before a test run. Removed old Ruby simulator, since it is not used in kinetic-c any longer
parent 4644561f
Loading
Loading
Loading
Loading
+1 −0
Original line number Diff line number Diff line
@@ -8,4 +8,5 @@ compiler:
install:
  - bundle install
script:
  - make start_simulator
  - make all
+0 −1
Original line number Diff line number Diff line
source "http://rubygems.org/"
gem 'bundler', '>= 1.3.5'
gem 'ceedling', '>= 0.15'
gem 'kinetic-ruby'
+1 −21
Original line number Diff line number Diff line
GEM
  remote: http://rubygems.org/
  specs:
    beefcake (0.5.0)
    ceedling (0.15.6)
    ceedling (0.16.0)
      rake (>= 0.8.7)
      thor (>= 0.14.5)
    diff-lcs (1.2.5)
    kinetic-ruby (0.6.3)
      beefcake
      rake (>= 0.9.2.2)
      rspec
    rake (10.3.2)
    rspec (3.0.0)
      rspec-core (~> 3.0.0)
      rspec-expectations (~> 3.0.0)
      rspec-mocks (~> 3.0.0)
    rspec-core (3.0.3)
      rspec-support (~> 3.0.0)
    rspec-expectations (3.0.3)
      diff-lcs (>= 1.2.0, < 2.0)
      rspec-support (~> 3.0.0)
    rspec-mocks (3.0.3)
      rspec-support (~> 3.0.0)
    rspec-support (3.0.3)
    rake (10.4.2)
    thor (0.19.1)

PLATFORMS
@@ -32,4 +13,3 @@ PLATFORMS
DEPENDENCIES
  bundler (>= 1.3.5)
  ceedling (>= 0.15)
  kinetic-ruby
+3 −61
Original line number Diff line number Diff line
@@ -139,7 +139,7 @@ $(OUT_DIR)/%.o: ${LIB_DIR}/bus/%.c ${LIB_DIR}/bus/%.h
${OUT_DIR}/*.o: src/lib/kinetic_types_internal.h


ci: uninstall all test_internals install
ci: uninstall all stop_simulator test_internals install
	@echo
	@echo --------------------------------------------------------------------------------
	@echo $(PROJECT) build completed successfully!
@@ -307,50 +307,7 @@ $(SYSTEST_OUT)/%.testpass : $(SYSTEST_OUT)/run_%

$(systest_names) : % : $(SYSTEST_OUT)/%.testpass

# system_tests: start_simulator $(systest_results)
system_tests: start_simulator $(systest_passfiles)


# run_systest_%: $(SYSTEST_OUT)/%
# 	@echo
# 	@echo ================================================================================
# 	@echo Executing system test: '$<'
# 	@echo --------------------------------------------------------------------------------;
# 	$<
# 	@echo ================================================================================
# 	@echo
# 	./vendor/kinetic-simulator/stopSimulator.sh
# run_systest_%: start_simulator

# valgrind_systest_%: $(SYSTEST_OUT)/%
# 	@echo
# 	@echo ================================================================================
# 	@echo Executing system test: '$<'
# 	@echo --------------------------------------------------------------------------------;
# 	${VALGRIND} ${VALGRIND_ARGS} $<
# 	@echo ================================================================================
# 	@echo

# setup_system_tests: $(systest_executables) \
# 	build_system_tests

# system_tests: setup_system_tests \
# 	start_simulator \
# 	run_example_write_file_blocking \
# 	run_example_write_file_blocking_threads \
# 	run_example_write_file_nonblocking \
# 	run_example_write_file_nonblocking_threads \
# 	stop_simulator

# valgrind_system_tests: setup_system_tests \
# 	start_simulator \
# 	valgrind_example_write_file_blocking \
# 	valgrind_example_write_file_blocking_threads \
# 	valgrind_example_write_file_nonblocking \
# 	valgrind_example_write_file_nonblocking_threads \
# 	stop_simulator


system_tests: $(systest_passfiles)


#===============================================================================
@@ -387,7 +344,7 @@ 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) start_simulator
run: $(UTIL_EXEC)
	@echo
	@echo --------------------------------------------------------------------------------
	@echo Running test utility: $(UTIL_EXEC)
@@ -425,17 +382,6 @@ $(BIN_DIR)/examples/%: $(EXAMPLE_SRC)/%.c $(KINETIC_LIB)

build_examples: $(example_executables)

test_example_%: $(BIN_DIR)/examples/%
	@echo
	@echo ================================================================================
	@echo Executing example: '$<'
	@echo --------------------------------------------------------------------------------;
	$<
	@echo ================================================================================
	@echo
	./vendor/kinetic-simulator/stopSimulator.sh
test_example_%: start_simulator

run_example_%: $(BIN_DIR)/examples/%
	@echo
	@echo ================================================================================
@@ -458,21 +404,17 @@ setup_examples: $(example_executables) \
	build_examples

examples: setup_examples \
	start_simulator \
	run_example_put_nonblocking \
	run_example_get_nonblocking \
	run_example_write_file_blocking \
	run_example_write_file_blocking_threads \
	run_example_write_file_nonblocking \
	run_example_get_key_range \
	stop_simulator

valgrind_examples: setup_examples \
	start_simulator \
	valgrind_put_nonblocking \
	valgrind_get_nonblocking \
	valgrind_example_write_file_blocking \
	valgrind_example_write_file_blocking_threads \
	valgrind_example_write_file_nonblocking \
	valgrind_example_get_key_range \
	stop_simulator
+2 −240
Original line number Diff line number Diff line
require 'kinetic-ruby'

compiler = ENV.fetch('CC', 'gcc')
compiler_location = `which #{compiler}`.strip
compiler_info = `#{compiler} --version 2>&1`.strip
@@ -15,7 +13,6 @@ task :report_toolchain do
    "      " + compiler_info.gsub(/\n/, "\n      ") + "\n"
end

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

@@ -130,142 +127,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

  def kinetic_device_listening?
    `netstat -an` =~ /[\.:]8123.+\s+LISTEN\s+/
  end

  def java_sim_start

    return if $java_sim

    report_banner "Starting Kinetic Java Simulator"

    java_sim_cleanup

    # Find the java 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")
    max_wait_secs = 20
    sleep_duration = 0.2
    timeout = false
    elapsed_secs = 0
    while !kinetic_device_listening? && !timeout do
      sleep(sleep_duration)
      elapsed_secs += sleep_duration
      timeout = (elapsed_secs > max_wait_secs)
    end
    raise "Kinetic Java simulator failed to start within #{max_wait_secs} seconds!" if timeout
  end

  def java_sim_shutdown
    if $java_sim
      report_banner "Shutting down Kinetic Java Simulator"
      Process.kill("INT", $java_sim)
      Process.wait($java_sim)
      $java_sim = nil
      sleep 0.5
      java_sim_cleanup
    end
  end

  def java_sim_erase_drive
    java_sim_start
    sh "\"#{JAVA_BIN}\" -classpath \"#{ENV['CLASSPATH']}\" com.seagate.kinetic.admin.cli.KineticAdminCLI -instanterase"
  end

  def java_sim_cleanup
    # Ensure stray simulators are not still running
    `ps -ef | grep kinetic-simulator`.each_line do |l|
      next if l =~ /grep kinetic-simulator/
      pid = l.match /^\s*\d+\s+(\d+)/
      if pid
        sh "kill -9 #{pid[1]}"
        report "Killed Java simulator with PID: #{pid[1]}"
      else
        report "Did not find any running Java Kinetic simulators"
      end
    end
  end

  task :start do
    java_sim_start
  end

  task :shutdown do
    java_sim_shutdown
  end

  desc "Erase Java simulator contents"
  task :erase do
    java_sim_erase_drive
  end

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)
    $kinetic_server.start
  end

  def shutdown_ruby_server
    $kinetic_server.shutdown unless $kinetic_server.nil?
    $kinetic_server = nil
  end

  task :start do
    start_ruby_server
  end

  task :shutdown do
    shutdown_ruby_server
  end
end

# Setup ruby and java simulators for integration and system tests
Dir['test/integration/test_*.c'].each do |test_file|
  task test_file => ['java_sim:shutdown', 'ruby_sim:start']
end
Dir['test/system/test_*.c'].each do |test_file|
  task test_file => ['ruby_sim:shutdown', 'java_sim:start']
end

namespace :system do
  desc "Run system tests w/KineticRuby for message inspection"
  task :test_sniff do
    [
      'java_sim:shutdown',
      'ruby_sim:start',
    ].each do |task|
      Rake::Task[task].reenable
      Rake::Task[task].invoke
    end

    Dir['test/system/test_*.c'].each do |test_task|
      p test_task
      Rake::Task[test_task].clear_prerequisites
      Rake::Task[test_task].invoke
    end

  end
end

desc "Prepend license to source files"
task :apply_license do
  Dir['include/**/*.h', 'src/**/*.h', 'src/**/*.c', 'test/**/*.h', 'test/**/*.c'].each do |f|
@@ -273,11 +134,6 @@ task :apply_license do
  end
end

desc "Enable verbose output"
task :verbose do
  Rake::Task[:verbosity].invoke(3) # Set verbosity to 3:semi-obnoxious for debugging
end

namespace :tests do

  desc "Run unit tests"
@@ -288,108 +144,14 @@ namespace :tests do
  end

  desc "Run integration tests"
  task :integration => ['ruby_sim:start'] do
  task :integration 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

  namespace :integration do
    task :noop do
      ####### ???
    end
  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')
    java_sim_shutdown
  end

  namespace :system do
    FileList['test/system/test_*.c'].each do |test|
      basename = File.basename(test, '.*')
      desc "Run system test #{basename}"
      task basename do
        shutdown_ruby_server
        java_sim_start
        Rake::Task[test].reenable
        Rake::Task[test].invoke
      end
    end
end

  desc "Run Kinetic Client Utility tests"
  task :utility => ['ruby_sim:shutdown'] do
    sh "make run"
  end

  namespace :utility do

    def with_test_server(banner)
      report_banner(banner)
      shutdown_ruby_server
      java_sim_start
      cd "./build/artifacts/release/" do
        yield if block_given?
      end
    end

    task :noop => ['ruby_sim:shutdown'] do
      with_test_server("Testing NoOp Operation") 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

    task :put => ['ruby_sim:shutdown'] do
      with_test_server("Testing Put operation") do
        execute_command "./kinetic-c put"
      end
    end

    task :get => ['ruby_sim:shutdown'] do
      with_test_server("Testing Get operation") do
        execute_command "./kinetic-c put"
        execute_command "./kinetic-c get"
        execute_command "./kinetic-c --host localhost get"
      end
    end

    task :delete => ['release', 'ruby_sim:shutdown'] do
      with_test_server("Testing Get operation") do
        execute_command "./kinetic-c put"
        execute_command "./kinetic-c get"
        execute_command "./kinetic-c delete"
      end
    end

  end

end

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

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

desc "Run full CI build"
task :ci => ['clobber', 'all']
task :test_all => ['report_toolchain', 'tests:unit', 'tests:integration']

task :default => ['test:delta']

END {
  # Ensure java simlator is shutdown prior to rake exiting
  java_sim_shutdown
  $stdout.flush
  $stderr.flush
}
Loading