Skip to content

Commit

Permalink
test(stapel): importing of symlink file and directory
Browse files Browse the repository at this point in the history
Signed-off-by: Alexey Igrychev <alexey.igrychev@flant.com>
  • Loading branch information
alexey-igrychev committed Jul 21, 2022
1 parent 835260f commit b6fcf63
Show file tree
Hide file tree
Showing 6 changed files with 104 additions and 2 deletions.
2 changes: 0 additions & 2 deletions go.sum
Expand Up @@ -2053,8 +2053,6 @@ github.com/werf/copy-recurse v0.2.4 h1:kEyGUKhgS8WdEOjInNQKgk4lqPWzP2AgR27F3dcGs
github.com/werf/copy-recurse v0.2.4/go.mod h1:KVHSQ90p19xflWW0B7BJhLBwmSbEtuxIaBnjlUYRPhk=
github.com/werf/helm v0.0.0-20210202111118-81e74d46da0f h1:81YscYTF9mmTf0ULOsCmm42YWQp+qWDzWi1HjWniZrg=
github.com/werf/helm v0.0.0-20210202111118-81e74d46da0f/go.mod h1:OMONwLWU9zEENgaVjWEX+M+xik2QakejzKHG1+6mnUo=
github.com/werf/kubedog v0.9.1 h1:TLXttYA2Doiu0ehPqV0nPNc+LkLnC7SpgX6Nhq4zGAw=
github.com/werf/kubedog v0.9.1/go.mod h1:MIvQv19uLxcZMwATRE4sOtfUy36o99oBqmlXPk30U+A=
github.com/werf/kubedog v0.9.3 h1:+m7SIuLuYvvo1RW1Ap9N5vWZkUKkBS5TscTo8I2p/2k=
github.com/werf/kubedog v0.9.3/go.mod h1:MIvQv19uLxcZMwATRE4sOtfUy36o99oBqmlXPk30U+A=
github.com/werf/lockgate v0.0.0-20200729113342-ec2c142f71ea h1:R5tJUhL5a3YfHTrHWyuAdJW3h//fmONrpHJjjAZ79e4=
Expand Down
@@ -0,0 +1,18 @@
project: none
configVersion: 1
---
artifact: artifact
from: ubuntu:18.04
shell:
setup:
- mkdir -p /app
- echo VERSION_1 > /app/file
- ln -s /app /link_dir
---
image: app
from: alpine
import:
- artifact: artifact
add: /link_dir
to: /dir
after: install
@@ -0,0 +1,18 @@
project: none
configVersion: 1
---
artifact: artifact
from: ubuntu:18.04
shell:
setup:
- mkdir -p /app
- echo VERSION_2 > /app/file
- ln -s /app /link_dir
---
image: app
from: alpine
import:
- artifact: artifact
add: /link_dir
to: /dir
after: install
@@ -0,0 +1,18 @@
project: none
configVersion: 1
---
artifact: artifact
from: ubuntu:18.04
shell:
setup:
- mkdir -p /app
- echo VERSION_1 > /app/file
- ln -s /app/file /link_file
---
image: app
from: alpine
import:
- artifact: artifact
add: /link_file
to: /file
before: install
@@ -0,0 +1,18 @@
project: none
configVersion: 1
---
artifact: artifact
from: ubuntu:18.04
shell:
setup:
- mkdir -p /app
- echo VERSION_2 > /app/file
- ln -s /app/file /link_file
---
image: app
from: alpine
import:
- artifact: artifact
add: /link_file
to: /file
before: install
32 changes: 32 additions & 0 deletions integration/suites/build/stapel_image/imports/imports_test.go
Expand Up @@ -106,6 +106,38 @@ var _ = Describe("Stapel imports", func() {
}
}
})

It("should import artifacts from directory to which the symlink points", func() {
for stepInd := 1; stepInd <= 2; stepInd++ {
stepID := fmt.Sprintf("00%d", stepInd)
stepDir := utils.FixturePath("imports_app_3", stepID)
SuiteData.CommitProjectWorktree(SuiteData.ProjectName, stepDir, stepID)

Expect(werfBuild(SuiteData.GetProjectWorktree(SuiteData.ProjectName), liveexec.ExecCommandOptions{})).To(Succeed())

expectedStepFileContent := fmt.Sprintf("VERSION_%d\n", stepInd)
destFilePath := "/dir/file"
Expect(werfRunOutput(SuiteData.GetProjectWorktree(SuiteData.ProjectName), "cat", destFilePath)).To(ContainSubstring(expectedStepFileContent))
}
})

It("should import symlink file", func() {
By("Check the symlink is added")
var lastStageImageNameAfterFirstBuild string
{
SuiteData.CommitProjectWorktree(SuiteData.ProjectName, utils.FixturePath("imports_app_4", "001"), "001")
Expect(werfBuild(SuiteData.GetProjectWorktree(SuiteData.ProjectName), liveexec.ExecCommandOptions{})).To(Succeed())
Expect(werfRunOutput(SuiteData.GetProjectWorktree(SuiteData.ProjectName), "readlink", "/file")).To(ContainSubstring("/app/file"))
lastStageImageNameAfterFirstBuild = utils.GetBuiltImageLastStageImageName(SuiteData.GetProjectWorktree(SuiteData.ProjectName), SuiteData.WerfBinPath, "app")
}

By("Check nothing happens when the file to which the symlink points is changed")
{
Expect(werfBuild(SuiteData.GetProjectWorktree(SuiteData.ProjectName), liveexec.ExecCommandOptions{})).To(Succeed())
lastStageImageNameAfterSecondBuild := utils.GetBuiltImageLastStageImageName(SuiteData.GetProjectWorktree(SuiteData.ProjectName), SuiteData.WerfBinPath, "app")
Expect(lastStageImageNameAfterFirstBuild).To(BeEquivalentTo(lastStageImageNameAfterSecondBuild))
}
})
})

Context("caching by import source checksum", func() {
Expand Down

0 comments on commit b6fcf63

Please sign in to comment.