Skip to content
This repository has been archived by the owner on Mar 24, 2022. It is now read-only.

Commit

Permalink
add test for task caches
Browse files Browse the repository at this point in the history
concourse/concourse#230

Signed-off-by: Chris Hendrix <chendrix@pivotal.io>
  • Loading branch information
mariash authored and Chris Hendrix committed Jun 23, 2017
1 parent b0acfdb commit a10b551
Show file tree
Hide file tree
Showing 2 changed files with 116 additions and 0 deletions.
43 changes: 43 additions & 0 deletions pipelines/fixtures/task-caches.yml
@@ -0,0 +1,43 @@
---
resources:
- name: some-git-resource
type: git
source:
uri: {{origin-git-server}}
branch: master

jobs:
- name: simple
plan:
- get: some-git-resource
- task: first-task
config:
inputs:
- name: some-git-resource
outputs:
- name: first-task-output
image_resource:
type: docker-image
source:
repository: busybox
platform: linux
run:
path: sh
args:
- some-git-resource/first-script.sh
- task: second-task
config:
inputs:
- name: some-git-resource
- name: first-task-output
caches:
- path: first-task-output/blobs
image_resource:
type: docker-image
source:
repository: busybox
platform: linux
run:
path: sh
args:
- some-git-resource/second-script.sh
73 changes: 73 additions & 0 deletions pipelines/task_caches_test.go
@@ -0,0 +1,73 @@
package pipelines_test

import (
"github.com/concourse/testflight/gitserver"
. "github.com/onsi/ginkgo"
. "github.com/onsi/gomega"
"github.com/onsi/gomega/gbytes"
)

var _ = Describe("task caching", func() {
var (
originGitServer *gitserver.Server
)

BeforeEach(func() {
originGitServer = gitserver.Start(client)
})

AfterEach(func() {
originGitServer.Stop()
})

It("caches directories in the cache list without caching any non-cached directories", func() {
flyHelper.ConfigurePipeline(
pipelineName,
"-c", "fixtures/task-caches.yml",
"-v", "origin-git-server="+originGitServer.URI(),
)

// If we were to just use config in the pipeline, we would see the
// echoing of the things we are looking for when it says "running ..."
// So to prevent this we commit it to a resource and so then it just says
// e.g. "running sh some-git-resource/first-script.sh"
// and leaves the output of the fly buffer with just the contents that are
// cat'ed out

firstScript := `echo not-cached-from-first-task >> first-task-output/not-cached-from-first-task
mkdir first-task-output/blobs
echo blob-contents-from-first-task >> first-task-output/blobs/blob`
originGitServer.CommitFileToBranch(firstScript, "first-script.sh", "master")

secondScript := `cat ./first-task-output/not-cached-from-first-task
echo not-cached-from-second-task >> first-task-output/not-cached-from-second-task
cat ./first-task-output/not-cached-from-second-task
echo blob-contents-from-second-task >> ./first-task-output/blobs/blob
cat ./first-task-output/blobs/blob`
originGitServer.CommitFileToBranch(secondScript, "second-script.sh", "master")

watch := flyHelper.TriggerJob(pipelineName, "simple")
<-watch.Exited
Expect(watch).To(gbytes.Say("not-cached-from-first-task"))
Expect(watch).To(gbytes.Say("not-cached-from-second-task"))
Expect(watch).To(gbytes.Say("blob-contents-from-second-task"))

Expect(watch).NotTo(gbytes.Say("blob-contents-from-first-task"))
Expect(watch).NotTo(gbytes.Say(`not-cached-from-first-task\s+not-cached-from-first-task`))
Expect(watch).NotTo(gbytes.Say(`not-cached-from-second-task\s+not-cached-from-second-task`))
Expect(watch).NotTo(gbytes.Say(`blob-contents-from-second-task\s+blob-contents-from-second-task`))

watch = flyHelper.TriggerJob(pipelineName, "simple")
<-watch.Exited
Expect(watch).To(gbytes.Say("not-cached-from-first-task"))
Expect(watch).To(gbytes.Say("not-cached-from-second-task"))
Expect(watch).To(gbytes.Say(`blob-contents-from-second-task\s+blob-contents-from-second-task`))

Expect(watch).NotTo(gbytes.Say("blob-contents-from-first-task"))
Expect(watch).NotTo(gbytes.Say(`not-cached-from-first-task\s+not-cached-from-first-task`))
Expect(watch).NotTo(gbytes.Say(`not-cached-from-second-task\s+not-cached-from-second-task`))
})
})

0 comments on commit a10b551

Please sign in to comment.