This repository has been archived by the owner on Mar 24, 2022. It is now read-only.
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
concourse/concourse#230 Signed-off-by: Chris Hendrix <chendrix@pivotal.io>
- Loading branch information
Showing
2 changed files
with
116 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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`)) | ||
}) | ||
}) |