Skip to content

Commit

Permalink
tests: add windows self hosted runner, add win tests in pipeline
Browse files Browse the repository at this point in the history
Signed-off-by: Luca Di Maio <luca.dimaio1@gmail.com>
  • Loading branch information
89luca89 committed Dec 4, 2023
1 parent 0059954 commit 6236b6e
Show file tree
Hide file tree
Showing 7 changed files with 398 additions and 239 deletions.
45 changes: 43 additions & 2 deletions .github/workflows/e2e-tests.yaml
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
name: E2E tests

on:
release:
types: [prereleased]
pull_request:
branches:
- main
Expand All @@ -20,15 +22,14 @@ env:
GO111MODULE: on
GOFLAGS: -mod=vendor

# windows blocklist: "up-podman", "integration", "machineprovider", "up"
jobs:
test-e2e:
runs-on: ubuntu-latest
strategy:
fail-fast: true
max-parallel: 16
matrix:
label: ["build", "ide", "integration", "machine", "machineprovider", "provider", "proxyprovider", "ssh", "up", "up-docker", "up-podman", "up-docker-compose"]
label: ["build", "ide", "integration", "machine", "machineprovider", "provider", "proxyprovider", "ssh", "up", "up-docker", "up-podman", "up-docker-compose", "up-docker-build", "up-docker-compose-build"]

steps:
- name: Checkout repo
Expand Down Expand Up @@ -63,3 +64,43 @@ jobs:
working-directory: ./e2e
run: |
sudo KUBECONFIG=/home/runner/.kube/config go test -v -ginkgo.v -timeout 3600s --ginkgo.label-filter=${{ matrix.label }}
test-e2e-windows:
runs-on: self-hosted-windows
# We run this only on PRs, for pre-releases we run the full separate workflow
if: ${{ github.event_name == 'pull_request' }}
strategy:
fail-fast: true
max-parallel: 1
matrix:
label: ["build", "ide", "ssh", "up-docker", "up-docker-build", "up-docker-compose" ]

steps:
- name: Git set line ending
run: |
git config --global core.autocrlf false
- name: Checkout repo
uses: actions/checkout@v2

- name: Set up Go
uses: actions/setup-go@v2
with:
go-version: 1.20.5

- name: Build binary and copy to the E2E directory
run: |
go build -ldflags "-s -w" -o devpod-windows-amd64.exe
mkdir e2e\bin
cp devpod-windows-amd64.exe e2e\bin\
- name: E2E test
working-directory: .\e2e
run: |
go run github.com/onsi/ginkgo/v2/ginkgo -r -p --timeout=3600s --label-filter=${{ matrix.label }}
- name: Container cleanup
if: ${{ always() }}
run: |
Remove-Item -Recurse C:\Users\loft-user\.devpod\
sh -c "docker ps -a | cut -d' ' -f1 | tail -n+2 | xargs docker rm -f || :"
53 changes: 53 additions & 0 deletions .github/workflows/e2e-win-fill-tests.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
name: E2E Win full tests

on:
release:
types: [prereleased]

concurrency:
group: ${{ github.workflow }}-${{ github.event.pull_request.number || github.ref }}
cancel-in-progress: true

env:
GO111MODULE: on
GOFLAGS: -mod=vendor

jobs:
test-e2e-windows:
runs-on: self-hosted-windows
strategy:
fail-fast: true
max-parallel: 1
matrix:
# windows blocklist: "up-podman", "integration", "machineprovider", "proxyprovider", "up"
label: ["build", "ide", "machine", "provider", "ssh", "up-docker", "up-docker-compose", "up-docker-build", "up-docker-compose-build"]

steps:
- name: Git set line ending
run: |
git config --global core.autocrlf false
- name: Checkout repo
uses: actions/checkout@v2

- name: Set up Go
uses: actions/setup-go@v2
with:
go-version: 1.20.5

