Add a Windows Linkerd cli Test (#4653)

This PR adds a new cli test to see if installation yamls are correctly
generated even on windows, this is important because of all the file
path difference between windows and Linux, and if any code uses a wrong
format might cause the chart generation commands to fail on windows.

This creates a separate workflow for both release and integration.

Also, all the exisiting integration tests are moved in to
/tests/integration to separate from /test/cli as this test does not fall
under integration tests category
This commit is contained in:
Tarun Pothulapati 2020-07-02 17:43:57 +00:00 committed by GitHub
parent 7cd188dc65
commit cf34a14985
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
55 changed files with 129 additions and 1 deletions

View File

@ -50,6 +50,9 @@ jobs:
docker save "$DOCKER_REGISTRY/$image:$TAG" > $ARCHIVES/$image.tar || tee save_fail &
done
# save windows cli into artifacts
cp -r ./target/cli/windows/linkerd $ARCHIVES/linkerd-windows.exe
# Wait for `docker save` background processes to complete. Exit early
# if any job failed.
wait < <(jobs -p)
@ -65,6 +68,31 @@ jobs:
name: image-archives
path: /home/runner/archives
# todo: Keep in sync with `release.yml`
windows_static_cli_tests:
name: Static CLI tests (windows)
runs-on: windows-latest
needs: [docker_build]
steps:
- name: Checkout code
# actions/checkout@v2
uses: actions/checkout@722adc6
- name: Try to load cached Go modules
# actions/cache@v1.1.2
uses: actions/cache@70655ec
with:
path: ~/go/pkg/mod
key: ${{ runner.os }}-go-${{ hashFiles('**/go.sum') }}
restore-keys: |
${{ runner.os }}-go-
- name: Download image archives
# actions/download-artifact@v1
uses: actions/download-artifact@18f0f59
with:
name: image-archives
- name: Run CLI Integration tests
run: |
go test --failfast --mod=readonly ".\test\cli" --linkerd=$PWD\image-archives\linkerd-windows.exe --cli-tests -v
# todo: Keep in sync with `release.yml`
kind_integration_tests:
strategy:
matrix:

View File

@ -37,6 +37,24 @@ jobs:
run: |
export PATH="`pwd`/bin:$PATH"
bin/docker-build
- name: Create artifact with Windows CLI binary
env:
ARCHIVES: /home/runner/archives
run: |
mkdir -p $ARCHIVES
# save windows cli into artifacts
cp -r ./target/cli/windows/linkerd $ARCHIVES/linkerd-windows.exe
# `with.path` values do not support environment variables yet, so an
# absolute path is used here.
#
# https://github.com/actions/upload-artifact/issues/8
- name: Upload artifact
# actions/upload-artifact@v1
uses: actions/upload-artifact@3446296
with:
name: image-archives
path: /home/runner/archives
# todo: Keep in sync with `cloud_integration.yml`
docker_push:
name: Docker push
@ -75,6 +93,31 @@ jobs:
bin/docker-retag-all $TAG main
bin/docker-push main
# todo: Keep in sync with `kind_integration.yml`
windows_static_cli_tests:
name: Static CLI tests (windows)
runs-on: windows-latest
needs: [docker_build]
steps:
- name: Checkout code
# actions/checkout@v2
uses: actions/checkout@722adc6
- name: Try to load cached Go modules
# actions/cache@v1.1.2
uses: actions/cache@70655ec
with:
path: ~/go/pkg/mod
key: ${{ runner.os }}-go-${{ hashFiles('**/go.sum') }}
restore-keys: |
${{ runner.os }}-go-
- name: Download image archives
# actions/download-artifact@v1
uses: actions/download-artifact@18f0f59
with:
name: image-archives
- name: Run CLI Integration tests
run: |
go test --failfast --mod=readonly ".\test\cli" --linkerd=$PWD\image-archives\linkerd-windows.exe --cli-tests -v
# todo: Keep in sync with `kind_integration.yml`
kind_integration_tests:
strategy:
matrix:

View File

@ -101,7 +101,7 @@ test_setup() {
bindir=$( cd "${BASH_SOURCE[0]%/*}" && pwd )
export bindir
export test_directory="$bindir"/../test
export test_directory="$bindir"/../test/integration
check_linkerd_binary
}

View File

@ -0,0 +1,57 @@
package test
import (
"flag"
"fmt"
"net/http"
"os"
"testing"
"github.com/linkerd/linkerd2/testutil"
)
var (
TestHelper *testutil.TestHelper
)
func TestMain(m *testing.M) {
// Read the flags and create a new test helper
exit := func(code int, msg string) {
fmt.Fprintln(os.Stderr, msg)
os.Exit(code)
}
linkerd := flag.String("linkerd", "", "path to the linkerd binary to test")
runTests := flag.Bool("cli-tests", false, "must be provided to run the cli tests")
flag.Parse()
if !*runTests {
exit(0, "cli tests not enabled: enable with -cli-tests")
}
if *linkerd == "" {
exit(1, "-linkerd flag is required")
}
TestHelper = testutil.NewGenericTestHelper(*linkerd, "", "l5d", "", "", "", "", "", "", "", "", false, false, false, *http.DefaultClient, testutil.KubernetesHelper{})
os.Exit(m.Run())
}
func TestCliInstall(t *testing.T) {
var (
cmd = "install"
args = []string{
"--ignore-cluster",
}
)
exec := append([]string{cmd}, args...)
out, stderr, err := TestHelper.LinkerdRun(exec...)
if err != nil {
testutil.AnnotatedFatalf(t, "'linkerd install' command failed",
"'linkerd install' command failed: \n%s\n%s", out, stderr)
}
}