Add strategy for DockerContainerPool
In order to provide an alternative to Poseidon, a strategy for the DockerContainerPool is added that is used by the runner model. Co-authored-by: Sebastian Serth <Sebastian.Serth@hpi.de>
This commit is contained in:

committed by
Sebastian Serth

parent
1d3f0d7ad8
commit
704407b9fc
@ -2,14 +2,14 @@
|
||||
|
||||
require 'rails_helper'
|
||||
|
||||
describe Runner::Strategy::Docker do
|
||||
describe Runner::Strategy::DockerContainerPool do
|
||||
let(:runner_id) { FactoryBot.attributes_for(:runner)[:runner_id] }
|
||||
let(:execution_environment) { FactoryBot.create :ruby }
|
||||
let(:docker) { described_class.new(runner_id, execution_environment) }
|
||||
let(:container_pool) { described_class.new(runner_id, execution_environment) }
|
||||
|
||||
# TODO: add tests for these methods when implemented
|
||||
it 'defines all methods all runner management strategies must define' do
|
||||
expect(docker.public_methods).to include(*Runner::DELEGATED_STRATEGY_METHODS)
|
||||
expect(container_pool.public_methods).to include(:destroy_at_management, :copy_files, :attach_to_execution)
|
||||
expect(described_class.public_methods).to include(:request_from_management)
|
||||
end
|
||||
end
|
@ -256,15 +256,15 @@ describe Runner::Strategy::Poseidon do
|
||||
end
|
||||
|
||||
describe '#copy_files' do
|
||||
let(:filename) { 'main.py' }
|
||||
let(:file_content) { 'print("Hello World!")' }
|
||||
let(:action) { -> { poseidon.copy_files({filename => file_content}) } }
|
||||
let(:encoded_file_content) { Base64.strict_encode64(file_content) }
|
||||
let(:file) { FactoryBot.build(:file, content: file_content) }
|
||||
let(:action) { -> { poseidon.copy_files([file]) } }
|
||||
let(:encoded_file_content) { Base64.strict_encode64(file.content) }
|
||||
let!(:copy_files_stub) do
|
||||
WebMock
|
||||
.stub_request(:patch, "#{Runner::BASE_URL}/runners/#{runner_id}/files")
|
||||
.with(
|
||||
body: {copy: [{path: filename, content: encoded_file_content}]},
|
||||
body: {copy: [{path: file.filepath, content: encoded_file_content}]},
|
||||
headers: {'Content-Type' => 'application/json'}
|
||||
)
|
||||
.to_return(body: response_body, status: response_status)
|
||||
|
Reference in New Issue
Block a user