<commit_before>require 'serverspec'

set :backend, :exec
puts "os: #{os}"

docker_version_string = `docker -v`
docker_version = docker_version_string.split(/\s/)[2].split(',')[0]

volumes_filter = '{{ .Volumes }}' if docker_version =~ /1.6/
volumes_filter = '{{ .Volumes }}' if docker_version =~ /1.7/
volumes_filter = '{{ .Config.Volumes }}' if docker_version =~ /1.8/

##############################################
#  test/cookbooks/docker_test/recipes/image.rb
##############################################

# test/cookbooks/docker_test/recipes/image.rb

# docker_image[hello-world]

describe command('docker images') do
  its(:exit_status) { should eq 0 }
  its(:stdout) { should match(/^hello-world\s.*latest/) }
end

# docker_image[Tom's container]

describe command('docker images') do
  its(:exit_status) { should eq 0 }
  its(:stdout) { should match(%r{^tduffield\/testcontainerd\s.*latest}) }
end

# docker_image[busybox]

describe command('docker images') do
  its(:exit_status) { should eq 0 }
  its(:stdout) { should match(/^busybox\s.*latest/) }
end

# docker_image[alpine]

describe command('docker images') do
  its(:exit_status) { should eq 0 }
  its(:stdout) { should match(/^alpine\s.*3.1/) }
end

# docker_image[vbatts/slackware]

describe command('docker images') do
  its(:exit_status) { should eq 0 }
  its(:stdout) { should_not match(/^slackware\s.*latest/) }
end

# docker_image[save hello-world]

describe file('/hello-world.tar') do
  it { should be_file }
  it { should be_mode 644 }
end

# docker_image[image-1]

describe command('docker images') do
  its(:exit_status) { should eq 0 }
  its(:stdout) { should_not match(/^image-1\s.*v1.0.1/) }
end

# docker_image[image.2]

describe command('docker images') do
  its(:exit_status) { should eq 0 }
  its(:stdout) { should_not match(/^image.2\s.*v1.0.1/) }
end

# docker_image[image_3]

describe command('docker images') do
  its(:exit_status) { should eq 0 }
  its(:stdout) { should_not match(/^image_3\s.*v1.0.1/) }
end

# docker_image[name-w-dashes]

describe command('docker images') do
  its(:exit_status) { should eq 0 }
  its(:stdout) { should match(/^localhost\:5043\/someara\/name-w-dashes\s.*latest/) }
end

# docker_tag[private repo tag for name.w.dots:latest]

describe command('docker images') do
  its(:exit_status) { should eq 0 }
  its(:stdout) { should match(%r{^localhost\:5043\/someara\/name\.w\.dots\s.*latest}) }
end

# FIXME: We need to test the "docker_registry" stuff...
# I can't figure out how to search the local registry to see if the
# authentication and :push actions in the test recipe actually worked.
#
# Skipping for now.

##################################################
#  test/cookbooks/docker_test/recipes/container.rb
##################################################

# docker_container[hello-world]

describe command("docker ps -af 'name=hello-world'") do
  its(:exit_status) { should eq 0 }
end

# docker_container[busybox_ls]

describe command("[ ! -z `docker ps -qaf 'name=busybox_ls$'` ]") do
  its(:exit_status) { should eq 0 }
end

# docker_container[alpine_ls]

describe command("[ ! -z `docker ps -qaf 'name=alpine_ls$'` ]") do
  its(:exit_status) { should eq 0 }
end

# docker_container[an_echo_server]

describe command("[ ! -z `docker ps -qaf 'name=an_echo_server$'` ]") do
  its(:exit_status) { should eq 0 }
end

# docker_container[another_echo_server]

describe command("[ ! -z `docker ps -qaf 'name=another_echo_server$'` ]") do
  its(:exit_status) { should eq 0 }
end

# docker_container[an_udp_echo_server]

describe command("[ ! -z `docker ps -qaf 'name=an_udp_echo_server$'` ]") do
  its(:exit_status) { should eq 0 }
end

# docker_container[bill]

describe command("[ ! -z `docker ps -qaf 'name=bil$'` ]") do
  its(:exit_status) { should eq 1 }
end

# docker_container[hammer_time]

describe command("[ ! -z `docker ps -qaf 'name=hammer_time$'` ]") do
  its(:exit_status) { should eq 0 }
end

describe command("docker ps -af 'name=hammer_time$'") do
  its(:exit_status) { should eq 0 }
  its(:stdout) { should match(/Exited \(137\)/) }
end

# docker_container[red_light]

describe command("[ ! -z `docker ps -qaf 'name=red_light$'` ]") do
  its(:exit_status) { should eq 0 }
end

describe command("docker ps -af 'name=red_light$'") do
  its(:exit_status) { should eq 0 }
  its(:stdout) { should match(/Paused/) }
end

# docker_container[green_light]

describe command("[ ! -z `docker ps -qaf 'name=green_light$'` ]") do
  its(:exit_status) { should eq 0 }
end

describe command("docker ps -af 'name=green_light$'") do
  its(:exit_status) { should eq 0 }
  its(:stdout) { should_not match(/Paused/) }
end

# docker_container[quitter]

describe command("[ ! -z `docker ps -qaf 'name=quitter$'` ]") do
  its(:exit_status) { should eq 0 }
end

describe command("docker ps -af 'name=quitter$'") do
  its(:exit_status) { should eq 0 }
  its(:stdout) { should_not match(/Exited/) }
end

# docker_container[restarter]

describe command("[ ! -z `docker ps -qaf 'name=restarter$'` ]") do
  its(:exit_status) { should eq 0 }
end

describe command("docker ps -af 'name=restarter$'") do
  its(:exit_status) { should eq 0 }
  its(:stdout) { should_not match(/Exited/) }
end

# docker_container[deleteme]

describe command("[ ! -z `docker ps -qaf 'name=deleteme$'` ]") do
  its(:exit_status) { should eq 1 }
end

# docker_container[redeployer]

describe command("docker ps -af 'name=redeployer$'") do
  its(:exit_status) { should eq 0 }
  its(:stdout) { should_not match(/Exited/) }
end

# docker_container[bind_mounter]

describe command("docker ps -af 'name=bind_mounter$'") do
  its(:exit_status) { should eq 0 }
  its(:stdout) { should match(/Exited/) }
end

describe command("docker inspect -f \"{{ .HostConfig.Binds }}\" bind_mounter") do
  its(:exit_status) { should eq 0 }
  its(:stdout) { should match(%r{\[\/hostbits\:\/bits \/more-hostbits\:\/more-bits\]}) }
end

# docker_container[chef_container]

describe command("docker ps -af 'name=chef_container$'") do
  its(:exit_status) { should eq 0 }
  its(:stdout) { should_not match(/Exited/) }
  its(:stdout) { should_not match(/Up/) }
end

describe command("docker inspect -f \"#{ volumes_filter }\" chef_container") do
  its(:exit_status) { should eq 0 }
  its(:stdout) { should match(%r{\/opt\/chef\:}) }
end

# docker_container[ohai_debian]

describe command("docker ps -af 'name=ohai_debian$'") do
  its(:exit_status) { should eq 0 }
  its(:stdout) { should match(/Exited/) }
end

describe command("docker inspect -f \"#{ volumes_filter }\" ohai_debian") do
  its(:exit_status) { should eq 0 }
  its(:stdout) { should match(%r{\/opt\/chef\:}) }
end

# docker_container[env]<commit_msg>updating volume checking serverspec for 1.8.1<commit_after>require 'serverspec'

set :backend, :exec
puts "os: #{os}"

docker_version_string = `docker -v`
docker_version = docker_version_string.split(/\s/)[2].split(',')[0]

