<commit_before>#!/usr/bin/env bats

load helpers

function teardown() {
	swarm_manage_cleanup
	stop_docker
}

@test "shared volumes dependency" {
	# FIXME: docker inspect --format is broken in docker master. See #717
	skip

	start_docker 2
	swarm_manage

	# Running the second container with shared volumes.
	run docker_swarm run --name b1 -e constraint:node==node-0 -d busybox:latest sleep 500
	[ "$status" -eq 0 ]
	run docker_swarm run --name b2 --volumes-from=/b1 -d busybox:latest sh
	[ "$status" -eq 0 ]

	# check if containers share volume.
	run docker_swarm inspect -f "{{ .HostConfig.VolumesFrom }}" b2
	[ "$status" -eq 0 ]
	[[ "${output}" == *"[/b1]"* ]]

	# check if both containers are started on the same node
	run docker_swarm inspect -f "{{ .Node.Name }}" b1
	[ "$status" -eq 0 ]
	[[ "${output}" == *"node-0"* ]]

	run docker_swarm inspect -f "{{ .Node.Name }}" b2
	[ "$status" -eq 0 ]
	[[ "${output}" == *"node-0"* ]]
}

@test "links dependency" {
	# FIXME: docker inspect --format is broken in docker master. See #717
	skip

	start_docker 2
	swarm_manage

	# Running the second container with link dependency.
	run docker_swarm run --name b1 -e constraint:node==node-1 -d busybox:latest sleep 500
	[ "$status" -eq 0 ]
	run docker_swarm run --name b2 --link=/b1:foo -d busybox:latest sh
	[ "$status" -eq 0 ]

	# check if containers share link.
	run docker_swarm inspect -f "{{ .HostConfig.Links }}" b2
	[ "$status" -eq 0 ]
	[[ "${output}" == *"[/b1:/b2/foo]"* ]]
	
	# check if both containers are started on the same node
	run docker_swarm inspect -f "{{ .Node.Name }}" b1
	[ "$status" -eq 0 ]
	[[ "${output}" == *"node-1"* ]]

	run docker_swarm inspect -f "{{ .Node.Name }}" b2
	[ "$status" -eq 0 ]
	[[ "${output}" == *"node-1"* ]]
}

@test "shared network stack dependency" {
	# FIXME: docker inspect --format is broken in docker master. See #717
	skip

	start_docker 2
	swarm_manage

	# Running the second container with network stack dependency.
	run docker_swarm run --name b1 -e constraint:node==node-0 -d busybox:latest sleep 500
	[ "$status" -eq 0 ]
	run docker_swarm run --name b2 --net=container:/b1 -d busybox:latest sh
	[ "$status" -eq 0 ]

	# check if containers have shared network stack.
	run docker_swarm inspect -f "{{ .HostConfig.NetworkMode }}" b2
	[ "$status" -eq 0 ]
	[[ "${output}" == *"container:/b1"* ]]

	# check if both containers are started on the same node
	run docker_swarm inspect -f "{{ .Node.Name }}" b1
	[ "$status" -eq 0 ]
	[[ "${output}" == *"node-0"* ]]

	run docker_swarm inspect -f "{{ .Node.Name }}" b2
	[ "$status" -eq 0 ]
	[[ "${output}" == *"node-0"* ]]	
}<commit_msg>do not use -f in tests<commit_after>#!/usr/bin/env bats

load helpers

function teardown() {
	swarm_manage_cleanup
	stop_docker
}

@test "shared volumes dependency" {
	start_docker 2
	swarm_manage

	# Running the second container with shared volumes.
	run docker_swarm run --name b1 -e constraint:node==node-0 -d busybox:latest sleep 500
	[ "$status" -eq 0 ]
	run docker_swarm run --name b2 --volumes-from=/b1 -d busybox:latest sh
	[ "$status" -eq 0 ]

	# check if containers share volume.
	run docker_swarm inspect -f "{{ .HostConfig.VolumesFrom }}" b2
	[ "$status" -eq 0 ]
	[[ "${output}" == *"[/b1]"* ]]

	# check if both containers are started on the same node
	run docker_swarm inspect b1
	[ "$status" -eq 0 ]
	[[ "${output}" == *'"Name": "node-0"'* ]]

	run docker_swarm inspect b2
	[ "$status" -eq 0 ]
	[[ "${output}" == *'"Name": "node-0"'* ]]
}

@test "links dependency" {
	start_docker 2
	swarm_manage

	# Running the second container with link dependency.
	run docker_swarm run --name b1 -e constraint:node==node-1 -d busybox:latest sleep 500
	[ "$status" -eq 0 ]
	run docker_swarm run --name b2 --link=/b1:foo -d busybox:latest sh
	[ "$status" -eq 0 ]

	# check if containers share link.
	run docker_swarm inspect -f "{{ .HostConfig.Links }}" b2
	[ "$status" -eq 0 ]
	[[ "${output}" == *"[/b1:/b2/foo]"* ]]
	
	# check if both containers are started on the same node
	run docker_swarm inspect b1
	[ "$status" -eq 0 ]
	[[ "${output}" == *'"Name": "node-1"'* ]]

	run docker_swarm inspect b2
	[ "$status" -eq 0 ]
	[[ "${output}" == *'"Name": "node-1"'* ]]
}

@test "shared network stack dependency" {
	start_docker 2
	swarm_manage

	# Running the second container with network stack dependency.
	run docker_swarm run --name b1 -e constraint:node==node-0 -d busybox:latest sleep 500
	[ "$status" -eq 0 ]
	run docker_swarm run --name b2 --net=container:/b1 -d busybox:latest sh
	[ "$status" -eq 0 ]

	# check if containers have shared network stack.
	run docker_swarm inspect -f "{{ .HostConfig.NetworkMode }}" b2
	[ "$status" -eq 0 ]
	[[ "${output}" == *"container:/b1"* ]]

	# check if both containers are started on the same node
	run docker_swarm inspect b1
	[ "$status" -eq 0 ]
	[[ "${output}" == *'"Name": "node-0"'* ]]

	run docker_swarm inspect b2
	[ "$status" -eq 0 ]
	[[ "${output}" == *'"Name": "node-0"'* ]]
}
{'fraction_non_alphanumeric': 0.1681469519580137, 'fraction_numerical': 0.025232135647961243, 'mean_word_length': 3.500454132606721, 'pattern_counts': {'":': 6, '<': 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': '5810091', 'n_tokens_mistral': 1920, 'n_tokens_neox': 1758, 'n_words': 585}