浏览代码

Fix problems with ddev e2e test and minor cleanup, add tmate (#27)

* Add tmate for debugging
* Use -parallel=1 for standaone tests

Signed-off-by: Randy Fay <[email protected]>
Randy Fay 3 年之前
父节点
当前提交
9d07ce415f
共有 3 个文件被更改,包括 32 次插入4 次删除
  1. 14 0
      .github/workflows/ci.yml
  2. 1 1
      Makefile
  3. 17 3
      pkg/e2e/ddev_test.go

+ 14 - 0
.github/workflows/ci.yml

@@ -5,6 +5,12 @@ on:
     branches:
       - v2
   pull_request:
+  workflow_dispatch:
+    inputs:
+      debug_enabled:
+        description: 'To run with tmate enter "debug_enabled"'
+        required: false
+        default: "false"
 
 jobs:
   lint:
@@ -125,5 +131,13 @@ jobs:
           BUILD_TAGS: e2e
         run: make GIT_TAG=e2e-PR-${{ github.event.pull_request.number }}-${{ github.event.pull_request.head.sha }} -f builder.Makefile compose-plugin
 
+      - name: Setup tmate session
+        uses: mxschmitt/action-tmate@v3
+        with:
+          limit-access-to-actor: true
+          github-token: ${{ secrets.GITHUB_TOKEN }}
+        if: ${{ github.event_name == 'workflow_dispatch' && github.event.inputs.debug_enabled }}
+
+
       - name: E2E Test in standalone mode
         run: make e2e-compose-standalone

+ 1 - 1
Makefile

@@ -51,7 +51,7 @@ e2e-compose-standalone: ## Run End to end local tests in standalone mode. Set E2
 	rm -f /usr/local/bin/docker-compose
 	cp bin/docker-compose /usr/local/bin
 	docker-compose version
-	go test $(TEST_FLAGS) -count=1 --tags=standalone ./pkg/e2e
+	go test $(TEST_FLAGS) -v -count=1 -parallel=1 --tags=standalone ./pkg/e2e
 
 .PHONY: mocks
 mocks:

+ 17 - 3
pkg/e2e/ddev_test.go

@@ -36,10 +36,15 @@ func TestComposeRunDdev(t *testing.T) {
 	if runtime.GOOS == "windows" {
 		t.Skip("Running on Windows. Skipping...")
 	}
+	_ = os.Setenv("DDEV_DEBUG", "true")
+
 	c := NewParallelE2eCLI(t, binDir)
 	dir, err := os.MkdirTemp("", t.Name()+"-")
 	assert.NilError(t, err)
 
+	// ddev needs to be able to find mkcert to figure out where certs are.
+	_ = os.Setenv("PATH", fmt.Sprintf("%s:%s", os.Getenv("PATH"), dir))
+
 	siteName := filepath.Base(dir)
 
 	t.Cleanup(func() {
@@ -60,6 +65,10 @@ func TestComposeRunDdev(t *testing.T) {
 			compressedFilename))
 
 	c.RunCmdInDir(dir, "tar", "-xzf", compressedFilename)
+	c.RunCmdInDir(dir, "curl", "-L", "-o", "mkcert", "https://github.com/FiloSottile/mkcert/releases/download/v1.4.3/mkcert-v1.4.3-linux-amd64")
+	c.RunCmdInDir(dir, "chmod", "a+x", "mkcert")
+	c.RunCmdInDir(dir, "mkcert", "-install")
+
 	c.RunDockerCmd("pull", "drud/ddev-ssh-agent:v1.18.0")
 	c.RunDockerCmd("pull", "busybox:stable")
 	c.RunDockerCmd("pull", "phpmyadmin:5")
@@ -73,14 +82,19 @@ func TestComposeRunDdev(t *testing.T) {
 
 	c.RunCmdInDir(dir, "./ddev", "config", "--auto")
 	c.RunCmdInDir(dir, "./ddev", "config", "global", "--use-docker-compose-from-path")
+	vRes := c.RunCmdInDir(dir, "./ddev", "version")
+	out := vRes.Stdout()
+	fmt.Printf("ddev version: %s\n", out)
 
 	c.RunCmdInDir(dir, "./ddev", "poweroff")
 
-	startRes := c.RunCmdInDir(dir, "./ddev", "start", "-y")
-	assert.Equal(c.test, startRes.ExitCode, 0, "Could not start project")
+	c.RunCmdInDir(dir, "./ddev", "start", "-y")
+
+	// This assertion is irrelevant because c.RunCmdInDir() does its own assertion.
+	//assert.Equal(c.test, startRes.ExitCode, 0, "Could not start project")
 
 	curlRes := c.RunCmdInDir(dir, "curl", "-sSL", fmt.Sprintf("http://%s.ddev.site", siteName))
-	out := curlRes.Stdout()
+	out = curlRes.Stdout()
 	fmt.Println(out)
 	assert.Assert(c.test, strings.Contains(out, "ddev is working"), "Could not start project")
 }