Skip to content

Instantly share code, notes, and snippets.

@ncdc
Created August 22, 2013 17:57
Show Gist options
  • Save ncdc/6310607 to your computer and use it in GitHub Desktop.
Save ncdc/6310607 to your computer and use it in GitHub Desktop.
begin
::OpenShift::Runtime::Utils::Cgroups.new(@uuid).boost do
logger.info "Executing initial gear prereceive for #{@uuid}"
Utils.oo_spawn("gear prereceive >> #{build_log} 2>&1",
env: env,
chdir: @container_dir,
uid: @uid,
timeout: @hourglass.remaining,
expected_exitstatus: 0)
logger.info "Executing initial gear postreceive for #{@uuid}"
Utils.oo_spawn("gear postreceive >> #{build_log} 2>&1",
env: env,
chdir: @container_dir,
uid: @uid,
timeout: @hourglass.remaining,
expected_exitstatus: 0)
end
rescue ::OpenShift::Runtime::Utils::ShellExecutionException => e
max_bytes = 10 * 1024
out, _, _ = Utils.oo_spawn("tail -c #{max_bytes} #{build_log} 2>&1",
env: env,
chdir: @container_dir,
uid: @uid,
timeout: @hourglass.remaining)
message = "The initial build for the application failed: #{e.message}\n\n.Last #{max_bytes/1024} kB of build output:\n#{out}"
raise ::OpenShift::Runtime::Utils::Sdk.translate_out_for_client(message, :error)
end
def test_post_configure_empty_clone_spec_prevents_build
cart_name = 'mock-0.1'
cartridge = mock()
@cartridge_model.expects(:get_cartridge).with(cart_name).returns(cartridge)
cartridge.expects(:install_build_required).returns(true)
cartridge.expects(:buildable?).returns(true)
@cartridge_model.expects(:post_configure).with(cart_name)
gear_env = {a: 1, b: 2}
OpenShift::Runtime::Utils::Environ.expects(:for_gear).with(@container.container_dir).returns(gear_env)
cgroups = mock()
OpenShift::Runtime::Utils::Cgroups.expects(:new).returns(cgroups)
cgroups.expects(:boost)
@hourglass.expects(:remaining).returns(100)
OpenShift::Runtime::Utils.expects(:oo_spawn).with("gear prereceive >> '/tmp/initial-build.log' 2>&1",
env: gear_env,
chdir: @container.container_dir,
uid: @container.uid,
timeout: 100,
expected_exitstatus: 0)
@hourglass.expects(:remaining).returns(50)
OpenShift::Runtime::Utils.expects(:oo_spawn).with("gear postreceive >> '/tmp/initial-build.log' 2>&1",
env: gear_env,
chdir: @container_dir,
uid: @uid,
timeout: 50,
expected_exitstatus: 0)
@container.post_configure(cart_name)
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment