From b8e35274ace279d6817505dde959ff9bda5c1e2c Mon Sep 17 00:00:00 2001 From: Jan Renz Date: Tue, 28 Apr 2015 13:46:56 +0200 Subject: [PATCH] Added some roadmap --- lib/assessor.rb | 2 +- lib/docker_client.rb | 10 ++++++---- lib/docker_container_pool.rb | 2 +- spec/lib/docker_client_spec.rb | 1 + 4 files changed, 9 insertions(+), 6 deletions(-) diff --git a/lib/assessor.rb b/lib/assessor.rb index ac0f5d42..1d395dc7 100644 --- a/lib/assessor.rb +++ b/lib/assessor.rb @@ -5,7 +5,7 @@ class Assessor test_outcome = @testing_framework_adapter.test_outcome(output) test_outcome.merge(score: calculate_score(test_outcome)) rescue - {score: 0.0} + {score: 0} end def calculate_score(test_outcome) diff --git a/lib/docker_client.rb b/lib/docker_client.rb index 7c9c3891..d2b7f328 100644 --- a/lib/docker_client.rb +++ b/lib/docker_client.rb @@ -83,7 +83,10 @@ class DockerClient Rails.logger.info('destroying container ' + container.to_s) container.stop.kill container.port_bindings.values.each { |port| PortPool.release(port) } - Pathname.new(local_workspace_path).children.each{ |p| p.rmtree} if local_workspace_path(container) + local_workspace_path = local_workspace_path(container) + if local_workspace_path && Pathname.new(local_workspace_path).exist? + Pathname.new(local_workspace_path).children.each{ |p| p.rmtree} + end container.delete(force: true) end @@ -94,9 +97,9 @@ class DockerClient def execute_command(command, before_execution_block, output_consuming_block) #tries ||= 0 @container = DockerContainerPool.get_container(@execution_environment) - #clear directory (it should be emtpy anyhow) - Pathname.new(local_workspace_path).children.each{ |p| p.rmtree} if @container + #clear directory (it should be emtpy anyhow) + Pathname.new(self.class.local_workspace_path(@container)).children.each{ |p| p.rmtree} before_execution_block.try(:call) send_command(command, @container, &output_consuming_block) else @@ -202,6 +205,5 @@ class DockerClient end private :send_command - class Error < RuntimeError; end end diff --git a/lib/docker_container_pool.rb b/lib/docker_container_pool.rb index ced2f319..133f2955 100644 --- a/lib/docker_container_pool.rb +++ b/lib/docker_container_pool.rb @@ -42,7 +42,7 @@ class DockerContainerPool def self.return_container(container, execution_environment) container.status = 'available' - unless(@containers[execution_environment.id].include?(container)) + if(@containers[execution_environment.id] && !@containers[execution_environment.id].include?(container)) @containers[execution_environment.id].push(container) else Rails.logger.info('trying to return existing container ' + container.to_s) diff --git a/spec/lib/docker_client_spec.rb b/spec/lib/docker_client_spec.rb index c87ef0eb..71d0adf1 100644 --- a/spec/lib/docker_client_spec.rb +++ b/spec/lib/docker_client_spec.rb @@ -112,6 +112,7 @@ describe DockerClient, docker: true do end it 'raises the error' do + pending('RETRY COUNT is disabled') expect { create_container }.to raise_error(error) end end