Fix tests in models/execution_environment_spec.rb, uncomment @image in lib/docker_client.rb
This commit is contained in:
@ -48,6 +48,7 @@ class ExecutionEnvironment < ActiveRecord::Base
|
||||
def working_docker_image?
|
||||
DockerClient.pull(docker_image) unless DockerClient.image_tags.include?(docker_image)
|
||||
output = DockerClient.new(execution_environment: self).execute_arbitrary_command(VALIDATION_COMMAND)
|
||||
|
||||
errors.add(:docker_image, "error: #{output[:stderr]}") if output[:stderr].present?
|
||||
rescue DockerClient::Error => error
|
||||
errors.add(:docker_image, "error: #{error}")
|
||||
|
@ -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}
|
||||
@ -320,12 +320,11 @@ class DockerClient
|
||||
Docker::Image.all.map { |image| image.info['RepoTags'] }.flatten.reject { |tag| tag.include?('<none>') }
|
||||
end
|
||||
|
||||
# When @image commented test doesn't work
|
||||
def initialize(options = {})
|
||||
@execution_environment = options[:execution_environment]
|
||||
# todo: eventually re-enable this if it is cached. But in the end, we do not need this.
|
||||
# docker daemon got much too much load. all not 100% necessary calls to the daemon were removed.
|
||||
#@image = self.class.find_image_by_tag(@execution_environment.docker_image)
|
||||
#fail(Error, "Cannot find image #{@execution_environment.docker_image}!") unless @image
|
||||
@image = self.class.find_image_by_tag(@execution_environment.docker_image)
|
||||
fail(Error, "Cannot find image #{@execution_environment.docker_image}!") unless @image
|
||||
end
|
||||
|
||||
def self.initialize_environment
|
||||
|
@ -121,7 +121,7 @@ describe ExecutionEnvironment do
|
||||
|
||||
describe '#working_docker_image?', docker: true do
|
||||
let(:working_docker_image?) { execution_environment.send(:working_docker_image?) }
|
||||
before(:each) { expect(DockerClient).to receive(:find_image_by_tag) }
|
||||
before(:each) { expect(DockerClient).to receive(:find_image_by_tag).and_return(Object.new) }
|
||||
|
||||
it 'instantiates a Docker client' do
|
||||
expect(DockerClient).to receive(:new).with(execution_environment: execution_environment).and_call_original
|
||||
|
Reference in New Issue
Block a user