- name: Build binary and copy to the E2E directory
run: |
go build -ldflags "-s -w" -o devpod-windows-amd64.exe
mkdir e2e\bin
cp devpod-windows-amd64.exe e2e\bin\
- name: E2E test
working-directory: .\e2e
run: |
go run github.com/onsi/ginkgo/v2/ginkgo -r -p --timeout=3600s --label-filter=${{ matrix.label }}
- name: Container cleanup
if: ${{ always() }}
run: |
Remove-Item -Recurse C:\Users\loft-user\.devpod\
sh -c "docker ps -a | cut -d' ' -f1 | tail -n+2 | xargs docker rm -f || :"
2 changes: 1 addition & 1 deletion e2e/framework/util.go
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ import (

func GetTimeout() time.Duration {
if runtime.GOOS == "windows" {
return 300 * time.Second
return 600 * time.Second
}

return 60 * time.Second
Expand Down
123 changes: 0 additions & 123 deletions e2e/tests/up/docker.go
Original file line number Diff line number Diff line change
Expand Up @@ -141,23 +141,6 @@ var _ = DevPodDescribe("devpod up test suite", func() {
gomega.Expect(bar).To(gomega.Equal("FOO"))
}, ginkgo.SpecTimeout(framework.GetTimeout()))

ginkgo.It("should start a new workspace with multistage build", func(ctx context.Context) {
tempDir, err := framework.CopyToTempDir("tests/up/testdata/docker-with-multi-stage-build")
framework.ExpectNoError(err)
ginkgo.DeferCleanup(framework.CleanupTempDir, initialDir, tempDir)

f := framework.NewDefaultFramework(initialDir + "/bin")
_ = f.DevPodProviderAdd(ctx, "docker")
err = f.DevPodProviderUse(ctx, "docker")
framework.ExpectNoError(err)

ginkgo.DeferCleanup(f.DevPodWorkspaceDelete, context.Background(), tempDir)

// Wait for devpod workspace to come online (deadline: 30s)
err = f.DevPodUp(ctx, tempDir, "--debug")
framework.ExpectNoError(err)
}, ginkgo.SpecTimeout(framework.GetTimeout()*3))

ginkgo.Context("should start a new workspace with features", func() {
ginkgo.It("ensure dependencies installed via features are accessible in lifecycle hooks", func(ctx context.Context) {
tempDir, err := framework.CopyToTempDir("tests/up/testdata/docker-features-lifecycle-hooks")
Expand Down Expand Up @@ -288,112 +271,6 @@ var _ = DevPodDescribe("devpod up test suite", func() {
framework.ExpectNotEqual(out, unexpectedOutput, "should NOT match")
}, ginkgo.SpecTimeout(framework.GetTimeout()))

ginkgo.Context("should start a workspace from a Dockerfile build", func() {
ginkgo.It("should rebuild image in case of changes in files in build context", func(ctx context.Context) {
tempDir, err := framework.CopyToTempDir("tests/up/testdata/docker-dockerfile-buildcontext")
framework.ExpectNoError(err)
ginkgo.DeferCleanup(framework.CleanupTempDir, initialDir, tempDir)

f := framework.NewDefaultFramework(initialDir + "/bin")

_ = f.DevPodProviderDelete(ctx, "docker")
err = f.DevPodProviderAdd(ctx, "docker")
framework.ExpectNoError(err)
err = f.DevPodProviderUse(context.Background(), "docker")
framework.ExpectNoError(err)

ginkgo.DeferCleanup(f.DevPodWorkspaceDelete, context.Background(), tempDir)

// Wait for devpod workspace to come online (deadline: 30s)
err = f.DevPodUp(ctx, tempDir)
framework.ExpectNoError(err)

workspace, err := f.FindWorkspace(ctx, tempDir)
framework.ExpectNoError(err)

container, err := dockerHelper.FindDevContainer(ctx, []string{
fmt.Sprintf("%s=%s", config.DockerIDLabel, workspace.UID),
})
framework.ExpectNoError(err)

image1 := container.Config.LegacyImage

scriptFile, err := os.OpenFile(tempDir+"/scripts/alias.sh",
os.O_APPEND|os.O_CREATE|os.O_WRONLY, 0600)
framework.ExpectNoError(err)

defer scriptFile.Close()

ginkgo.By("Changing a file within the context")
_, err = scriptFile.Write([]byte("alias yr='date +%Y'"))
framework.ExpectNoError(err)

ginkgo.By("Starting DevPod again with --recreate")
err = f.DevPodUp(ctx, tempDir, "--debug", "--recreate")
framework.ExpectNoError(err)

container, err = dockerHelper.FindDevContainer(ctx, []string{
fmt.Sprintf("%s=%s", config.DockerIDLabel, workspace.UID),
})
framework.ExpectNoError(err)

image2 := container.Config.LegacyImage

gomega.Expect(image2).ShouldNot(gomega.Equal(image1), "images should be different")
}, ginkgo.SpecTimeout(framework.GetTimeout()))
ginkgo.It("should not rebuild image for changes in files mentioned in .dockerignore", func(ctx context.Context) {
tempDir, err := framework.CopyToTempDir("tests/up/testdata/docker-dockerfile-buildcontext")
framework.ExpectNoError(err)
ginkgo.DeferCleanup(framework.CleanupTempDir, initialDir, tempDir)

f := framework.NewDefaultFramework(initialDir + "/bin")

_ = f.DevPodProviderDelete(ctx, "docker")
err = f.DevPodProviderAdd(ctx, "docker")
framework.ExpectNoError(err)
err = f.DevPodProviderUse(context.Background(), "docker")
framework.ExpectNoError(err)

ginkgo.DeferCleanup(f.DevPodWorkspaceDelete, context.Background(), tempDir)

// Wait for devpod workspace to come online (deadline: 30s)
err = f.DevPodUp(ctx, tempDir)
framework.ExpectNoError(err)

workspace, err := f.FindWorkspace(ctx, tempDir)
framework.ExpectNoError(err)

container, err := dockerHelper.FindDevContainer(ctx, []string{
fmt.Sprintf("%s=%s", config.DockerIDLabel, workspace.UID),
})
framework.ExpectNoError(err)

image1 := container.Config.LegacyImage

scriptFile, err := os.OpenFile(tempDir+"/scripts/install.sh",
os.O_APPEND|os.O_CREATE|os.O_WRONLY, 0600)
framework.ExpectNoError(err)

defer scriptFile.Close()

ginkgo.By("Changing a file within context")
_, err = scriptFile.Write([]byte("apt install python"))
framework.ExpectNoError(err)

ginkgo.By("Starting DevPod again with --recreate")
err = f.DevPodUp(ctx, tempDir, "--debug", "--recreate")
framework.ExpectNoError(err)

container, err = dockerHelper.FindDevContainer(ctx, []string{
fmt.Sprintf("%s=%s", config.DockerIDLabel, workspace.UID),
})
framework.ExpectNoError(err)

image2 := container.Config.LegacyImage

gomega.Expect(image2).Should(gomega.Equal(image1), "image should be same")
}, ginkgo.SpecTimeout(framework.GetTimeout()))
})
ginkgo.It("should use http headers to download feature", func(ctx context.Context) {
server := ghttp.NewServer()

Expand Down
Loading

0 comments on commit 6236b6e

Please sign in to comment.