Skip to content

Commit

Permalink
Remove the ID generator from AutoHCK
Browse files Browse the repository at this point in the history
AutoHCK is a CI runner, not a manager, and should not
control resources between different runs.

Add command line argument to have the ability to specify
an ID that is received from external tools.

Signed-off-by: Kostiantyn Kostiuk <[email protected]>
  • Loading branch information
kostyanf14 committed Nov 2, 2023
1 parent f34d3a0 commit 9c19180
Show file tree
Hide file tree
Showing 5 changed files with 11 additions and 116 deletions.
1 change: 0 additions & 1 deletion Gemfile
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,6 @@ gem 'openssl', require: false
gem 'rtoolsHCK', git: 'https://github.com/HCK-CI/rtoolsHCK.git', tag: 'v0.4.0'
gem 'rubyzip'
gem 'sentry-ruby'
gem 'sqlite3'

group :test do
gem 'code-scanning-rubocop'
Expand Down
4 changes: 0 additions & 4 deletions Gemfile.lock
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,6 @@ GEM
logging (2.3.1)
little-plugger (~> 1.1)
multi_json (~> 1.14)
mini_portile2 (2.8.4)
minitest (5.20.0)
mono_logger (1.1.2)
multi_json (1.15.0)
Expand Down Expand Up @@ -133,8 +132,6 @@ GEM
sentry-ruby-core (4.7.1)
concurrent-ruby
faraday
sqlite3 (1.6.6)
mini_portile2 (~> 2.8.0)
stringio (3.0.8)
tzinfo (2.0.6)
concurrent-ruby (~> 1.0)
Expand Down Expand Up @@ -172,7 +169,6 @@ DEPENDENCIES
rubocop
rubyzip
sentry-ruby
sqlite3

RUBY VERSION
ruby 3.1.4p223
Expand Down
90 changes: 0 additions & 90 deletions lib/auxiliary/id_gen.rb

This file was deleted.

11 changes: 10 additions & 1 deletion lib/cli.rb
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ def initialize

# class CommonOptions
class CommonOptions
attr_accessor :debug, :config, :client_world_net
attr_accessor :debug, :config, :client_world_net, :id

def create_parser(sub_parser)
OptionParser.new do |parser|
Expand All @@ -46,9 +46,11 @@ def define_options(parser)
@debug = false
@config = nil
@client_world_net = false
@id = 2
debug_option(parser)
config_option(parser)
client_world_net_option(parser)
id_option(parser)
version_option(parser)
end

Expand All @@ -73,6 +75,13 @@ def client_world_net_option(parser)
end
end

def id_option(parser)
parser.on('--id <id>', Integer,
'Set ID for AutoHCK run') do |id|
@id = id
end
end

def version_option(parser)
parser.on('-v', '--version',
'Display version information and exit') do
Expand Down
21 changes: 1 addition & 20 deletions lib/project.rb
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@
require './lib/auxiliary/multi_logger'
require './lib/auxiliary/diff_checker'
require './lib/auxiliary/json_helper'
require './lib/auxiliary/id_gen'
require './lib/auxiliary/extra_software/manager'

# AutoHCK module
Expand All @@ -32,7 +31,7 @@ def initialize(scope, options)
init_multilog(options.common.debug)
init_class_variables
init_workspace
@id = assign_id
@id = options.common.id
scope << self
end

Expand Down Expand Up @@ -117,23 +116,6 @@ def init_class_variables
@engine_type = @config["#{@options.mode}_engine"]
end

def assign_id
@id_gen = Idgen.new(@scope, @config['id_range'], @config['time_out'])
id = @id_gen.allocate
while id.negative?
@logger.info('No available ID')
sleep 20
id = @id_gen.allocate
end
@logger.info("Assigned ID: #{id}")
id.to_s
end

def release_id
@logger.info("Releasing ID: #{@id}")
@id_gen.release(@id)
end

def configure_result_uploader
@logger.info('Initializing result uploaders')
@result_uploader = ResultUploader.new(@scope, self)
Expand Down Expand Up @@ -188,7 +170,6 @@ def handle_error
def close
@logger.debug('Closing AutoHCK project')
@result_uploader&.upload_file(@logfile_path, 'AutoHCK.log')
release_id
end
end
end

0 comments on commit 9c19180

Please sign in to comment.