volumes_filter = '{{ .Volumes }}' if docker_version =~ /1.6/
volumes_filter = '{{ .Volumes }}' if docker_version =~ /1.7/
volumes_filter = '{{ .Config.Volumes }}' if docker_version =~ /1.8/

mounts_filter = '{{ .Volumes }}' if docker_version =~ /1.6/
mounts_filter = '{{ .Volumes }}' if docker_version =~ /1.7/
mounts_filter = '{{ .Mounts }}' if docker_version =~ /1.8/

##############################################
#  test/cookbooks/docker_test/recipes/image.rb
##############################################

# test/cookbooks/docker_test/recipes/image.rb

# docker_image[hello-world]

describe command('docker images') do
  its(:exit_status) { should eq 0 }
  its(:stdout) { should match(/^hello-world\s.*latest/) }
end

# docker_image[Tom's container]

describe command('docker images') do
  its(:exit_status) { should eq 0 }
  its(:stdout) { should match(%r{^tduffield\/testcontainerd\s.*latest}) }
end

# docker_image[busybox]

describe command('docker images') do
  its(:exit_status) { should eq 0 }
  its(:stdout) { should match(/^busybox\s.*latest/) }
end

# docker_image[alpine]

describe command('docker images') do
  its(:exit_status) { should eq 0 }
  its(:stdout) { should match(/^alpine\s.*3.1/) }
end

# docker_image[vbatts/slackware]

describe command('docker images') do
  its(:exit_status) { should eq 0 }
  its(:stdout) { should_not match(/^slackware\s.*latest/) }
end

# docker_image[save hello-world]

describe file('/hello-world.tar') do
  it { should be_file }
  it { should be_mode 644 }
end

# docker_image[image-1]

describe command('docker images') do
  its(:exit_status) { should eq 0 }
  its(:stdout) { should_not match(/^image-1\s.*v1.0.1/) }
end

# docker_image[image.2]

describe command('docker images') do
  its(:exit_status) { should eq 0 }
  its(:stdout) { should_not match(/^image.2\s.*v1.0.1/) }
end

# docker_image[image_3]

describe command('docker images') do
  its(:exit_status) { should eq 0 }
  its(:stdout) { should_not match(/^image_3\s.*v1.0.1/) }
end

# docker_image[name-w-dashes]

describe command('docker images') do
  its(:exit_status) { should eq 0 }
  its(:stdout) { should match(/^localhost\:5043\/someara\/name-w-dashes\s.*latest/) }
end

# docker_tag[private repo tag for name.w.dots:latest]

describe command('docker images') do
  its(:exit_status) { should eq 0 }
  its(:stdout) { should match(%r{^localhost\:5043\/someara\/name\.w\.dots\s.*latest}) }
end

# FIXME: We need to test the "docker_registry" stuff...
# I can't figure out how to search the local registry to see if the
# authentication and :push actions in the test recipe actually worked.
#
# Skipping for now.

##################################################
#  test/cookbooks/docker_test/recipes/container.rb
##################################################

# docker_container[hello-world]

describe command("docker ps -af 'name=hello-world'") do
  its(:exit_status) { should eq 0 }
end

# docker_container[busybox_ls]

describe command("[ ! -z `docker ps -qaf 'name=busybox_ls$'` ]") do
  its(:exit_status) { should eq 0 }
end

# docker_container[alpine_ls]

describe command("[ ! -z `docker ps -qaf 'name=alpine_ls$'` ]") do
  its(:exit_status) { should eq 0 }
end

# docker_container[an_echo_server]

describe command("[ ! -z `docker ps -qaf 'name=an_echo_server$'` ]") do
  its(:exit_status) { should eq 0 }
end

# docker_container[another_echo_server]

describe command("[ ! -z `docker ps -qaf 'name=another_echo_server$'` ]") do
  its(:exit_status) { should eq 0 }
end

# docker_container[an_udp_echo_server]

