Skip to content

Commit

Permalink
Updating some tests to not require the docker socket ⚽️
Browse files Browse the repository at this point in the history
We should try to avoid, as much as possible, to assume that there will
be a docker socket available on the node. If the runtime used by
Kubernetes is not Docker, this fails.

This affects : TestPipelineRun and private-taskrun and
taskrun-docker-basic examples.

Signed-off-by: Vincent Demeester <vdemeest@redhat.com>
  • Loading branch information
vdemeester committed Apr 5, 2019
1 parent 2f384e6 commit bcc3904
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 30 deletions.
13 changes: 3 additions & 10 deletions examples/taskruns/private-taskrun.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -46,15 +46,8 @@ spec:
steps:
- name: pull
# Private image is just Ubuntu
image: gcr.io/cloud-builders/docker
args: ["pull", "gcr.io/build-crd-testing/secret-sauce"]
volumeMounts:
- name: docker-socket
mountPath: /var/run/docker.sock
volumes:
- name: docker-socket
hostPath:
path: /var/run/docker.sock
type: Socket
image: quay.io/rhpipeline/skopeo:alpine
command: ["skopeo"]
args: ["copy", "docker://gcr.io/build-crd-testing/secret-sauce", "dir:///tmp/secret-sauce"]
trigger:
type: manual
13 changes: 3 additions & 10 deletions examples/taskruns/taskrun-docker-basic.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -38,14 +38,7 @@ spec:
taskSpec:
steps:
- name: test
image: gcr.io/cloud-builders/docker
image: quay.io/rhpipeline/skopeo:alpine
# Test pulling a private builder container.
args: ["pull", "gcr.io/build-crd-testing/secret-sauce"]
volumeMounts:
- name: docker-socket
mountPath: /var/run/docker.sock
volumes:
- name: docker-socket
hostPath:
path: /var/run/docker.sock
type: Socket
command: ["skopeo"]
args: ["copy", "docker://gcr.io/build-crd-testing/secret-sauce", "dir:///tmp/secret-sauce"]
13 changes: 3 additions & 10 deletions test/pipelinerun_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -93,17 +93,10 @@ func TestPipelineRun(t *testing.T) {

task := tb.Task(getName(taskName, index), namespace, tb.TaskSpec(
// Reference build: https://github.com/knative/build/tree/master/test/docker-basic
tb.Step("config-docker", "gcr.io/cloud-builders/docker",
tb.Command("docker"),
tb.Args("pull", "gcr.io/build-crd-testing/secret-sauce"),
tb.VolumeMount("docker-socket", "/var/run/docker.sock"),
tb.Step("config-docker", "quay.io/rhpipeline/skopeo:alpine",
tb.Command("skopeo"),
tb.Args("copy", "docker://gcr.io/build-crd-testing/secret-sauce", "dir:///tmp/secret-sauce/"),
),
tb.TaskVolume("docker-socket", tb.VolumeSource(corev1.VolumeSource{
HostPath: &corev1.HostPathVolumeSource{
Path: "/var/run/docker.sock",
Type: newHostPathType(string(corev1.HostPathSocket)),
},
})),
))
if _, err := c.TaskClient.Create(task); err != nil {
t.Fatalf("Failed to create Task `%s`: %s", getName(taskName, index), err)
Expand Down

0 comments on commit bcc3904

Please sign in to comment.