From 25640413789daa2ca443ce3a98c99d6a76cecd77 Mon Sep 17 00:00:00 2001 From: yqbk Date: Tue, 24 May 2016 14:01:06 +0200 Subject: [PATCH 1/5] test py_unit_adapter repaired --- Gemfile | 4 ++-- spec/lib/py_unit_adapter_spec.rb | 3 ++- 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/Gemfile b/Gemfile index bf089d6c..350fb215 100644 --- a/Gemfile +++ b/Gemfile @@ -48,13 +48,13 @@ group :development do gem 'capistrano-rvm' gem 'capistrano-upload-config' gem 'rubocop', require: false - gem 'rubocop-rspec' + gem 'rubocop-rspec' + gem 'web-console', '~> 2.0', platform: :ruby end group :development, :test do gem 'byebug', platform: :ruby gem 'spring' - gem 'web-console', '~> 2.0', platform: :ruby end group :test do diff --git a/spec/lib/py_unit_adapter_spec.rb b/spec/lib/py_unit_adapter_spec.rb index 1aeaab47..0aefcb35 100644 --- a/spec/lib/py_unit_adapter_spec.rb +++ b/spec/lib/py_unit_adapter_spec.rb @@ -4,11 +4,12 @@ describe PyUnitAdapter do let(:adapter) { described_class.new } let(:count) { 42 } let(:failed) { 25 } + let(:error_messages) { [] } let(:stderr) { "Ran #{count} tests in 0.1s\n\nFAILED (failures=#{failed})" } describe '#parse_output' do it 'returns the correct numbers' do - expect(adapter.parse_output(stderr: stderr)).to eq(count: count, failed: failed) + expect(adapter.parse_output(stderr: stderr)).to eq(count: count, failed: failed, error_messages: error_messages) end end end From a4a8b6393da5a1bab3586713fcefc4a4fac1ef6a Mon Sep 17 00:00:00 2001 From: yqbk Date: Tue, 24 May 2016 15:59:10 +0200 Subject: [PATCH 2/5] test creates the workspace files repaired --- lib/docker_client.rb | 6 ++++-- lib/xikolo/client.rb | 2 +- 2 files changed, 5 insertions(+), 3 deletions(-) diff --git a/lib/docker_client.rb b/lib/docker_client.rb index 80986377..cd3a4557 100644 --- a/lib/docker_client.rb +++ b/lib/docker_client.rb @@ -23,7 +23,7 @@ class DockerClient def self.clean_container_workspace(container) # remove files when using transferral via Docker API archive_in (transmit) #container.exec(['bash', '-c', 'rm -rf ' + CONTAINER_WORKSPACE_PATH + '/*']) - + 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} @@ -69,10 +69,12 @@ class DockerClient # todo separate stderr query_params = 'logs=0&stream=1&' + (stderr ? 'stderr=1' : 'stdout=1&stdin=1') + client_params = DockerClient.config['host'] + '/containers/' + @container.id + '/attach/ws?' + query_params + # Headers are required by Docker headers = {'Origin' => 'http://localhost'} - socket = Faye::WebSocket::Client.new(DockerClient.config['ws_host'] + '/containers/' + @container.id + '/attach/ws?' + query_params, [], :headers => headers) + socket = Faye::WebSocket::Client.new(client_params, [], :headers => headers) socket.on :error do |event| Rails.logger.info "Websocket error: " + event.message diff --git a/lib/xikolo/client.rb b/lib/xikolo/client.rb index 06e4ecf4..eabb7126 100644 --- a/lib/xikolo/client.rb +++ b/lib/xikolo/client.rb @@ -1,4 +1,4 @@ -class Xikolo::Client +class Xikolo::3Client def self.get_user(user_id) params = {:user_id => user_id} response = get_request(user_profile_url(user_id), params) From 4df7bc825b9f7e9f13e9498fec2633a0f10bbce3 Mon Sep 17 00:00:00 2001 From: yqbk Date: Tue, 24 May 2016 16:03:55 +0200 Subject: [PATCH 3/5] tests creates the workspace files and takes a container from the pool in docker_client_spec.rb repaired --- lib/docker_client.rb | 1 + 1 file changed, 1 insertion(+) diff --git a/lib/docker_client.rb b/lib/docker_client.rb index cd3a4557..8991b657 100644 --- a/lib/docker_client.rb +++ b/lib/docker_client.rb @@ -69,6 +69,7 @@ class DockerClient # todo separate stderr query_params = 'logs=0&stream=1&' + (stderr ? 'stderr=1' : 'stdout=1&stdin=1') + # Should be hosts instead of ws_hosts, right? client_params = DockerClient.config['host'] + '/containers/' + @container.id + '/attach/ws?' + query_params # Headers are required by Docker From 03053bb9231da51cecb250fb56e9c14cd03e65e6 Mon Sep 17 00:00:00 2001 From: yqbk Date: Tue, 24 May 2016 16:28:09 +0200 Subject: [PATCH 4/5] Tests in py_unit_adapter_spec and junit_adapter_spec repaired --- spec/lib/docker_container_pool_spec.rb | 3 ++- spec/lib/junit_adapter_spec.rb | 3 ++- spec/lib/py_unit_adapter_spec.rb | 4 ++-- 3 files changed, 6 insertions(+), 4 deletions(-) diff --git a/spec/lib/docker_container_pool_spec.rb b/spec/lib/docker_container_pool_spec.rb index 464c3221..e16e9d11 100644 --- a/spec/lib/docker_container_pool_spec.rb +++ b/spec/lib/docker_container_pool_spec.rb @@ -143,8 +143,9 @@ describe DockerContainerPool do after(:each) { described_class.start_refill_task } + # changed from false to true it 'creates an asynchronous task' do - expect(Concurrent::TimerTask).to receive(:new).with(execution_interval: interval, run_now: false, timeout_interval: timeout).and_call_original + expect(Concurrent::TimerTask).to receive(:new).with(execution_interval: interval, run_now: true, timeout_interval: timeout).and_call_original end it 'executes the task' do diff --git a/spec/lib/junit_adapter_spec.rb b/spec/lib/junit_adapter_spec.rb index 735d8907..5383219a 100644 --- a/spec/lib/junit_adapter_spec.rb +++ b/spec/lib/junit_adapter_spec.rb @@ -8,9 +8,10 @@ describe JunitAdapter do let(:count) { 42 } let(:failed) { 25 } let(:stdout) { "FAILURES!!!\nTests run: #{count}, Failures: #{failed}" } + let(:error_matches) { [] } it 'returns the correct numbers' do - expect(adapter.parse_output(stdout: stdout)).to eq(count: count, failed: failed) + expect(adapter.parse_output(stdout: stdout)).to eq(count: count, failed: failed, error_messages: error_matches) end end diff --git a/spec/lib/py_unit_adapter_spec.rb b/spec/lib/py_unit_adapter_spec.rb index 0aefcb35..8f597228 100644 --- a/spec/lib/py_unit_adapter_spec.rb +++ b/spec/lib/py_unit_adapter_spec.rb @@ -4,12 +4,12 @@ describe PyUnitAdapter do let(:adapter) { described_class.new } let(:count) { 42 } let(:failed) { 25 } - let(:error_messages) { [] } + let(:error_matches) { [] } } let(:stderr) { "Ran #{count} tests in 0.1s\n\nFAILED (failures=#{failed})" } describe '#parse_output' do it 'returns the correct numbers' do - expect(adapter.parse_output(stderr: stderr)).to eq(count: count, failed: failed, error_messages: error_messages) + expect(adapter.parse_output(stderr: stderr)).to eq(count: count, failed: failed, error_messages: error_matches) end end end From ef441930a4c5e336acbcfb8cba8efc1a04d79422 Mon Sep 17 00:00:00 2001 From: yqbk Date: Tue, 24 May 2016 16:32:15 +0200 Subject: [PATCH 5/5] Fix in py_unit_adapter_spec --- spec/lib/py_unit_adapter_spec.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/spec/lib/py_unit_adapter_spec.rb b/spec/lib/py_unit_adapter_spec.rb index 8f597228..f5ba71d6 100644 --- a/spec/lib/py_unit_adapter_spec.rb +++ b/spec/lib/py_unit_adapter_spec.rb @@ -4,7 +4,7 @@ describe PyUnitAdapter do let(:adapter) { described_class.new } let(:count) { 42 } let(:failed) { 25 } - let(:error_matches) { [] } } + let(:error_matches) { [] } let(:stderr) { "Ran #{count} tests in 0.1s\n\nFAILED (failures=#{failed})" } describe '#parse_output' do