describe command("[ ! -z `docker ps -qaf 'name=an_udp_echo_server$'` ]") do
  its(:exit_status) { should eq 0 }
end

# docker_container[bill]

describe command("[ ! -z `docker ps -qaf 'name=bil$'` ]") do
  its(:exit_status) { should eq 1 }
end

# docker_container[hammer_time]

describe command("[ ! -z `docker ps -qaf 'name=hammer_time$'` ]") do
  its(:exit_status) { should eq 0 }
end

describe command("docker ps -af 'name=hammer_time$'") do
  its(:exit_status) { should eq 0 }
  its(:stdout) { should match(/Exited \(137\)/) }
end

# docker_container[red_light]

describe command("[ ! -z `docker ps -qaf 'name=red_light$'` ]") do
  its(:exit_status) { should eq 0 }
end

describe command("docker ps -af 'name=red_light$'") do
  its(:exit_status) { should eq 0 }
  its(:stdout) { should match(/Paused/) }
end

# docker_container[green_light]

describe command("[ ! -z `docker ps -qaf 'name=green_light$'` ]") do
  its(:exit_status) { should eq 0 }
end

describe command("docker ps -af 'name=green_light$'") do
  its(:exit_status) { should eq 0 }
  its(:stdout) { should_not match(/Paused/) }
end

# docker_container[quitter]

describe command("[ ! -z `docker ps -qaf 'name=quitter$'` ]") do
  its(:exit_status) { should eq 0 }
end

describe command("docker ps -af 'name=quitter$'") do
  its(:exit_status) { should eq 0 }
  its(:stdout) { should_not match(/Exited/) }
end

# docker_container[restarter]

describe command("[ ! -z `docker ps -qaf 'name=restarter$'` ]") do
  its(:exit_status) { should eq 0 }
end

describe command("docker ps -af 'name=restarter$'") do
  its(:exit_status) { should eq 0 }
  its(:stdout) { should_not match(/Exited/) }
end

# docker_container[deleteme]

describe command("[ ! -z `docker ps -qaf 'name=deleteme$'` ]") do
  its(:exit_status) { should eq 1 }
end

# docker_container[redeployer]

describe command("docker ps -af 'name=redeployer$'") do
  its(:exit_status) { should eq 0 }
  its(:stdout) { should_not match(/Exited/) }
end

# docker_container[bind_mounter]

describe command("docker ps -af 'name=bind_mounter$'") do
  its(:exit_status) { should eq 0 }
  its(:stdout) { should match(/Exited/) }
end

describe command("docker inspect -f \"{{ .HostConfig.Binds }}\" bind_mounter") do
  its(:exit_status) { should eq 0 }
  its(:stdout) { should match(%r{\[\/hostbits\:\/bits \/more-hostbits\:\/more-bits\]}) }
end

# docker_container[chef_container]

describe command("docker ps -af 'name=chef_container$'") do
  its(:exit_status) { should eq 0 }
  its(:stdout) { should_not match(/Exited/) }
  its(:stdout) { should_not match(/Up/) }
end

describe command("docker inspect -f \"#{ volumes_filter }\" chef_container") do
  its(:exit_status) { should eq 0 }
  its(:stdout) { should match(%r{\/opt\/chef\:}) }
end

# docker_container[ohai_debian]

describe command("docker ps -af 'name=ohai_debian$'") do
  its(:exit_status) { should eq 0 }
  its(:stdout) { should match(/Exited/) }
end

describe command("docker inspect -f \"#{ mounts_filter }\" ohai_debian") do
  its(:exit_status) { should eq 0 }
  its(:stdout) { should match(%r{\/opt\/chef}) }
end

# docker_container[env]
{'fraction_non_alphanumeric': 0.18720047187200473, 'fraction_numerical': 0.011575610115756101, 'mean_word_length': 4.630552096305521, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '7659831', 'n_tokens_mistral': 5113, 'n_tokens_neox': 4777, 'n_words': 1169}