From 39f240eaf854efbd7ce8a453269ca95170e90ffc Mon Sep 17 00:00:00 2001 From: Peter Mounce Date: Sun, 10 May 2020 09:54:09 +0100 Subject: [PATCH 01/71] Multi-OS: Provide binaries Fixes #551, #385, #380 --- .travis.yml | 14 ++++++++++++-- Makefile | 6 +++--- 2 files changed, 15 insertions(+), 5 deletions(-) diff --git a/.travis.yml b/.travis.yml index 93664b35d..997543986 100644 --- a/.travis.yml +++ b/.travis.yml @@ -9,13 +9,18 @@ go: - 1.13.x os: - - linux +- osx +- linux +- windows dist: trusty services: - docker +before_install: +- if [ "${TRAVIS_OS_NAME}" == "windows" ]; then choco install make; fi + install: - go get -u golang.org/x/lint/golint - curl -L https://codeclimate.com/downloads/test-reporter/test-reporter-latest-linux-amd64 > ./cc-test-reporter @@ -25,7 +30,8 @@ before_script: - ./cc-test-reporter before-build script: - - make all +# darwin & windows do not support integration-testing approach via docker that linux does, so skip `test-int-*` +- if [[ "${TRAVIS_OS_NAME}" == "windows" || "${TRAVIS_OS_NAME}" == "osx" ]]; then make test-short-all; else make all; fi after_script: - ./cc-test-reporter after-build --exit-code $TRAVIS_TEST_RESULT -d @@ -35,12 +41,16 @@ deploy: token: secure: hEHCC4EN7iHz7pIWKRn2qw22NTqUxnuBp59wfAlLBtV26j5rHMzSu8mlxkJInusDUGLJiNLrZPRWN0mzOdIXalbUeLhlX7EflJgEj6Q0MchUR69LzCAp0KMIFL1Sfq0v81VgujRLUUy5utxDL8Er4tZknn2PpXAMzpO+ozjNRDhhSEM4iMXfY3bcOIMnx6XRgCjFCb036wlBgOfdgv5fwm2PP638DTKar4W6ZZbqCQByhJ5RyL3BMDPTT0moA/tYbG+FA6p6Rme1OcBkMnpsiJZoB3u8gxsNiEJ43/C2RcULW/18qqp2UVD5FipSDYP7GQ5ugKCbgpWXb0Ctl8o4hv1UsNl0XoyJhAt0PRp6vqnyy6LWB2FzX30Xj/vGIhO/IfiJvspHxpatTk7Esjr46K4u9ao/x63LX6F6yI1ZTfbzt2MhRYRjwh4ORNfqhysuzXChftX1S9hj6s6gO0/zqoOsRK/PK8DProbUn4bxrGOBzi16P0GEk4agWWUm74Pis9qCThXNW8MXEV936KvE1wb1RxTACYvFBtO2IM5eQ26t2Y7mGJd7FJup9LR4oUtUTSbYo5P2Sal6xntBKH5P4nwEtM+TtHoeSCKQ3X5i1VSdvAH7soEAly6rP5d5wwPhqqx9mgUPYO/3ulvxLJOYHamrbj6nlHDXnCEoj1ZMxX4= file: + - release/goss-darwin-amd64 + - release/goss-darwin-amd64.sha256 - release/goss-linux-amd64 - release/goss-linux-amd64.sha256 - release/goss-linux-386 - release/goss-linux-386.sha256 - release/goss-linux-arm - release/goss-linux-arm.sha256 + - release/goss-windows-amd64 + - release/goss-windows-amd64.sha256 - extras/dgoss/dgoss - extras/dgoss/dgoss.sha256 skip_cleanup: true diff --git a/Makefile b/Makefile index f53275446..317dfe0b3 100644 --- a/Makefile +++ b/Makefile @@ -9,9 +9,9 @@ GO111MODULE=on .PHONY: all build install test release bench fmt lint vet test-int-all gen centos7 wheezy precise alpine3 arch test-int32 centos7-32 wheezy-32 precise-32 alpine3-32 arch-32 -all: test-all dgoss-sha256 +all: test-short-all test-int-all dgoss-sha256 -test-all: fmt lint vet test test-int-all +test-short-all: fmt lint vet test install: release/goss-linux-amd64 $(info INFO: Starting build $@) @@ -59,7 +59,7 @@ release: $(MAKE) clean $(MAKE) build -build: release/goss-linux-386 release/goss-linux-amd64 release/goss-linux-arm +build: release/goss-darwin-amd64 release/goss-linux-386 release/goss-linux-amd64 release/goss-linux-arm release/goss-windows-amd64 gen: $(info INFO: Starting build $@) From af50e67bff0309a04228e063d7e0a53ea5a65dcc Mon Sep 17 00:00:00 2001 From: Peter Mounce Date: Sun, 10 May 2020 11:22:49 +0100 Subject: [PATCH 02/71] Make cross-compilation build work (on macOS locally, try CI separately) --- Makefile | 3 +- integration-tests/test.sh | 7 +++++ release-build.sh | 22 ++++++++++++++ system/file.go | 53 --------------------------------- system/file_posix.go | 62 +++++++++++++++++++++++++++++++++++++++ system/file_windows.go | 15 ++++++++++ system/mount.go | 15 ---------- system/mount_posix.go | 21 +++++++++++++ system/mount_windows.go | 9 ++++++ 9 files changed, 137 insertions(+), 70 deletions(-) create mode 100755 release-build.sh create mode 100644 system/file_posix.go create mode 100644 system/file_windows.go create mode 100644 system/mount_posix.go create mode 100644 system/mount_windows.go diff --git a/Makefile b/Makefile index 317dfe0b3..28e9eecbf 100644 --- a/Makefile +++ b/Makefile @@ -52,8 +52,7 @@ bench: # `subst` substitutes space for -, thus making an array # firstword, and word select indexes from said array. release/goss-%: $(GO_FILES) - CGO_ENABLED=0 GOOS=$(firstword $(subst -, ,$*)) GOARCH=$(word 2, $(subst -, ,$*)) go build -ldflags "-X main.version=$(TRAVIS_TAG) -s -w" -o $@ $(exe) - sha256sum $@ > $@.sha256 + ./release-build.sh $* release: $(MAKE) clean diff --git a/integration-tests/test.sh b/integration-tests/test.sh index ac18920a2..750c28ecb 100755 --- a/integration-tests/test.sh +++ b/integration-tests/test.sh @@ -15,6 +15,13 @@ seccomp_opts() { fi } +current_platform="$(uname -s)" +echo "${current_platform}" +if [[ "${current_platform}" == "MINGW"* || "${current_platform}" == "MSYS_NT"* || "${current_platform}" == "Darwin" ]]; then + echo "Skipping: Cannot run integration tests (docker) on macOS or Windows. Exiting 0." + exit 0 +fi + cp "../release/goss-linux-$arch" "goss/$os/" # Run build if Dockerfile has changed but hasn't been pushed to dockerhub if ! md5sum -c "Dockerfile_${os}.md5"; then diff --git a/release-build.sh b/release-build.sh new file mode 100755 index 000000000..d5242d02b --- /dev/null +++ b/release-build.sh @@ -0,0 +1,22 @@ +#!/usr/bin/env bash +set -euo pipefail +set -x +platform_spec="${1:?Must supply name of release binary to build e.g. goss-linux-amd64}" +TRAVIS_TAG="${TRAVIS_TAG:-"local"}" + +# Split platform_spec into platform/arch segments +IFS='- ' read -r -a segments <<< "${platform_spec}" + +os="${segments[0]}" +arch="${segments[1]}" + +output="release/goss-${platform_spec}" +if [[ "${os}" == "windows" ]]; then + output="${output}.exe" +fi + +GOOS="${os}" GOARCH="${arch}" CGO_ENABLED=0 go build \ + -ldflags "-X main.version=${TRAVIS_TAG} -s -w" \ + -o "${output}" + +sha256sum "${output}" > "${output}".sha256 diff --git a/system/file.go b/system/file.go index 71f7ff2e6..077209784 100644 --- a/system/file.go +++ b/system/file.go @@ -9,7 +9,6 @@ import ( "path/filepath" "strconv" "strings" - "syscall" "github.com/aelsabbahy/goss/util" "github.com/opencontainers/runc/libcontainer/user" @@ -85,22 +84,6 @@ func (f *DefFile) Contains() (io.Reader, error) { return fh, nil } -func (f *DefFile) Mode() (string, error) { - if err := f.setup(); err != nil { - return "", err - } - - fi, err := os.Lstat(f.realPath) - if err != nil { - return "", err - } - - sys := fi.Sys() - stat := sys.(*syscall.Stat_t) - mode := fmt.Sprintf("%04o", (stat.Mode & 07777)) - return mode, nil -} - func (f *DefFile) Size() (int, error) { if err := f.setup(); err != nil { return 0, err @@ -146,42 +129,6 @@ func (f *DefFile) Filetype() (string, error) { return "file", nil } -func (f *DefFile) Owner() (string, error) { - if err := f.setup(); err != nil { - return "", err - } - - fi, err := os.Lstat(f.realPath) - if err != nil { - return "", err - } - - uidS := fmt.Sprint(fi.Sys().(*syscall.Stat_t).Uid) - uid, err := strconv.Atoi(uidS) - if err != nil { - return "", err - } - return getUserForUid(uid) -} - -func (f *DefFile) Group() (string, error) { - if err := f.setup(); err != nil { - return "", err - } - - fi, err := os.Lstat(f.realPath) - if err != nil { - return "", err - } - - gidS := fmt.Sprint(fi.Sys().(*syscall.Stat_t).Gid) - gid, err := strconv.Atoi(gidS) - if err != nil { - return "", err - } - return getGroupForGid(gid) -} - func (f *DefFile) LinkedTo() (string, error) { if err := f.setup(); err != nil { return "", err diff --git a/system/file_posix.go b/system/file_posix.go new file mode 100644 index 000000000..b0b6396f9 --- /dev/null +++ b/system/file_posix.go @@ -0,0 +1,62 @@ +// +build linux darwin !windows + +package system + +import ( + "fmt" + "os" + "strconv" + "syscall" +) + +func (f *DefFile) Mode() (string, error) { + if err := f.setup(); err != nil { + return "", err + } + + fi, err := os.Lstat(f.realPath) + if err != nil { + return "", err + } + + sys := fi.Sys() + stat := sys.(*syscall.Stat_t) + mode := fmt.Sprintf("%04o", (stat.Mode & 07777)) + return mode, nil +} + +func (f *DefFile) Owner() (string, error) { + if err := f.setup(); err != nil { + return "", err + } + + fi, err := os.Lstat(f.realPath) + if err != nil { + return "", err + } + + uidS := fmt.Sprint(fi.Sys().(*syscall.Stat_t).Uid) + uid, err := strconv.Atoi(uidS) + if err != nil { + return "", err + } + return getUserForUid(uid) +} + +func (f *DefFile) Group() (string, error) { + if err := f.setup(); err != nil { + return "", err + } + + fi, err := os.Lstat(f.realPath) + if err != nil { + return "", err + } + + gidS := fmt.Sprint(fi.Sys().(*syscall.Stat_t).Gid) + gid, err := strconv.Atoi(gidS) + if err != nil { + return "", err + } + return getGroupForGid(gid) +} diff --git a/system/file_windows.go b/system/file_windows.go new file mode 100644 index 000000000..f9c97f8aa --- /dev/null +++ b/system/file_windows.go @@ -0,0 +1,15 @@ +// +build windows + +package system + +func (f *DefFile) Mode() (string, error) { + return "0000", nil // TODO implement +} + +func (f *DefFile) Owner() (string, error) { + return getUserForUid(1000) +} + +func (f *DefFile) Group() (string, error) { + return getGroupForGid(1000) +} diff --git a/system/mount.go b/system/mount.go index 46337b66a..b2cfd24fe 100644 --- a/system/mount.go +++ b/system/mount.go @@ -2,9 +2,7 @@ package system import ( "fmt" - "math" "strings" - "syscall" "github.com/aelsabbahy/goss/util" "github.com/docker/docker/pkg/mount" @@ -121,16 +119,3 @@ func getMount(mountpoint string) (*mount.Info, error) { } return nil, fmt.Errorf("Mountpoint not found") } - -func getUsage(mountpoint string) (int, error) { - statfsOut := &syscall.Statfs_t{} - err := syscall.Statfs(mountpoint, statfsOut) - if err != nil { - return -1, err - } - - percentageFree := float64(statfsOut.Bfree) / float64(statfsOut.Blocks) - usage := math.Round((1 - percentageFree) * 100) - - return int(usage), nil -} diff --git a/system/mount_posix.go b/system/mount_posix.go new file mode 100644 index 000000000..75b830213 --- /dev/null +++ b/system/mount_posix.go @@ -0,0 +1,21 @@ +// +build linux darwin !windows + +package system + +import ( + "math" + "syscall" +) + +func getUsage(mountpoint string) (int, error) { + statfsOut := &syscall.Statfs_t{} + err := syscall.Statfs(mountpoint, statfsOut) + if err != nil { + return -1, err + } + + percentageFree := float64(statfsOut.Bfree) / float64(statfsOut.Blocks) + usage := math.Round((1 - percentageFree) * 100) + + return int(usage), nil +} diff --git a/system/mount_windows.go b/system/mount_windows.go new file mode 100644 index 000000000..b6fdbb142 --- /dev/null +++ b/system/mount_windows.go @@ -0,0 +1,9 @@ +// +build windows + +package system + +import "errors" + +func getUsage(mountpoint string) (int, error) { + return 0, errors.New("Not implemented") +} From cffc0bc01561b6bf0411974d0b13cbdf347e67f4 Mon Sep 17 00:00:00 2001 From: Peter Mounce Date: Sun, 10 May 2020 11:38:56 +0100 Subject: [PATCH 03/71] deal with cc-test-reporter --- .travis.yml | 4 +--- Makefile | 5 ----- ci-install.sh | 12 ++++++++++++ release-build.sh | 2 +- 4 files changed, 14 insertions(+), 9 deletions(-) create mode 100755 ci-install.sh diff --git a/.travis.yml b/.travis.yml index 997543986..55ffbbccb 100644 --- a/.travis.yml +++ b/.travis.yml @@ -22,9 +22,7 @@ before_install: - if [ "${TRAVIS_OS_NAME}" == "windows" ]; then choco install make; fi install: - - go get -u golang.org/x/lint/golint - - curl -L https://codeclimate.com/downloads/test-reporter/test-reporter-latest-linux-amd64 > ./cc-test-reporter - - chmod +x ./cc-test-reporter + - ./ci-install.sh before_script: - ./cc-test-reporter before-build diff --git a/Makefile b/Makefile index 28e9eecbf..3c3f59678 100644 --- a/Makefile +++ b/Makefile @@ -46,11 +46,6 @@ bench: $(info INFO: Starting build $@) go test -bench=. - - -# Pattern rule for platform builds. -# `subst` substitutes space for -, thus making an array -# firstword, and word select indexes from said array. release/goss-%: $(GO_FILES) ./release-build.sh $* diff --git a/ci-install.sh b/ci-install.sh new file mode 100755 index 000000000..a2c9dccba --- /dev/null +++ b/ci-install.sh @@ -0,0 +1,12 @@ +#!/usr/bin/env bash +set -euo pipefail + +goos="${TRAVIS_OS_NAME:?"No value for TRAVIS_OS_NAME. This is meant to be run in Travis CI, see also https://docs.travis-ci.com/user/environment-variables/#convenience-variables"}" +if [[ "${goos}" == "osx" ]]; then + goos="darwin" +fi + +go get -u golang.org/x/lint/golint + +curl -L "https://codeclimate.com/downloads/test-reporter/test-reporter-latest-${goos}-amd64" > ./cc-test-reporter +chmod +x ./cc-test-reporter diff --git a/release-build.sh b/release-build.sh index d5242d02b..6596b25bf 100755 --- a/release-build.sh +++ b/release-build.sh @@ -1,6 +1,6 @@ #!/usr/bin/env bash set -euo pipefail -set -x + platform_spec="${1:?Must supply name of release binary to build e.g. goss-linux-amd64}" TRAVIS_TAG="${TRAVIS_TAG:-"local"}" From 1e33748c3a67206e3c97959545de6696db1adb0f Mon Sep 17 00:00:00 2001 From: Peter Mounce Date: Sun, 10 May 2020 11:53:23 +0100 Subject: [PATCH 04/71] oh, Windows --- ci-install.sh | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/ci-install.sh b/ci-install.sh index a2c9dccba..747e95ec0 100755 --- a/ci-install.sh +++ b/ci-install.sh @@ -5,8 +5,12 @@ goos="${TRAVIS_OS_NAME:?"No value for TRAVIS_OS_NAME. This is meant to be run in if [[ "${goos}" == "osx" ]]; then goos="darwin" fi +extension="" +if [[ "${goos}" == "windows" ]]; then + extension=".exe" +fi go get -u golang.org/x/lint/golint -curl -L "https://codeclimate.com/downloads/test-reporter/test-reporter-latest-${goos}-amd64" > ./cc-test-reporter -chmod +x ./cc-test-reporter +curl -L "https://codeclimate.com/downloads/test-reporter/test-reporter-latest-${goos}-amd64${extension}" > "./cc-test-reporter${extension}" +chmod +x "./cc-test-reporter${extension}" From 3b0a2a19843f72d2facbb079435c69d83308cc86 Mon Sep 17 00:00:00 2001 From: Peter Mounce Date: Sun, 10 May 2020 11:57:33 +0100 Subject: [PATCH 05/71] Add docs and start of matrix / test-plan --- README.md | 15 +++++++------ docs/manual.md | 12 ++++++----- docs/platform-feature-parity.md | 37 +++++++++++++++++++++++++++++++++ 3 files changed, 53 insertions(+), 11 deletions(-) create mode 100644 docs/platform-feature-parity.md diff --git a/README.md b/README.md index 0d99ccfac..5d885e44d 100644 --- a/README.md +++ b/README.md @@ -31,6 +31,8 @@ Goss is a YAML based [serverspec](http://serverspec.org/) alternative tool for v ## Installation +Note: macOS and Windows binaries are new and considered alpha-quality. Some functionality may be missing, some may be broken. Refer to (Enhancements and bug-reports welcome, please see [#551: Multi-OS support](https://github.com/aelsabbahy/goss/issues/551)) + This will install goss and [dgoss](https://github.com/aelsabbahy/goss/tree/master/extras/dgoss). **Note:** Using `curl | sh` is not recommended for production systems, use manual installation below. @@ -45,8 +47,8 @@ curl -fsSL https://goss.rocks/install | GOSS_VER=v0.3.6 GOSS_DST=~/bin sh ### Manual installation - #### Latest + ```bash curl -L https://github.com/aelsabbahy/goss/releases/latest/download/goss-linux-amd64 -o /usr/local/bin/goss chmod +rx /usr/local/bin/goss @@ -58,6 +60,7 @@ chmod +rx /usr/local/bin/dgoss ``` #### Specific Version + ```bash # See https://github.com/aelsabbahy/goss/releases for release versions VERSION=v0.3.10 @@ -88,7 +91,7 @@ An initial set of tests can be derived from the system state by using the [add]( Let's write a simple sshd test using autoadd. -``` +```txt # Running it as root will allow it to also detect ports $ sudo goss autoadd sshd ``` @@ -132,7 +135,7 @@ Now that we have a test suite, we can: * Run it once -``` +```txt goss validate ............... @@ -142,19 +145,19 @@ Count: 15, Failed: 0 * Edit it to use [templates](https://github.com/aelsabbahy/goss/blob/master/docs/manual.md#templates), and run with a vars file -``` +```txt goss --vars vars.yaml validate ``` * keep running it until the system enters a valid state or we timeout -``` +```txt goss validate --retry-timeout 30s --sleep 1s ``` * serve the tests as a health endpoint -``` +```txt goss serve & curl localhost:8080/healthz diff --git a/docs/manual.md b/docs/manual.md index 09d3e911b..b548f447a 100644 --- a/docs/manual.md +++ b/docs/manual.md @@ -1,5 +1,7 @@ # goss manual +Note: macOS and Windows binaries are new and considered alpha-quality. Some functionality may be missing, some may be broken. Refer to (Enhancements and bug-reports welcome, please see [#551: Multi-OS support](https://github.com/aelsabbahy/goss/issues/551)) + ## Table of Contents * [Table of Contents](#table-of-contents) @@ -326,7 +328,7 @@ $ echo $? ## Goss test creation Goss tests can be created by using either of following methods. 1. goss autoadd -2. goss add +2. goss add 3. manually create YAML/JSON test file by hand. To customize the parameters generated by `goss add` and `goss autoadd` YAML file you need to manually edit it. @@ -364,7 +366,7 @@ service: file: /var/www/html: filetype: directory - exists: true + exists: true ``` If you try to validate this file, it will **only** run the second `file` test: @@ -392,7 +394,7 @@ file: exists: true /var/www/html: filetype: directory - exists: true + exists: true service: httpd: @@ -462,7 +464,7 @@ command: # required attributes exit-status: 0 # defaults to hash key - exec: "go version" + exec: "go version" # optional attributes stdout: - go version go1.6 linux/amd64 @@ -878,7 +880,7 @@ package: contain-element: "4.1.0" ``` -Custom semver matcher is available under `semver-constraint`: +Custom semver matcher is available under `semver-constraint`: ```yaml example: diff --git a/docs/platform-feature-parity.md b/docs/platform-feature-parity.md new file mode 100644 index 000000000..c82fc1c74 --- /dev/null +++ b/docs/platform-feature-parity.md @@ -0,0 +1,37 @@ +# Platform feature-parity + +macOS and Windows binaries are new and considered alpha-quality. Some functionality may be missing, some may be broken. + +This matrix attempts to track parity across platforms. + +Legend: + +* `√` - implemented, passing in CI +* an issue number - refer to that issue for details + +## Matrix + +| Feature | `linux` implementation + unit-tests | `linux` integration-tests | `macOS` implementation + unit-tests | `macOS` integration-tests | `Windows` implementation + unit-tests | `Windows` integration-tests | +|:---------------|:--------|:-----------------:|:----------------:|:-----------------:|:----------------:|:-------------------:|:------------------:| +| Assertion: `addr` | √ | √ | | | | | +| Assertion: `command` | √ | √ | | | | | +| Assertion: `dns` | √ | √ | | | | | +| Assertion: `file` | √ | √ | | | | | +| Assertion: `gossfile` | √ | √ | | | | | +| Assertion: `group` | √ | √ | | | | | +| Assertion: `http` | √ | √ | | | | | +| Assertion: `interface` | √ | √ | | | | | +| Assertion: `kernel-param` | √ | √ | | | | | +| Assertion: `mount` | √ | √ | | | | | +| Assertion: `matching` | √ | √ | | | | | +| Assertion: `package` | √ | √ | | | | | +| Assertion: `port` | √ | √ | | | | | +| Assertion: `process` | √ | √ | | | | | +| Assertion: `service` | √ | √ | | | | | +| Assertion: `user` | √ | √ | | | | | +| Command: `add` | √ | √ | | | | | +| Command: `autoadd` | √ | √ | | | | | +| Command: `help` | √ | √ | | | | | +| Command: `render` | √ | √ | | | | | +| Command: `serve` | √ | √ | | | | | +| Command: `validate` | √ | √ | | | | | From b4b5371bf2d3e6be973717566d9a3ff14d781d29 Mon Sep 17 00:00:00 2001 From: Peter Mounce Date: Sun, 10 May 2020 12:02:20 +0100 Subject: [PATCH 06/71] cross-platform CI --- .travis.yml | 4 ++-- ci-after-build.sh | 11 +++++++++++ ci-before-build.sh | 11 +++++++++++ 3 files changed, 24 insertions(+), 2 deletions(-) create mode 100755 ci-after-build.sh create mode 100755 ci-before-build.sh diff --git a/.travis.yml b/.travis.yml index 55ffbbccb..547a4629a 100644 --- a/.travis.yml +++ b/.travis.yml @@ -25,14 +25,14 @@ install: - ./ci-install.sh before_script: - - ./cc-test-reporter before-build + - ./ci-before-build.sh script: # darwin & windows do not support integration-testing approach via docker that linux does, so skip `test-int-*` - if [[ "${TRAVIS_OS_NAME}" == "windows" || "${TRAVIS_OS_NAME}" == "osx" ]]; then make test-short-all; else make all; fi after_script: - - ./cc-test-reporter after-build --exit-code $TRAVIS_TEST_RESULT -d + - ./ci-after-build.sh deploy: provider: releases diff --git a/ci-after-build.sh b/ci-after-build.sh new file mode 100755 index 000000000..2d452e923 --- /dev/null +++ b/ci-after-build.sh @@ -0,0 +1,11 @@ +#!/usr/bin/env bash +set -euo pipefail + +goos="${TRAVIS_OS_NAME:?"No value for TRAVIS_OS_NAME. This is meant to be run in Travis CI, see also https://docs.travis-ci.com/user/environment-variables/#convenience-variables"}" + +extension="" +if [[ "${goos}" == "windows" ]]; then + extension=".exe" +fi + +"./cc-test-reporter${extension}" after-build --exit-code "${TRAVIS_TEST_RESULT}" -d diff --git a/ci-before-build.sh b/ci-before-build.sh new file mode 100755 index 000000000..a27587291 --- /dev/null +++ b/ci-before-build.sh @@ -0,0 +1,11 @@ +#!/usr/bin/env bash +set -euo pipefail + +goos="${TRAVIS_OS_NAME:?"No value for TRAVIS_OS_NAME. This is meant to be run in Travis CI, see also https://docs.travis-ci.com/user/environment-variables/#convenience-variables"}" + +extension="" +if [[ "${goos}" == "windows" ]]; then + extension=".exe" +fi + +"./cc-test-reporter${extension}" before-build \ No newline at end of file From 3bf369ddd6b9ddcd41904da2d36d1e575c6e0b38 Mon Sep 17 00:00:00 2001 From: Peter Mounce Date: Sun, 10 May 2020 12:05:21 +0100 Subject: [PATCH 07/71] debug --- ci-after-build.sh | 2 +- ci-before-build.sh | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/ci-after-build.sh b/ci-after-build.sh index 2d452e923..2956f5b48 100755 --- a/ci-after-build.sh +++ b/ci-after-build.sh @@ -1,6 +1,6 @@ #!/usr/bin/env bash set -euo pipefail - +set -x goos="${TRAVIS_OS_NAME:?"No value for TRAVIS_OS_NAME. This is meant to be run in Travis CI, see also https://docs.travis-ci.com/user/environment-variables/#convenience-variables"}" extension="" diff --git a/ci-before-build.sh b/ci-before-build.sh index a27587291..7d02e30f6 100755 --- a/ci-before-build.sh +++ b/ci-before-build.sh @@ -1,6 +1,6 @@ #!/usr/bin/env bash set -euo pipefail - +set -x goos="${TRAVIS_OS_NAME:?"No value for TRAVIS_OS_NAME. This is meant to be run in Travis CI, see also https://docs.travis-ci.com/user/environment-variables/#convenience-variables"}" extension="" From fc0e37c5e2c3b4a9c42431d34893b524f0a21703 Mon Sep 17 00:00:00 2001 From: Peter Mounce Date: Sun, 10 May 2020 12:05:52 +0100 Subject: [PATCH 08/71] save --- docs/platform-feature-parity.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docs/platform-feature-parity.md b/docs/platform-feature-parity.md index c82fc1c74..6ea1ec9f0 100644 --- a/docs/platform-feature-parity.md +++ b/docs/platform-feature-parity.md @@ -1,6 +1,6 @@ # Platform feature-parity -macOS and Windows binaries are new and considered alpha-quality. Some functionality may be missing, some may be broken. +macOS and Windows binaries are new and considered alpha-quality. Some functionality may be missing, some may be broken. (Enhancements and bug-reports welcome, please see [#551: Multi-OS support](https://github.com/aelsabbahy/goss/issues/551)) This matrix attempts to track parity across platforms. From 6f04931ec76a9852f778f832a42562584ffdb0b9 Mon Sep 17 00:00:00 2001 From: Peter Mounce Date: Sun, 10 May 2020 12:24:08 +0100 Subject: [PATCH 09/71] oops --- release-build.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/release-build.sh b/release-build.sh index 6596b25bf..a6a043f87 100755 --- a/release-build.sh +++ b/release-build.sh @@ -18,5 +18,5 @@ fi GOOS="${os}" GOARCH="${arch}" CGO_ENABLED=0 go build \ -ldflags "-X main.version=${TRAVIS_TAG} -s -w" \ -o "${output}" - +chmod +x "${output}" sha256sum "${output}" > "${output}".sha256 From 284705a4ede2c157716f016374af557a160a1f2a Mon Sep 17 00:00:00 2001 From: Peter Mounce Date: Sun, 10 May 2020 12:38:14 +0100 Subject: [PATCH 10/71] debug --- integration-tests/test.sh | 2 ++ 1 file changed, 2 insertions(+) diff --git a/integration-tests/test.sh b/integration-tests/test.sh index 750c28ecb..305263df6 100755 --- a/integration-tests/test.sh +++ b/integration-tests/test.sh @@ -48,7 +48,9 @@ trap "rv=\$?; docker rm -vf $id; exit \$rv" INT TERM EXIT [[ $os != "arch" ]] && docker_exec "/goss/$os/goss-linux-$arch" -g "/goss/goss-wait.yaml" validate -r 10s -s 100ms && sleep 1 #out=$(docker exec "$container_name" bash -c "time /goss/$os/goss-linux-$arch -g /goss/$os/goss.yaml validate") +set +e # this can fail, but if it does, no output is shown. out=$(docker_exec "/goss/$os/goss-linux-$arch" --vars "/goss/vars.yaml" --vars-inline "$vars_inline" -g "/goss/$os/goss.yaml" validate) +set -e echo "$out" if [[ $os == "arch" ]]; then From 25b2e67297033cf7c4a77fae4e3196a55c976c49 Mon Sep 17 00:00:00 2001 From: Peter Mounce Date: Sun, 10 May 2020 12:43:03 +0100 Subject: [PATCH 11/71] oci runtime error try2 --- integration-tests/Dockerfile_centos7 | 2 ++ 1 file changed, 2 insertions(+) diff --git a/integration-tests/Dockerfile_centos7 b/integration-tests/Dockerfile_centos7 index d31eaa8c6..e14beef40 100644 --- a/integration-tests/Dockerfile_centos7 +++ b/integration-tests/Dockerfile_centos7 @@ -1,6 +1,8 @@ FROM centos:7.2.1511 MAINTAINER Ahmed +SHELL [ "/bin/sh" ] + ENV container docker RUN (cd /lib/systemd/system/sysinit.target.wants/; for i in *; do [ $i == systemd-tmpfiles-setup.service ] || rm -f $i; done); \ rm -f /lib/systemd/system/multi-user.target.wants/*;\ From 59b95736d43a43e33f11be11374e538b55d0ae2f Mon Sep 17 00:00:00 2001 From: Peter Mounce Date: Sun, 10 May 2020 12:46:25 +0100 Subject: [PATCH 12/71] no windows support for codeclimate --- ci-after-build.sh | 7 ++----- ci-before-build.sh | 7 ++----- ci-install.sh | 10 ++++------ 3 files changed, 8 insertions(+), 16 deletions(-) diff --git a/ci-after-build.sh b/ci-after-build.sh index 2956f5b48..20e9ba6a1 100755 --- a/ci-after-build.sh +++ b/ci-after-build.sh @@ -3,9 +3,6 @@ set -euo pipefail set -x goos="${TRAVIS_OS_NAME:?"No value for TRAVIS_OS_NAME. This is meant to be run in Travis CI, see also https://docs.travis-ci.com/user/environment-variables/#convenience-variables"}" -extension="" -if [[ "${goos}" == "windows" ]]; then - extension=".exe" +if [[ "${goos}" != "windows" ]]; then + ./cc-test-reporter after-build --exit-code "${TRAVIS_TEST_RESULT}" -d fi - -"./cc-test-reporter${extension}" after-build --exit-code "${TRAVIS_TEST_RESULT}" -d diff --git a/ci-before-build.sh b/ci-before-build.sh index 7d02e30f6..f78771337 100755 --- a/ci-before-build.sh +++ b/ci-before-build.sh @@ -3,9 +3,6 @@ set -euo pipefail set -x goos="${TRAVIS_OS_NAME:?"No value for TRAVIS_OS_NAME. This is meant to be run in Travis CI, see also https://docs.travis-ci.com/user/environment-variables/#convenience-variables"}" -extension="" -if [[ "${goos}" == "windows" ]]; then - extension=".exe" +if [[ "${goos}" != "windows" ]]; then + ./cc-test-reporter before-build fi - -"./cc-test-reporter${extension}" before-build \ No newline at end of file diff --git a/ci-install.sh b/ci-install.sh index 747e95ec0..d28fb365b 100755 --- a/ci-install.sh +++ b/ci-install.sh @@ -5,12 +5,10 @@ goos="${TRAVIS_OS_NAME:?"No value for TRAVIS_OS_NAME. This is meant to be run in if [[ "${goos}" == "osx" ]]; then goos="darwin" fi -extension="" -if [[ "${goos}" == "windows" ]]; then - extension=".exe" -fi go get -u golang.org/x/lint/golint -curl -L "https://codeclimate.com/downloads/test-reporter/test-reporter-latest-${goos}-amd64${extension}" > "./cc-test-reporter${extension}" -chmod +x "./cc-test-reporter${extension}" +if [[ "${goos}" != "windows" ]]; then + curl -L "https://codeclimate.com/downloads/test-reporter/test-reporter-latest-${goos}-amd64${extension}" > "./cc-test-reporter" + chmod +x "./cc-test-reporter" +fi From 6f04e71f1ff88f980aed2609c00e49e638996f19 Mon Sep 17 00:00:00 2001 From: Peter Mounce Date: Sun, 10 May 2020 12:49:32 +0100 Subject: [PATCH 13/71] missed that --- ci-install.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ci-install.sh b/ci-install.sh index d28fb365b..c2c593f7d 100755 --- a/ci-install.sh +++ b/ci-install.sh @@ -9,6 +9,6 @@ fi go get -u golang.org/x/lint/golint if [[ "${goos}" != "windows" ]]; then - curl -L "https://codeclimate.com/downloads/test-reporter/test-reporter-latest-${goos}-amd64${extension}" > "./cc-test-reporter" + curl -L "https://codeclimate.com/downloads/test-reporter/test-reporter-latest-${goos}-amd64" > "./cc-test-reporter" chmod +x "./cc-test-reporter" fi From f9011ff9ad7ae79eb633310cc9c0a68118e1bd60 Mon Sep 17 00:00:00 2001 From: Peter Mounce Date: Sun, 10 May 2020 12:56:46 +0100 Subject: [PATCH 14/71] bash --- integration-tests/Dockerfile_centos7 | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/integration-tests/Dockerfile_centos7 b/integration-tests/Dockerfile_centos7 index e14beef40..159a03cf4 100644 --- a/integration-tests/Dockerfile_centos7 +++ b/integration-tests/Dockerfile_centos7 @@ -1,7 +1,7 @@ FROM centos:7.2.1511 MAINTAINER Ahmed -SHELL [ "/bin/sh" ] +SHELL [ "/bin/bash", "-e", "-u", "-o", "pipefail", "-c" ] ENV container docker RUN (cd /lib/systemd/system/sysinit.target.wants/; for i in *; do [ $i == systemd-tmpfiles-setup.service ] || rm -f $i; done); \ From 24177a5d5815ef2731a6f199d0e379ac1e590eec Mon Sep 17 00:00:00 2001 From: Peter Mounce Date: Sun, 10 May 2020 12:58:41 +0100 Subject: [PATCH 15/71] Windows find is, of course, different --- Makefile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Makefile b/Makefile index 3c3f59678..744c85b66 100644 --- a/Makefile +++ b/Makefile @@ -4,7 +4,7 @@ exe = github.com/aelsabbahy/goss/cmd/goss pkgs = $(shell ./novendor.sh) cmd = goss TRAVIS_TAG ?= "0.0.0" -GO_FILES = $(shell find . \( -path ./vendor -o -name '_test.go' \) -prune -o -name '*.go' -print) +GO_FILES = $(shell git ls-files -- '*.go' ':!:*vendor*_test.go') GO111MODULE=on .PHONY: all build install test release bench fmt lint vet test-int-all gen centos7 wheezy precise alpine3 arch test-int32 centos7-32 wheezy-32 precise-32 alpine3-32 arch-32 From 4621bbf4447f847165466f77364ae407f139da26 Mon Sep 17 00:00:00 2001 From: Peter Mounce Date: Sun, 10 May 2020 13:05:20 +0100 Subject: [PATCH 16/71] CI --- .travis.yml | 9 ++++----- ci-after-build.sh | 6 +++--- ci-before-build.sh | 6 +++--- ci-build.sh | 12 ++++++++++++ ci-install.sh | 3 ++- 5 files changed, 24 insertions(+), 12 deletions(-) create mode 100755 ci-build.sh diff --git a/.travis.yml b/.travis.yml index 547a4629a..5dd40b851 100644 --- a/.travis.yml +++ b/.travis.yml @@ -22,17 +22,16 @@ before_install: - if [ "${TRAVIS_OS_NAME}" == "windows" ]; then choco install make; fi install: - - ./ci-install.sh + - ./ci-install.sh "${TRAVIS_OS_NAME}" before_script: - - ./ci-before-build.sh + - ./ci-before-build.sh "${TRAVIS_OS_NAME}" script: -# darwin & windows do not support integration-testing approach via docker that linux does, so skip `test-int-*` -- if [[ "${TRAVIS_OS_NAME}" == "windows" || "${TRAVIS_OS_NAME}" == "osx" ]]; then make test-short-all; else make all; fi + - ./ci-before-build.sh "${TRAVIS_OS_NAME}" after_script: - - ./ci-after-build.sh + - ./ci-after-build.sh "${TRAVIS_OS_NAME}" deploy: provider: releases diff --git a/ci-after-build.sh b/ci-after-build.sh index 20e9ba6a1..dbd798bed 100755 --- a/ci-after-build.sh +++ b/ci-after-build.sh @@ -1,8 +1,8 @@ #!/usr/bin/env bash set -euo pipefail -set -x -goos="${TRAVIS_OS_NAME:?"No value for TRAVIS_OS_NAME. This is meant to be run in Travis CI, see also https://docs.travis-ci.com/user/environment-variables/#convenience-variables"}" -if [[ "${goos}" != "windows" ]]; then +os_name="${1:?"No value from TRAVIS_OS_NAME in 1st arg. This is meant to be run in Travis CI, see also https://docs.travis-ci.com/user/environment-variables/#convenience-variables"}" + +if [[ "${os_name}" != "windows" ]]; then ./cc-test-reporter after-build --exit-code "${TRAVIS_TEST_RESULT}" -d fi diff --git a/ci-before-build.sh b/ci-before-build.sh index f78771337..ac74476e5 100755 --- a/ci-before-build.sh +++ b/ci-before-build.sh @@ -1,8 +1,8 @@ #!/usr/bin/env bash set -euo pipefail -set -x -goos="${TRAVIS_OS_NAME:?"No value for TRAVIS_OS_NAME. This is meant to be run in Travis CI, see also https://docs.travis-ci.com/user/environment-variables/#convenience-variables"}" -if [[ "${goos}" != "windows" ]]; then +os_name="${1:?"No value from TRAVIS_OS_NAME in 1st arg. This is meant to be run in Travis CI, see also https://docs.travis-ci.com/user/environment-variables/#convenience-variables"}" + +if [[ "${os_name}" != "windows" ]]; then ./cc-test-reporter before-build fi diff --git a/ci-build.sh b/ci-build.sh new file mode 100755 index 000000000..8daf52e8e --- /dev/null +++ b/ci-build.sh @@ -0,0 +1,12 @@ +#!/usr/bin/env bash +set -euo pipefail + +os_name="${1:?"No value from TRAVIS_OS_NAME in 1st arg. This is meant to be run in Travis CI, see also https://docs.travis-ci.com/user/environment-variables/#convenience-variables"}" + +# darwin & windows do not support integration-testing approach via docker, so on those, just run fast tests. +# linux runs all tests; unit and integration. +if [[ "${os_name}" == "windows" || "${os_name}" == "osx" ]]; then + make test-short-all +else + make all +fi diff --git a/ci-install.sh b/ci-install.sh index c2c593f7d..a5bb6bbd5 100755 --- a/ci-install.sh +++ b/ci-install.sh @@ -1,7 +1,8 @@ #!/usr/bin/env bash set -euo pipefail -goos="${TRAVIS_OS_NAME:?"No value for TRAVIS_OS_NAME. This is meant to be run in Travis CI, see also https://docs.travis-ci.com/user/environment-variables/#convenience-variables"}" +os_name="${1:?"No value from TRAVIS_OS_NAME in 1st arg. This is meant to be run in Travis CI, see also https://docs.travis-ci.com/user/environment-variables/#convenience-variables"}" +goos="${os_name}" if [[ "${goos}" == "osx" ]]; then goos="darwin" fi From 91f8f034a3ca83585286232e520f9091f592b73e Mon Sep 17 00:00:00 2001 From: Peter Mounce Date: Sun, 10 May 2020 13:09:14 +0100 Subject: [PATCH 17/71] fix pasta --- .travis.yml | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/.travis.yml b/.travis.yml index 5dd40b851..56edb5b5f 100644 --- a/.travis.yml +++ b/.travis.yml @@ -9,9 +9,9 @@ go: - 1.13.x os: -- osx -- linux -- windows + - osx + - linux + - windows dist: trusty @@ -28,7 +28,7 @@ before_script: - ./ci-before-build.sh "${TRAVIS_OS_NAME}" script: - - ./ci-before-build.sh "${TRAVIS_OS_NAME}" + - ./ci-build.sh "${TRAVIS_OS_NAME}" after_script: - ./ci-after-build.sh "${TRAVIS_OS_NAME}" From 955c3bb1e8db9c67ad7b003fc81fb7b660e32604 Mon Sep 17 00:00:00 2001 From: Peter Mounce Date: Sun, 10 May 2020 13:09:38 +0100 Subject: [PATCH 18/71] fix windows binary name --- .travis.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.travis.yml b/.travis.yml index 56edb5b5f..491c4a353 100644 --- a/.travis.yml +++ b/.travis.yml @@ -46,8 +46,8 @@ deploy: - release/goss-linux-386.sha256 - release/goss-linux-arm - release/goss-linux-arm.sha256 - - release/goss-windows-amd64 - - release/goss-windows-amd64.sha256 + - release/goss-windows-amd64.exe + - release/goss-windows-amd64.exe.sha256 - extras/dgoss/dgoss - extras/dgoss/dgoss.sha256 skip_cleanup: true From daa336f08e95a9609709e8bbad36e9b58005878d Mon Sep 17 00:00:00 2001 From: Peter Mounce Date: Sun, 10 May 2020 13:23:18 +0100 Subject: [PATCH 19/71] Move to ci folder to avoid cluttering root. Implement fmt and test to simplify makefile and maybe cross-platform differences --- .travis.yml | 8 ++++---- Makefile | 13 ++----------- ci-after-build.sh => ci/ci-after-build.sh | 0 ci-before-build.sh => ci/ci-before-build.sh | 0 ci-build.sh => ci/ci-build.sh | 0 ci-install.sh => ci/ci-install.sh | 0 ci/go-fmt.sh | 15 +++++++++++++++ ci/go-test.sh | 10 ++++++++++ 8 files changed, 31 insertions(+), 15 deletions(-) rename ci-after-build.sh => ci/ci-after-build.sh (100%) rename ci-before-build.sh => ci/ci-before-build.sh (100%) rename ci-build.sh => ci/ci-build.sh (100%) rename ci-install.sh => ci/ci-install.sh (100%) create mode 100755 ci/go-fmt.sh create mode 100755 ci/go-test.sh diff --git a/.travis.yml b/.travis.yml index 491c4a353..a7e29e6c5 100644 --- a/.travis.yml +++ b/.travis.yml @@ -22,16 +22,16 @@ before_install: - if [ "${TRAVIS_OS_NAME}" == "windows" ]; then choco install make; fi install: - - ./ci-install.sh "${TRAVIS_OS_NAME}" + - ./ci/install.sh "${TRAVIS_OS_NAME}" before_script: - - ./ci-before-build.sh "${TRAVIS_OS_NAME}" + - ./ci/before-build.sh "${TRAVIS_OS_NAME}" script: - - ./ci-build.sh "${TRAVIS_OS_NAME}" + - ./ci/build.sh "${TRAVIS_OS_NAME}" after_script: - - ./ci-after-build.sh "${TRAVIS_OS_NAME}" + - ./ci/after-build.sh "${TRAVIS_OS_NAME}" deploy: provider: releases diff --git a/Makefile b/Makefile index 744c85b66..5bf1ae87e 100644 --- a/Makefile +++ b/Makefile @@ -19,12 +19,7 @@ install: release/goss-linux-amd64 test: $(info INFO: Starting build $@) - { \ -set -e ;\ -go test -coverprofile=c.out ${pkgs} ;\ -cat c.out | sed 's|github.com/aelsabbahy/goss/||' > c.out.tmp ;\ -mv c.out.tmp c.out ;\ -} + ./ci/go-test.sh lint: $(info INFO: Starting build $@) @@ -36,11 +31,7 @@ vet: fmt: $(info INFO: Starting build $@) - { \ -set -e ;\ -fmt=$$(gofmt -l ${GO_FILES}) ;\ -[ -z "$$fmt" ] && echo "valid gofmt" || (echo -e "invalid gofmt\n$$fmt"; exit 1)\ -} + ./ci/go-fmt.sh bench: $(info INFO: Starting build $@) diff --git a/ci-after-build.sh b/ci/ci-after-build.sh similarity index 100% rename from ci-after-build.sh rename to ci/ci-after-build.sh diff --git a/ci-before-build.sh b/ci/ci-before-build.sh similarity index 100% rename from ci-before-build.sh rename to ci/ci-before-build.sh diff --git a/ci-build.sh b/ci/ci-build.sh similarity index 100% rename from ci-build.sh rename to ci/ci-build.sh diff --git a/ci-install.sh b/ci/ci-install.sh similarity index 100% rename from ci-install.sh rename to ci/ci-install.sh diff --git a/ci/go-fmt.sh b/ci/go-fmt.sh new file mode 100755 index 000000000..92898d3d8 --- /dev/null +++ b/ci/go-fmt.sh @@ -0,0 +1,15 @@ +#!/usr/bin/env bash +set -euo pipefail + +# gofmt must be on PATH +command -v gofmt + +fmt="$(gofmt -l "${GO_FILES}")" + +if [[ -z "${fmt}" ]]; then + echo "valid gofmt" +else + echo "invalid gofmt:" + echo "${fmt}" + exit 1 +fi diff --git a/ci/go-test.sh b/ci/go-test.sh new file mode 100755 index 000000000..3e7f9c9de --- /dev/null +++ b/ci/go-test.sh @@ -0,0 +1,10 @@ +#!/usr/bin/env bash +set -euo pipefail + +command -v go + +go test -coverprofile="c.out" "${@}" + +sed 's|github.com/aelsabbahy/goss/||' <"c.out" >"c.out.tmp" + +mv "c.out.tmp" "c.out" From 1ac0fc22a9c050bf15c153f3b3f101e7926aecc7 Mon Sep 17 00:00:00 2001 From: Peter Mounce Date: Sun, 10 May 2020 13:24:20 +0100 Subject: [PATCH 20/71] pass through --- Makefile | 2 +- ci/go-test.sh | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/Makefile b/Makefile index 5bf1ae87e..6da318073 100644 --- a/Makefile +++ b/Makefile @@ -19,7 +19,7 @@ install: release/goss-linux-amd64 test: $(info INFO: Starting build $@) - ./ci/go-test.sh + ./ci/go-test.sh $(pkgs) lint: $(info INFO: Starting build $@) diff --git a/ci/go-test.sh b/ci/go-test.sh index 3e7f9c9de..4e5215771 100755 --- a/ci/go-test.sh +++ b/ci/go-test.sh @@ -3,7 +3,7 @@ set -euo pipefail command -v go -go test -coverprofile="c.out" "${@}" +go test -coverprofile="c.out" "${1}" sed 's|github.com/aelsabbahy/goss/||' <"c.out" >"c.out.tmp" From 0fbb8448c1c84f1019a209f36cf809a746638f46 Mon Sep 17 00:00:00 2001 From: Peter Mounce Date: Sun, 10 May 2020 13:24:49 +0100 Subject: [PATCH 21/71] try just bash --- integration-tests/Dockerfile_centos7 | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/integration-tests/Dockerfile_centos7 b/integration-tests/Dockerfile_centos7 index 159a03cf4..070795cef 100644 --- a/integration-tests/Dockerfile_centos7 +++ b/integration-tests/Dockerfile_centos7 @@ -1,7 +1,7 @@ FROM centos:7.2.1511 MAINTAINER Ahmed -SHELL [ "/bin/bash", "-e", "-u", "-o", "pipefail", "-c" ] +SHELL [ "/bin/bash" ] ENV container docker RUN (cd /lib/systemd/system/sysinit.target.wants/; for i in *; do [ $i == systemd-tmpfiles-setup.service ] || rm -f $i; done); \ From 46678fdeea88ef4220f9994ad3aec7dbfcdd387a Mon Sep 17 00:00:00 2001 From: Peter Mounce Date: Sun, 10 May 2020 13:33:55 +0100 Subject: [PATCH 22/71] oops2 --- ci/{ci-after-build.sh => after-build.sh} | 0 ci/{ci-before-build.sh => before-build.sh} | 0 ci/{ci-build.sh => build.sh} | 0 ci/{ci-install.sh => install.sh} | 0 4 files changed, 0 insertions(+), 0 deletions(-) rename ci/{ci-after-build.sh => after-build.sh} (100%) rename ci/{ci-before-build.sh => before-build.sh} (100%) rename ci/{ci-build.sh => build.sh} (100%) rename ci/{ci-install.sh => install.sh} (100%) diff --git a/ci/ci-after-build.sh b/ci/after-build.sh similarity index 100% rename from ci/ci-after-build.sh rename to ci/after-build.sh diff --git a/ci/ci-before-build.sh b/ci/before-build.sh similarity index 100% rename from ci/ci-before-build.sh rename to ci/before-build.sh diff --git a/ci/ci-build.sh b/ci/build.sh similarity index 100% rename from ci/ci-build.sh rename to ci/build.sh diff --git a/ci/ci-install.sh b/ci/install.sh similarity index 100% rename from ci/ci-install.sh rename to ci/install.sh From 35aa225cb65a1ce462cdb9d891d9efd50f1320be Mon Sep 17 00:00:00 2001 From: Peter Mounce Date: Sun, 10 May 2020 13:45:53 +0100 Subject: [PATCH 23/71] TIL go fmt {package} is a thing --- Makefile | 2 +- ci/go-fmt.sh | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/Makefile b/Makefile index 6da318073..a7c5802b1 100644 --- a/Makefile +++ b/Makefile @@ -37,7 +37,7 @@ bench: $(info INFO: Starting build $@) go test -bench=. -release/goss-%: $(GO_FILES) +release/goss-%: ./release-build.sh $* release: diff --git a/ci/go-fmt.sh b/ci/go-fmt.sh index 92898d3d8..ccbb54fe1 100755 --- a/ci/go-fmt.sh +++ b/ci/go-fmt.sh @@ -4,7 +4,7 @@ set -euo pipefail # gofmt must be on PATH command -v gofmt -fmt="$(gofmt -l "${GO_FILES}")" +fmt="$(go fmt github.com/aelsabbahy/goss/...)" if [[ -z "${fmt}" ]]; then echo "valid gofmt" From 6b9344f6f16ef14c3f97f081190b87ae7ea419cb Mon Sep 17 00:00:00 2001 From: Peter Mounce Date: Sun, 10 May 2020 13:47:30 +0100 Subject: [PATCH 24/71] no longer needed --- Makefile | 1 - 1 file changed, 1 deletion(-) diff --git a/Makefile b/Makefile index a7c5802b1..3960b55f0 100644 --- a/Makefile +++ b/Makefile @@ -4,7 +4,6 @@ exe = github.com/aelsabbahy/goss/cmd/goss pkgs = $(shell ./novendor.sh) cmd = goss TRAVIS_TAG ?= "0.0.0" -GO_FILES = $(shell git ls-files -- '*.go' ':!:*vendor*_test.go') GO111MODULE=on .PHONY: all build install test release bench fmt lint vet test-int-all gen centos7 wheezy precise alpine3 arch test-int32 centos7-32 wheezy-32 precise-32 alpine3-32 arch-32 From 670cdd471983490e099d181adc8ab79b305e6e50 Mon Sep 17 00:00:00 2001 From: Peter Mounce Date: Sun, 10 May 2020 13:56:54 +0100 Subject: [PATCH 25/71] windows --- ci/go-fmt.sh | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/ci/go-fmt.sh b/ci/go-fmt.sh index ccbb54fe1..bea8cb4e5 100755 --- a/ci/go-fmt.sh +++ b/ci/go-fmt.sh @@ -1,9 +1,18 @@ #!/usr/bin/env bash set -euo pipefail +os_name="${1:?"No value from TRAVIS_OS_NAME in 1st arg. This is meant to be run in Travis CI, see also https://docs.travis-ci.com/user/environment-variables/#convenience-variables"}" + # gofmt must be on PATH command -v gofmt +if [[ "${os_name}" == "windows" ]]; then + echo "Skipping go-fmt on Windows because line-endings cause every file to need formatting." + echo "Linux is treated as authoritative." + echo "Exiting 0..." + exit 0 +fi + fmt="$(go fmt github.com/aelsabbahy/goss/...)" if [[ -z "${fmt}" ]]; then From cc06c9dc2c8cac28153f0adb41e0dad218ed42a5 Mon Sep 17 00:00:00 2001 From: Peter Mounce Date: Sun, 10 May 2020 13:58:07 +0100 Subject: [PATCH 26/71] fix table --- docs/platform-feature-parity.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docs/platform-feature-parity.md b/docs/platform-feature-parity.md index 6ea1ec9f0..eb5ce4415 100644 --- a/docs/platform-feature-parity.md +++ b/docs/platform-feature-parity.md @@ -12,7 +12,7 @@ Legend: ## Matrix | Feature | `linux` implementation + unit-tests | `linux` integration-tests | `macOS` implementation + unit-tests | `macOS` integration-tests | `Windows` implementation + unit-tests | `Windows` integration-tests | -|:---------------|:--------|:-----------------:|:----------------:|:-----------------:|:----------------:|:-------------------:|:------------------:| +|:---------------|:--------|:-----------------:|:----------------:|:-----------------:|:----------------:|:-------------------:| | Assertion: `addr` | √ | √ | | | | | | Assertion: `command` | √ | √ | | | | | | Assertion: `dns` | √ | √ | | | | | From 77cc3bf2f3647dfbcec128de63cb50f96e9b3d5e Mon Sep 17 00:00:00 2001 From: Peter Mounce Date: Sun, 10 May 2020 13:58:43 +0100 Subject: [PATCH 27/71] fix --- docs/platform-feature-parity.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docs/platform-feature-parity.md b/docs/platform-feature-parity.md index eb5ce4415..4b485e66a 100644 --- a/docs/platform-feature-parity.md +++ b/docs/platform-feature-parity.md @@ -12,7 +12,7 @@ Legend: ## Matrix | Feature | `linux` implementation + unit-tests | `linux` integration-tests | `macOS` implementation + unit-tests | `macOS` integration-tests | `Windows` implementation + unit-tests | `Windows` integration-tests | -|:---------------|:--------|:-----------------:|:----------------:|:-----------------:|:----------------:|:-------------------:| +|:---------------|:-------:|:-----------------:|:----------------:|:-----------------:|:----------------:|:-------------------:| | Assertion: `addr` | √ | √ | | | | | | Assertion: `command` | √ | √ | | | | | | Assertion: `dns` | √ | √ | | | | | From bcea1ced2dc78f89de776a29ba57c764c3ebbc63 Mon Sep 17 00:00:00 2001 From: Peter Mounce Date: Sun, 10 May 2020 14:00:15 +0100 Subject: [PATCH 28/71] pasta --- ci/go-fmt.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ci/go-fmt.sh b/ci/go-fmt.sh index bea8cb4e5..46d0a2d7f 100755 --- a/ci/go-fmt.sh +++ b/ci/go-fmt.sh @@ -1,7 +1,7 @@ #!/usr/bin/env bash set -euo pipefail -os_name="${1:?"No value from TRAVIS_OS_NAME in 1st arg. This is meant to be run in Travis CI, see also https://docs.travis-ci.com/user/environment-variables/#convenience-variables"}" +os_name="${TRAVIS_OS_NAME:?"No value from TRAVIS_OS_NAME. This is meant to be run in Travis CI, see also https://docs.travis-ci.com/user/environment-variables/#convenience-variables"}" # gofmt must be on PATH command -v gofmt From 1ba5427ca6c9059e1e6fe25f6a3f4438740b144f Mon Sep 17 00:00:00 2001 From: Peter Mounce Date: Sun, 10 May 2020 18:17:13 +0100 Subject: [PATCH 29/71] format table --- docs/platform-feature-parity.md | 48 ++++++++++++++++----------------- 1 file changed, 24 insertions(+), 24 deletions(-) diff --git a/docs/platform-feature-parity.md b/docs/platform-feature-parity.md index 4b485e66a..99a860afd 100644 --- a/docs/platform-feature-parity.md +++ b/docs/platform-feature-parity.md @@ -11,27 +11,27 @@ Legend: ## Matrix -| Feature | `linux` implementation + unit-tests | `linux` integration-tests | `macOS` implementation + unit-tests | `macOS` integration-tests | `Windows` implementation + unit-tests | `Windows` integration-tests | -|:---------------|:-------:|:-----------------:|:----------------:|:-----------------:|:----------------:|:-------------------:| -| Assertion: `addr` | √ | √ | | | | | -| Assertion: `command` | √ | √ | | | | | -| Assertion: `dns` | √ | √ | | | | | -| Assertion: `file` | √ | √ | | | | | -| Assertion: `gossfile` | √ | √ | | | | | -| Assertion: `group` | √ | √ | | | | | -| Assertion: `http` | √ | √ | | | | | -| Assertion: `interface` | √ | √ | | | | | -| Assertion: `kernel-param` | √ | √ | | | | | -| Assertion: `mount` | √ | √ | | | | | -| Assertion: `matching` | √ | √ | | | | | -| Assertion: `package` | √ | √ | | | | | -| Assertion: `port` | √ | √ | | | | | -| Assertion: `process` | √ | √ | | | | | -| Assertion: `service` | √ | √ | | | | | -| Assertion: `user` | √ | √ | | | | | -| Command: `add` | √ | √ | | | | | -| Command: `autoadd` | √ | √ | | | | | -| Command: `help` | √ | √ | | | | | -| Command: `render` | √ | √ | | | | | -| Command: `serve` | √ | √ | | | | | -| Command: `validate` | √ | √ | | | | | +| Feature | `linux` implementation + unit-tests | `linux` integration-tests | `macOS` implementation + unit-tests | `macOS` integration-tests | `Windows` implementation + unit-tests | `Windows` integration-tests | +|:--------------------------|:-----------------------------------:|:-------------------------:|:-----------------------------------:|:-------------------------:|:-------------------------------------:|:---------------------------:| +| Assertion: `addr` | √ | √ | | | | | +| Assertion: `command` | √ | √ | | | | | +| Assertion: `dns` | √ | √ | | | | | +| Assertion: `file` | √ | √ | | | | | +| Assertion: `gossfile` | √ | √ | | | | | +| Assertion: `group` | √ | √ | | | | | +| Assertion: `http` | √ | √ | | | | | +| Assertion: `interface` | √ | √ | | | | | +| Assertion: `kernel-param` | √ | √ | | | | | +| Assertion: `mount` | √ | √ | | | | | +| Assertion: `matching` | √ | √ | | | | | +| Assertion: `package` | √ | √ | | | | | +| Assertion: `port` | √ | √ | | | | | +| Assertion: `process` | √ | √ | | | | | +| Assertion: `service` | √ | √ | | | | | +| Assertion: `user` | √ | √ | | | | | +| Command: `add` | √ | √ | | | | | +| Command: `autoadd` | √ | √ | | | | | +| Command: `help` | √ | √ | | | | | +| Command: `render` | √ | √ | | | | | +| Command: `serve` | √ | √ | | | | | +| Command: `validate` | √ | √ | | | | | From 02ed9cb84a2ad698ddb866d75312b5e4221fa0fd Mon Sep 17 00:00:00 2001 From: Peter Mounce Date: Mon, 11 May 2020 09:55:04 +0100 Subject: [PATCH 30/71] revert to master --- integration-tests/Dockerfile_centos7 | 2 -- 1 file changed, 2 deletions(-) diff --git a/integration-tests/Dockerfile_centos7 b/integration-tests/Dockerfile_centos7 index 070795cef..d31eaa8c6 100644 --- a/integration-tests/Dockerfile_centos7 +++ b/integration-tests/Dockerfile_centos7 @@ -1,8 +1,6 @@ FROM centos:7.2.1511 MAINTAINER Ahmed -SHELL [ "/bin/bash" ] - ENV container docker RUN (cd /lib/systemd/system/sysinit.target.wants/; for i in *; do [ $i == systemd-tmpfiles-setup.service ] || rm -f $i; done); \ rm -f /lib/systemd/system/multi-user.target.wants/*;\ From 09586c3bea7a51941f8bda1dc82bedddc23070d7 Mon Sep 17 00:00:00 2001 From: Peter Mounce Date: Mon, 11 May 2020 09:55:33 +0100 Subject: [PATCH 31/71] revert --- integration-tests/test.sh | 9 --------- 1 file changed, 9 deletions(-) diff --git a/integration-tests/test.sh b/integration-tests/test.sh index 305263df6..ac18920a2 100755 --- a/integration-tests/test.sh +++ b/integration-tests/test.sh @@ -15,13 +15,6 @@ seccomp_opts() { fi } -current_platform="$(uname -s)" -echo "${current_platform}" -if [[ "${current_platform}" == "MINGW"* || "${current_platform}" == "MSYS_NT"* || "${current_platform}" == "Darwin" ]]; then - echo "Skipping: Cannot run integration tests (docker) on macOS or Windows. Exiting 0." - exit 0 -fi - cp "../release/goss-linux-$arch" "goss/$os/" # Run build if Dockerfile has changed but hasn't been pushed to dockerhub if ! md5sum -c "Dockerfile_${os}.md5"; then @@ -48,9 +41,7 @@ trap "rv=\$?; docker rm -vf $id; exit \$rv" INT TERM EXIT [[ $os != "arch" ]] && docker_exec "/goss/$os/goss-linux-$arch" -g "/goss/goss-wait.yaml" validate -r 10s -s 100ms && sleep 1 #out=$(docker exec "$container_name" bash -c "time /goss/$os/goss-linux-$arch -g /goss/$os/goss.yaml validate") -set +e # this can fail, but if it does, no output is shown. out=$(docker_exec "/goss/$os/goss-linux-$arch" --vars "/goss/vars.yaml" --vars-inline "$vars_inline" -g "/goss/$os/goss.yaml" validate) -set -e echo "$out" if [[ $os == "arch" ]]; then From 4ec3fa6aacfe6426fd1c2d7987c5958881946b2c Mon Sep 17 00:00:00 2001 From: Peter Mounce Date: Mon, 11 May 2020 10:12:22 +0100 Subject: [PATCH 32/71] make travis_tag consistent for local builds compared to previously --- Makefile | 1 - release-build.sh | 6 ++++-- 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/Makefile b/Makefile index 3960b55f0..93c97dde9 100644 --- a/Makefile +++ b/Makefile @@ -3,7 +3,6 @@ export GO15VENDOREXPERIMENT=1 exe = github.com/aelsabbahy/goss/cmd/goss pkgs = $(shell ./novendor.sh) cmd = goss -TRAVIS_TAG ?= "0.0.0" GO111MODULE=on .PHONY: all build install test release bench fmt lint vet test-int-all gen centos7 wheezy precise alpine3 arch test-int32 centos7-32 wheezy-32 precise-32 alpine3-32 arch-32 diff --git a/release-build.sh b/release-build.sh index a6a043f87..588e5a037 100755 --- a/release-build.sh +++ b/release-build.sh @@ -2,7 +2,7 @@ set -euo pipefail platform_spec="${1:?Must supply name of release binary to build e.g. goss-linux-amd64}" -TRAVIS_TAG="${TRAVIS_TAG:-"local"}" +version_stamp="${TRAVIS_TAG:-"0.0.0"}" # Split platform_spec into platform/arch segments IFS='- ' read -r -a segments <<< "${platform_spec}" @@ -16,7 +16,9 @@ if [[ "${os}" == "windows" ]]; then fi GOOS="${os}" GOARCH="${arch}" CGO_ENABLED=0 go build \ - -ldflags "-X main.version=${TRAVIS_TAG} -s -w" \ + -ldflags "-X main.version=${version_stamp} -s -w" \ -o "${output}" + chmod +x "${output}" + sha256sum "${output}" > "${output}".sha256 From a2c784a38c938158aa019ba3408939bb71942661 Mon Sep 17 00:00:00 2001 From: Peter Mounce Date: Mon, 11 May 2020 10:12:33 +0100 Subject: [PATCH 33/71] :facepalm: --- release-build.sh | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/release-build.sh b/release-build.sh index 588e5a037..094d9dea9 100755 --- a/release-build.sh +++ b/release-build.sh @@ -17,7 +17,8 @@ fi GOOS="${os}" GOARCH="${arch}" CGO_ENABLED=0 go build \ -ldflags "-X main.version=${version_stamp} -s -w" \ - -o "${output}" + -o "${output}" \ + github.com/aelsabbahy/goss/cmd/goss chmod +x "${output}" From 8486de1ad22e920f815047b076ae0359afb515dd Mon Sep 17 00:00:00 2001 From: Peter Mounce Date: Mon, 11 May 2020 10:48:03 +0100 Subject: [PATCH 34/71] flesh out parity doc --- docs/platform-feature-parity.md | 253 ++++++++++++++++++++++--- integration-tests/goss/goss-serve.yaml | 8 + 2 files changed, 235 insertions(+), 26 deletions(-) create mode 100644 integration-tests/goss/goss-serve.yaml diff --git a/docs/platform-feature-parity.md b/docs/platform-feature-parity.md index 99a860afd..a003fb3af 100644 --- a/docs/platform-feature-parity.md +++ b/docs/platform-feature-parity.md @@ -6,32 +6,233 @@ This matrix attempts to track parity across platforms. Legend: -* `√` - implemented, passing in CI -* an issue number - refer to that issue for details +* `f` - full support +* `p` - partial support (with page-link to heading underneath table, with details) +* `n` - no current support (with page-link to heading underneath table, with details) ## Matrix -| Feature | `linux` implementation + unit-tests | `linux` integration-tests | `macOS` implementation + unit-tests | `macOS` integration-tests | `Windows` implementation + unit-tests | `Windows` integration-tests | -|:--------------------------|:-----------------------------------:|:-------------------------:|:-----------------------------------:|:-------------------------:|:-------------------------------------:|:---------------------------:| -| Assertion: `addr` | √ | √ | | | | | -| Assertion: `command` | √ | √ | | | | | -| Assertion: `dns` | √ | √ | | | | | -| Assertion: `file` | √ | √ | | | | | -| Assertion: `gossfile` | √ | √ | | | | | -| Assertion: `group` | √ | √ | | | | | -| Assertion: `http` | √ | √ | | | | | -| Assertion: `interface` | √ | √ | | | | | -| Assertion: `kernel-param` | √ | √ | | | | | -| Assertion: `mount` | √ | √ | | | | | -| Assertion: `matching` | √ | √ | | | | | -| Assertion: `package` | √ | √ | | | | | -| Assertion: `port` | √ | √ | | | | | -| Assertion: `process` | √ | √ | | | | | -| Assertion: `service` | √ | √ | | | | | -| Assertion: `user` | √ | √ | | | | | -| Command: `add` | √ | √ | | | | | -| Command: `autoadd` | √ | √ | | | | | -| Command: `help` | √ | √ | | | | | -| Command: `render` | √ | √ | | | | | -| Command: `serve` | √ | √ | | | | | -| Command: `validate` | √ | √ | | | | | +| Feature | `linux` | `macOS` | `Windows` | +|:--------------------------|:-------:|:----------------------:|:------------------------:| +| Assertion: `addr` | `f` | | | +| Assertion: `command` | `f` | | | +| Assertion: `dns` | `f` | | | +| Assertion: `file` | `f` | [`p`](#file-macos) | [`p`](#file-windows) | +| Assertion: `gossfile` | `f` | | | +| Assertion: `group` | `f` | | | +| Assertion: `http` | `f` | | | +| Assertion: `interface` | `f` | | | +| Assertion: `kernel-param` | `f` | | | +| Assertion: `mount` | `f` | | | +| Assertion: `matching` | `f` | | | +| Assertion: `package` | `f` | | | +| Assertion: `port` | `f` | | | +| Assertion: `process` | `f` | | | +| Assertion: `service` | `f` | | | +| Assertion: `user` | `f` | | | +| Command: `add` | `f` | | | +| Command: `autoadd` | `f` | | | +| Command: `help` | `f` | | | +| Command: `render` | `f` | | | +| Command: `serve` | `f` | [`p`](#serve-macos) | | +| Command: `validate` | `f` | [`p`](#validate-macos) | [`p`](#validate-windows) | + +## Details + +Please keep this section sorted for ease of navigation. + +Template (so that page-links are regular, and people with markdown aware editors can fold headings). + +```md +### Attribute|Command `ref` + +#### `ref`: platform + +{details here} +``` + +### Attribute: `addr` + +Not yet tested. + +#### `addr`: macOS + +#### `addr`: Windows + +### Attribute: `command` + +#### `command`: macOS + +#### `command`: Windows + +### Attribute: `dns` + +Not yet tested. + +#### `dns`: macOS + +#### `dns`: Windows + +### Attribute: `file` + +#### `file`: macOS + +`owner` and `group` return `##` rather than the actual owner and group. + +#### `file`: Windows + +`owner` and `group` are not applicable on Windows. + +### Attribute: `gossfile` + +Not yet tested. + +#### `gossfile`: macOS + +#### `gossfile`: Windows + +### Attribute: `group` + +Not yet tested. + +#### `group`: macOS + +#### `group`: Windows + +### Attribute: `http` + +Not yet tested. + +#### `http`: macOS + +#### `http`: Windows + +### Attribute: `interface` + +Not yet tested. + +#### `interface`: macOS + +#### `interface`: Windows + +### Attribute: `kernel-param` + +Not yet tested. + +#### `kernel-param`: macOS + +#### `kernel-param`: Windows + +### Attribute: `mount` + +Not yet tested. + +#### `mount`: macOS + +#### `mount`: Windows + +### Attribute: `matching` + +Not yet tested. + +#### `matching`: macOS + +#### `matching`: Windows + +### Attribute: `package` + +Not yet tested. + +#### `package`: macOS + +#### `package`: Windows + +### Attribute: `port` + +Not yet tested. + +#### `port`: macOS + +#### `port`: Windows + +### Attribute: `process` + +Not yet tested. + +#### `process`: macOS + +#### `process`: Windows + +### Attribute: `service` + +Not yet tested. + +#### `service`: macOS + +#### `service`: Windows + +### Attribute: `user` + +Not yet tested. + +#### `user`: macOS + +#### `user`: Windows + +### Command: `add` + +Not yet tested. + +#### `add`: macOS + +#### `add`: Windows + +### Command: `autoadd` + +Not yet tested. + +#### `autoadd`: macOS + +#### `autoadd`: Windows + +### Command: `help` + +Not yet tested. + +#### `help`: macOS + +#### `help`: Windows + +### Command: `render` + +Not yet tested. + +#### `render`: macOS + +#### `render`: Windows + +### Command: `serve` + +Not yet tested. + +#### `serve`: macOS + +Manually tested. + +```bash +trap 'killall goss' EXIT +goss -g integration-tests/goss/goss-serve.yaml serve & +curl http://localhost:9100/healthz | grep 'Count: 2, Failed: 0, Skipped: 0' +``` + +#### `serve`: Windows + +### Command: `validate` + +#### `validate`: macOS + +Manually tested `goss validate`; success. + +#### `validate`: Windows + +Manually tested `goss validate`; success. diff --git a/integration-tests/goss/goss-serve.yaml b/integration-tests/goss/goss-serve.yaml new file mode 100644 index 000000000..1beef10bb --- /dev/null +++ b/integration-tests/goss/goss-serve.yaml @@ -0,0 +1,8 @@ +--- +command: + hello world: + exec: echo 'hi' + exit-status: 0 + stdout: + - hi + stderr: [] From 78b539cbf66bf0558b68ce7a79f4b9e59cbfdb41 Mon Sep 17 00:00:00 2001 From: Peter Mounce Date: Mon, 11 May 2020 10:55:12 +0100 Subject: [PATCH 35/71] expand --- docs/platform-feature-parity.md | 16 +++++++++++----- 1 file changed, 11 insertions(+), 5 deletions(-) diff --git a/docs/platform-feature-parity.md b/docs/platform-feature-parity.md index a003fb3af..20dfe7b3a 100644 --- a/docs/platform-feature-parity.md +++ b/docs/platform-feature-parity.md @@ -15,7 +15,7 @@ Legend: | Feature | `linux` | `macOS` | `Windows` | |:--------------------------|:-------:|:----------------------:|:------------------------:| | Assertion: `addr` | `f` | | | -| Assertion: `command` | `f` | | | +| Assertion: `command` | `f` | [`p`](#command-macos) | | | Assertion: `dns` | `f` | | | | Assertion: `file` | `f` | [`p`](#file-macos) | [`p`](#file-windows) | | Assertion: `gossfile` | `f` | | | @@ -34,7 +34,7 @@ Legend: | Command: `autoadd` | `f` | | | | Command: `help` | `f` | | | | Command: `render` | `f` | | | -| Command: `serve` | `f` | [`p`](#serve-macos) | | +| Command: `serve` | `f` | [`p`](#serve-macos) | | | Command: `validate` | `f` | [`p`](#validate-macos) | [`p`](#validate-windows) | ## Details @@ -63,6 +63,8 @@ Not yet tested. #### `command`: macOS +Manually tested via [`serve`](#serve-macos). + #### `command`: Windows ### Attribute: `dns` @@ -220,8 +222,9 @@ Not yet tested. Manually tested. ```bash -trap 'killall goss' EXIT -goss -g integration-tests/goss/goss-serve.yaml serve & +make build +trap 'killall goss-darwin-amd64' EXIT +release/goss-darwin-amd64 -g integration-tests/goss/goss-serve.yaml serve & curl http://localhost:9100/healthz | grep 'Count: 2, Failed: 0, Skipped: 0' ``` @@ -231,7 +234,10 @@ curl http://localhost:9100/healthz | grep 'Count: 2, Failed: 0, Skipped: 0' #### `validate`: macOS -Manually tested `goss validate`; success. +```bash +make build +release/goss-darwin-amd64 -g integration-tests/goss/goss-serve.yaml validate | grep 'Count: 2, Failed: 0, Skipped: 0' +``` #### `validate`: Windows From 330bd1c22d51ce575d404052b330fce400e639fd Mon Sep 17 00:00:00 2001 From: Peter Mounce Date: Mon, 11 May 2020 10:55:47 +0100 Subject: [PATCH 36/71] tweak --- docs/platform-feature-parity.md | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/docs/platform-feature-parity.md b/docs/platform-feature-parity.md index 20dfe7b3a..7f3d50bc5 100644 --- a/docs/platform-feature-parity.md +++ b/docs/platform-feature-parity.md @@ -219,8 +219,6 @@ Not yet tested. #### `serve`: macOS -Manually tested. - ```bash make build trap 'killall goss-darwin-amd64' EXIT @@ -241,4 +239,4 @@ release/goss-darwin-amd64 -g integration-tests/goss/goss-serve.yaml validate | g #### `validate`: Windows -Manually tested `goss validate`; success. +Not yet tested. From 75eb18ac9a511941442c884d6bf96c9cae8a43fa Mon Sep 17 00:00:00 2001 From: Peter Mounce Date: Mon, 11 May 2020 11:07:52 +0100 Subject: [PATCH 37/71] elaborate --- docs/platform-feature-parity.md | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/docs/platform-feature-parity.md b/docs/platform-feature-parity.md index 7f3d50bc5..de25ac17a 100644 --- a/docs/platform-feature-parity.md +++ b/docs/platform-feature-parity.md @@ -4,12 +4,20 @@ macOS and Windows binaries are new and considered alpha-quality. Some functional This matrix attempts to track parity across platforms. -Legend: +## How to use this doc + +### Legend * `f` - full support * `p` - partial support (with page-link to heading underneath table, with details) * `n` - no current support (with page-link to heading underneath table, with details) +### Contributing + +The current integration test approach is only appropriate for validating `linux` binaries against `linux` OS/arch combinations. + +Validating `macOS` and `Windows` binaries requires adding coverage that runs on those platforms within Travis, but since Travis does not support containerised builds for either platform, assertions are limited to assert against the state of the CI hosts, where we're relying on that to predictable. + ## Matrix | Feature | `linux` | `macOS` | `Windows` | From 82270281d7b42dc664a38a2fd36f2747c04507c5 Mon Sep 17 00:00:00 2001 From: Peter Mounce Date: Mon, 11 May 2020 11:40:45 +0100 Subject: [PATCH 38/71] I added tests --- integration-tests/test.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/integration-tests/test.sh b/integration-tests/test.sh index ac18920a2..c8cda4418 100755 --- a/integration-tests/test.sh +++ b/integration-tests/test.sh @@ -47,7 +47,7 @@ echo "$out" if [[ $os == "arch" ]]; then egrep -q 'Count: 90, Failed: 0, Skipped: 3' <<<"$out" else - egrep -q 'Count: 107, Failed: 0, Skipped: 5' <<<"$out" + egrep -q 'Count: 109, Failed: 0, Skipped: 5' <<<"$out" fi if [[ ! $os == "arch" ]]; then From fb3921bcb76560c9dd23986b4db3d901f4e7f9ee Mon Sep 17 00:00:00 2001 From: Peter Mounce Date: Thu, 14 May 2020 18:47:29 +0100 Subject: [PATCH 39/71] simplify I think? --- docs/platform-feature-parity.md | 61 +++++++++++++++------------------ 1 file changed, 27 insertions(+), 34 deletions(-) diff --git a/docs/platform-feature-parity.md b/docs/platform-feature-parity.md index de25ac17a..7e654d85f 100644 --- a/docs/platform-feature-parity.md +++ b/docs/platform-feature-parity.md @@ -11,6 +11,7 @@ This matrix attempts to track parity across platforms. * `f` - full support * `p` - partial support (with page-link to heading underneath table, with details) * `n` - no current support (with page-link to heading underneath table, with details) +* `` (blank) - not yet tried ### Contributing @@ -20,45 +21,37 @@ Validating `macOS` and `Windows` binaries requires adding coverage that runs on ## Matrix -| Feature | `linux` | `macOS` | `Windows` | -|:--------------------------|:-------:|:----------------------:|:------------------------:| -| Assertion: `addr` | `f` | | | -| Assertion: `command` | `f` | [`p`](#command-macos) | | -| Assertion: `dns` | `f` | | | -| Assertion: `file` | `f` | [`p`](#file-macos) | [`p`](#file-windows) | -| Assertion: `gossfile` | `f` | | | -| Assertion: `group` | `f` | | | -| Assertion: `http` | `f` | | | -| Assertion: `interface` | `f` | | | -| Assertion: `kernel-param` | `f` | | | -| Assertion: `mount` | `f` | | | -| Assertion: `matching` | `f` | | | -| Assertion: `package` | `f` | | | -| Assertion: `port` | `f` | | | -| Assertion: `process` | `f` | | | -| Assertion: `service` | `f` | | | -| Assertion: `user` | `f` | | | -| Command: `add` | `f` | | | -| Command: `autoadd` | `f` | | | -| Command: `help` | `f` | | | -| Command: `render` | `f` | | | -| Command: `serve` | `f` | [`p`](#serve-macos) | | -| Command: `validate` | `f` | [`p`](#validate-macos) | [`p`](#validate-windows) | +| Feature | `linux` | `macOS` | `Windows` | +|:---------------|:-------:|:----------------------:|:------------------------:| +| **Assertions** | | | | +| `addr` | `f` | | | +| `command` | `f` | [`p`](#command-macos) | | +| `dns` | `f` | | | +| `file` | `f` | [`p`](#file-macos) | [`p`](#file-windows) | +| `gossfile` | `f` | | | +| `group` | `f` | | | +| `http` | `f` | | | +| `interface` | `f` | | | +| `kernel-param` | `f` | | | +| `mount` | `f` | | | +| `matching` | `f` | | | +| `package` | `f` | | | +| `port` | `f` | | | +| `process` | `f` | | | +| `service` | `f` | | | +| `user` | `f` | | | +| **Commands** | | | | +| `add` | `f` | | | +| `autoadd` | `f` | | | +| `help` | `f` | | | +| `render` | `f` | | | +| `serve` | `f` | [`p`](#serve-macos) | | +| `validate` | `f` | [`p`](#validate-macos) | [`p`](#validate-windows) | ## Details Please keep this section sorted for ease of navigation. -Template (so that page-links are regular, and people with markdown aware editors can fold headings). - -```md -### Attribute|Command `ref` - -#### `ref`: platform - -{details here} -``` - ### Attribute: `addr` Not yet tested. From e35b1b8d6eb365cad45d46b6b562f5288c6c0514 Mon Sep 17 00:00:00 2001 From: Peter Mounce Date: Thu, 14 May 2020 19:18:31 +0100 Subject: [PATCH 40/71] Name the binaries to denote alphaness --- .travis.yml | 8 ++++---- Makefile | 2 +- docs/platform-feature-parity.md | 6 +++--- release-build.sh | 4 ++++ 4 files changed, 12 insertions(+), 8 deletions(-) diff --git a/.travis.yml b/.travis.yml index a7e29e6c5..fb9d97fed 100644 --- a/.travis.yml +++ b/.travis.yml @@ -38,16 +38,16 @@ deploy: token: secure: hEHCC4EN7iHz7pIWKRn2qw22NTqUxnuBp59wfAlLBtV26j5rHMzSu8mlxkJInusDUGLJiNLrZPRWN0mzOdIXalbUeLhlX7EflJgEj6Q0MchUR69LzCAp0KMIFL1Sfq0v81VgujRLUUy5utxDL8Er4tZknn2PpXAMzpO+ozjNRDhhSEM4iMXfY3bcOIMnx6XRgCjFCb036wlBgOfdgv5fwm2PP638DTKar4W6ZZbqCQByhJ5RyL3BMDPTT0moA/tYbG+FA6p6Rme1OcBkMnpsiJZoB3u8gxsNiEJ43/C2RcULW/18qqp2UVD5FipSDYP7GQ5ugKCbgpWXb0Ctl8o4hv1UsNl0XoyJhAt0PRp6vqnyy6LWB2FzX30Xj/vGIhO/IfiJvspHxpatTk7Esjr46K4u9ao/x63LX6F6yI1ZTfbzt2MhRYRjwh4ORNfqhysuzXChftX1S9hj6s6gO0/zqoOsRK/PK8DProbUn4bxrGOBzi16P0GEk4agWWUm74Pis9qCThXNW8MXEV936KvE1wb1RxTACYvFBtO2IM5eQ26t2Y7mGJd7FJup9LR4oUtUTSbYo5P2Sal6xntBKH5P4nwEtM+TtHoeSCKQ3X5i1VSdvAH7soEAly6rP5d5wwPhqqx9mgUPYO/3ulvxLJOYHamrbj6nlHDXnCEoj1ZMxX4= file: - - release/goss-darwin-amd64 - - release/goss-darwin-amd64.sha256 + - release/goss-alpha-darwin-amd64 + - release/goss-alpha-darwin-amd64.sha256 - release/goss-linux-amd64 - release/goss-linux-amd64.sha256 - release/goss-linux-386 - release/goss-linux-386.sha256 - release/goss-linux-arm - release/goss-linux-arm.sha256 - - release/goss-windows-amd64.exe - - release/goss-windows-amd64.exe.sha256 + - release/goss-alpha-windows-amd64.exe + - release/goss-alpha-windows-amd64.exe.sha256 - extras/dgoss/dgoss - extras/dgoss/dgoss.sha256 skip_cleanup: true diff --git a/Makefile b/Makefile index 93c97dde9..32772c676 100644 --- a/Makefile +++ b/Makefile @@ -42,7 +42,7 @@ release: $(MAKE) clean $(MAKE) build -build: release/goss-darwin-amd64 release/goss-linux-386 release/goss-linux-amd64 release/goss-linux-arm release/goss-windows-amd64 +build: release/goss-alpha-darwin-amd64 release/goss-linux-386 release/goss-linux-amd64 release/goss-linux-arm release/goss-alpha-windows-amd64 gen: $(info INFO: Starting build $@) diff --git a/docs/platform-feature-parity.md b/docs/platform-feature-parity.md index 7e654d85f..6ae19c532 100644 --- a/docs/platform-feature-parity.md +++ b/docs/platform-feature-parity.md @@ -222,8 +222,8 @@ Not yet tested. ```bash make build -trap 'killall goss-darwin-amd64' EXIT -release/goss-darwin-amd64 -g integration-tests/goss/goss-serve.yaml serve & +trap 'killall goss-alpha-darwin-amd64' EXIT +release/goss-alpha-darwin-amd64 -g integration-tests/goss/goss-serve.yaml serve & curl http://localhost:9100/healthz | grep 'Count: 2, Failed: 0, Skipped: 0' ``` @@ -235,7 +235,7 @@ curl http://localhost:9100/healthz | grep 'Count: 2, Failed: 0, Skipped: 0' ```bash make build -release/goss-darwin-amd64 -g integration-tests/goss/goss-serve.yaml validate | grep 'Count: 2, Failed: 0, Skipped: 0' +release/goss-alpha-darwin-amd64 -g integration-tests/goss/goss-serve.yaml validate | grep 'Count: 2, Failed: 0, Skipped: 0' ``` #### `validate`: Windows diff --git a/release-build.sh b/release-build.sh index 094d9dea9..3bab62b09 100755 --- a/release-build.sh +++ b/release-build.sh @@ -9,6 +9,10 @@ IFS='- ' read -r -a segments <<< "${platform_spec}" os="${segments[0]}" arch="${segments[1]}" +if [[ "${segments[0]}" == "alpha" ]]; then + os="${segments[1]}" + arch="${segments[2]}" +fi output="release/goss-${platform_spec}" if [[ "${os}" == "windows" ]]; then From b939438cd23624b3662bdd59798ad98db77477be Mon Sep 17 00:00:00 2001 From: Peter Mounce Date: Thu, 14 May 2020 19:43:50 +0100 Subject: [PATCH 41/71] Output warning before/after, and fail unless GOSS_ALPHA=1 --- cmd/goss/goss.go | 35 +++++++++++++++++++++++++++++++++++ 1 file changed, 35 insertions(+) diff --git a/cmd/goss/goss.go b/cmd/goss/goss.go index 2c3e9ff51..083f3be69 100644 --- a/cmd/goss/goss.go +++ b/cmd/goss/goss.go @@ -4,6 +4,7 @@ import ( "fmt" "log" "os" + "runtime" "strings" "time" @@ -378,9 +379,43 @@ func main() { }, } + warnAlphaIfNeeded() + fatalAlphaIfNeeded() err := app.Run(os.Args) if err != nil { log.Fatal(err) } + warnAlphaIfNeeded() +} + +const msgFormat string = `WARNING: goss on %q is alpha-quality and work-in-progress. + +You should not expect everything to work. Treat linux as the canonical behaviour to expect. + +Please see https://github.com/aelsabbahy/goss/tree/master/docs/platform-feature-parity.md to set your expectations and see progress. +Please file issues via https://github.com/aelsabbahy/goss/issues/new/choose +Pull requests and bug reports very welcome.` + +func warnAlphaIfNeeded() { + if runtime.GOOS == "darwin" || runtime.GOOS == "windows" { + log.Printf(msgFormat, strings.Title(runtime.GOOS)) + } +} + +func fatalAlphaIfNeeded() { + if runtime.GOOS == "darwin" || runtime.GOOS == "windows" { + howto := map[string]string{ + "darwin": "export GOSS_ALPHA=1", + "windows": "set GOSS_ALPHA=1", + } + val, found := os.LookupEnv("GOSS_ALPHA") + if !found || val != "1" { + log.Printf(`Terminating. +To bypass this and use the binary anyway: + +%s`, howto[runtime.GOOS]) + os.Exit(1) + } + } } From 4f145e99eb878954fb317ad3735efe2f3c1b4e61 Mon Sep 17 00:00:00 2001 From: Peter Mounce Date: Thu, 14 May 2020 19:44:48 +0100 Subject: [PATCH 42/71] elaborate slightly --- docs/platform-feature-parity.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docs/platform-feature-parity.md b/docs/platform-feature-parity.md index 6ae19c532..4c42774ae 100644 --- a/docs/platform-feature-parity.md +++ b/docs/platform-feature-parity.md @@ -64,7 +64,7 @@ Not yet tested. #### `command`: macOS -Manually tested via [`serve`](#serve-macos). +Manually tested via [`serve`](#serve-macos) below. #### `command`: Windows From ee45539fd689992d7ecd0941212d10edbcb1cd3e Mon Sep 17 00:00:00 2001 From: Peter Mounce Date: Thu, 14 May 2020 19:48:30 +0100 Subject: [PATCH 43/71] oops, CI verbiage --- cmd/goss/goss.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/cmd/goss/goss.go b/cmd/goss/goss.go index 083f3be69..61552700d 100644 --- a/cmd/goss/goss.go +++ b/cmd/goss/goss.go @@ -388,7 +388,7 @@ func main() { warnAlphaIfNeeded() } -const msgFormat string = `WARNING: goss on %q is alpha-quality and work-in-progress. +const msgFormat string = `WARNING: goss on %q is alpha-quality, work-in-progress, and not yet exercised within continuous integration. You should not expect everything to work. Treat linux as the canonical behaviour to expect. From 988558fbdb54b8bce9355cc2517af406aa4a2ed4 Mon Sep 17 00:00:00 2001 From: Peter Mounce Date: Sun, 17 May 2020 11:27:41 +0100 Subject: [PATCH 44/71] cleaner formatting --- docs/platform-feature-parity.md | 300 ++++++++++++-------------------- 1 file changed, 108 insertions(+), 192 deletions(-) diff --git a/docs/platform-feature-parity.md b/docs/platform-feature-parity.md index 4c42774ae..f7e0fef52 100644 --- a/docs/platform-feature-parity.md +++ b/docs/platform-feature-parity.md @@ -8,10 +8,12 @@ This matrix attempts to track parity across platforms. ### Legend -* `f` - full support -* `p` - partial support (with page-link to heading underneath table, with details) -* `n` - no current support (with page-link to heading underneath table, with details) -* `` (blank) - not yet tried +* `x` - full supported/tested +* `w` - full working/tested, community support +* `w-nt` - works no automated tests +* `n/a` - Not applicable for this platform +* `#585` - Link to bug(s) for implementation, fixing +* ` ` - (blank) - not yet tried, no data ### Contributing @@ -19,206 +21,126 @@ The current integration test approach is only appropriate for validating `linux` Validating `macOS` and `Windows` binaries requires adding coverage that runs on those platforms within Travis, but since Travis does not support containerised builds for either platform, assertions are limited to assert against the state of the CI hosts, where we're relying on that to predictable. -## Matrix - -| Feature | `linux` | `macOS` | `Windows` | -|:---------------|:-------:|:----------------------:|:------------------------:| -| **Assertions** | | | | -| `addr` | `f` | | | -| `command` | `f` | [`p`](#command-macos) | | -| `dns` | `f` | | | -| `file` | `f` | [`p`](#file-macos) | [`p`](#file-windows) | -| `gossfile` | `f` | | | -| `group` | `f` | | | -| `http` | `f` | | | -| `interface` | `f` | | | -| `kernel-param` | `f` | | | -| `mount` | `f` | | | -| `matching` | `f` | | | -| `package` | `f` | | | -| `port` | `f` | | | -| `process` | `f` | | | -| `service` | `f` | | | -| `user` | `f` | | | -| **Commands** | | | | -| `add` | `f` | | | -| `autoadd` | `f` | | | -| `help` | `f` | | | -| `render` | `f` | | | -| `serve` | `f` | [`p`](#serve-macos) | | -| `validate` | `f` | [`p`](#validate-macos) | [`p`](#validate-windows) | - -## Details - -Please keep this section sorted for ease of navigation. - -### Attribute: `addr` - -Not yet tested. - -#### `addr`: macOS - -#### `addr`: Windows - -### Attribute: `command` - -#### `command`: macOS - -Manually tested via [`serve`](#serve-macos) below. - -#### `command`: Windows - -### Attribute: `dns` - -Not yet tested. - -#### `dns`: macOS - -#### `dns`: Windows - -### Attribute: `file` - -#### `file`: macOS - -`owner` and `group` return `##` rather than the actual owner and group. - -#### `file`: Windows - -`owner` and `group` are not applicable on Windows. - -### Attribute: `gossfile` - -Not yet tested. - -#### `gossfile`: macOS - -#### `gossfile`: Windows - -### Attribute: `group` - -Not yet tested. - -#### `group`: macOS - -#### `group`: Windows - -### Attribute: `http` - -Not yet tested. - -#### `http`: macOS - -#### `http`: Windows - -### Attribute: `interface` - -Not yet tested. - -#### `interface`: macOS - -#### `interface`: Windows - -### Attribute: `kernel-param` - -Not yet tested. - -#### `kernel-param`: macOS - -#### `kernel-param`: Windows - -### Attribute: `mount` - -Not yet tested. - -#### `mount`: macOS - -#### `mount`: Windows - -### Attribute: `matching` - -Not yet tested. - -#### `matching`: macOS - -#### `matching`: Windows - -### Attribute: `package` - -Not yet tested. - -#### `package`: macOS - -#### `package`: Windows - -### Attribute: `port` - -Not yet tested. - -#### `port`: macOS - -#### `port`: Windows - -### Attribute: `process` - -Not yet tested. - -#### `process`: macOS - -#### `process`: Windows - -### Attribute: `service` - -Not yet tested. - -#### `service`: macOS - -#### `service`: Windows - -### Attribute: `user` - -Not yet tested. - -#### `user`: macOS - -#### `user`: Windows +## Matrix - tests/assertions + +| Test | `linux` | `macOS` | `Windows` | +|:--------------------|---------|---------|-----------| +| **addr** | x | | | +| reachable | x | | | +| local-address | x | | | +| timeout | x | | | +| | x | | | +| **command** | x | | | +| exit-status | x | | | +| stdout | x | | | +| stderr | x | | | +| timeout | x | | | +| | x | | | +| **dns** | x | | | +| resolvable | x | | | +| addrs | x | | | +| server | x | | | +| timeout | x | | | +| **file** | x | | | +| exists | x | w-nt | w | +| mode | x | | n/a | +| size | x | | | +| owner | x | #585 | n/a | +| group | x | #585 | n/a | +| filetype | x | | | +| contains | x | w-nt | w-nt | +| md5 | x | w-nt | w-nt | +| sha256 | x | w-nt | w-nt | +| linked-to | x | w-nt | w-nt | +| | x | | | +| **gossfile** | x | | | +| | x | | | +| **group** | x | | | +| exists | x | | | +| gid | x | | | +| | x | | | +| **http** | x | | | +| status | x | | | +| allow-insecure | x | | | +| no-follow-redirects | x | | | +| timeout | x | | | +| request-headers | x | | | +| headers | x | | | +| body | x | | | +| username | x | | | +| password | x | | | +| **interface** | x | | | +| exists | x | | | +| addrs | x | | | +| mtu | x | | | +| | x | | | +| **kernel-param** | x | | | +| value | x | | | +| | x | | | +| **mount** | x | | | +| exists | x | | | +| opts | x | | | +| source | x | | | +| filesystem | x | | | +| usage | x | | | +| | x | | | +| **matching** | x | | | +| | x | | | +| **package** | x | | | +| installed | x | | | +| versions | x | | | +| | x | | | +| **port** | x | | | +| listening | x | | | +| ip | x | | | +| | x | | | +| **process** | x | | | +| running | x | | | +| | x | | | +| **service** | x | | | +| enabled | x | | | +| running | x | | | +| | x | | | +| **user** | x | | | +| exists | x | | | +| uid | x | | | +| gid | x | | | +| groups | x | | | +| home | x | | | +| shell | x | | | + +## Matrix - `command`s + +| Test | `linux` | `macOS` | `Windows` | +|:-----------|---------|---------|-----------| +| `add` | x | | | +| `autoadd` | x | | | +| `help` | x | | | +| `render` | x | | | +| `serve` | x | w-nt | | +| `validate` | x | w-nt | w-nt | + +### `command` testing notes ### Command: `add` Not yet tested. -#### `add`: macOS - -#### `add`: Windows - ### Command: `autoadd` Not yet tested. -#### `autoadd`: macOS - -#### `autoadd`: Windows - ### Command: `help` Not yet tested. -#### `help`: macOS - -#### `help`: Windows - ### Command: `render` Not yet tested. -#### `render`: macOS - -#### `render`: Windows - ### Command: `serve` -Not yet tested. - -#### `serve`: macOS +macOS: ```bash make build @@ -227,17 +149,11 @@ release/goss-alpha-darwin-amd64 -g integration-tests/goss/goss-serve.yaml serve curl http://localhost:9100/healthz | grep 'Count: 2, Failed: 0, Skipped: 0' ``` -#### `serve`: Windows - ### Command: `validate` -#### `validate`: macOS +macOS: ```bash make build release/goss-alpha-darwin-amd64 -g integration-tests/goss/goss-serve.yaml validate | grep 'Count: 2, Failed: 0, Skipped: 0' ``` - -#### `validate`: Windows - -Not yet tested. From 1a98dfcb7217b0a6a45da70712cd984f0a909f9f Mon Sep 17 00:00:00 2001 From: Peter Mounce Date: Sun, 24 May 2020 11:13:16 +0100 Subject: [PATCH 45/71] support each shell --- cmd/goss/goss.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/cmd/goss/goss.go b/cmd/goss/goss.go index 61552700d..53302ef18 100644 --- a/cmd/goss/goss.go +++ b/cmd/goss/goss.go @@ -406,7 +406,7 @@ func fatalAlphaIfNeeded() { if runtime.GOOS == "darwin" || runtime.GOOS == "windows" { howto := map[string]string{ "darwin": "export GOSS_ALPHA=1", - "windows": "set GOSS_ALPHA=1", + "windows": "In cmd: set GOSS_ALPHA=1\nIn powershell: $env:GOSS_ALPHA=1\nIn bash: export GOSS_ALPHA=1", } val, found := os.LookupEnv("GOSS_ALPHA") if !found || val != "1" { From f7c2d6f1bc4970d7ffd3cfa2c734230af9ac4227 Mon Sep 17 00:00:00 2001 From: Peter Mounce Date: Sun, 24 May 2020 14:20:57 +0100 Subject: [PATCH 46/71] Test Windows by adding automation --- ci/build.sh | 7 +- cmd/goss/goss.go | 47 ++++-- docs/platform-feature-parity.md | 154 ++++++++++-------- .../goss/darwin/commands/help.goss.yaml | 9 + .../goss/windows/commands/add.goss.yaml | 11 ++ .../goss/windows/commands/autoadd.goss.yaml | 13 ++ .../goss/windows/commands/help.goss.yaml | 9 + .../goss/windows/commands/validate-input.yaml | 4 + .../goss/windows/commands/validate.goss.yaml | 12 ++ .../goss/windows/testdata/static-file.txt | 1 + .../goss/windows/tests/addr.goss.yaml | 10 ++ .../goss/windows/tests/command.goss.yaml | 10 ++ .../goss/windows/tests/dns.goss.yaml | 9 + .../goss/windows/tests/file.goss.yaml | 15 ++ .../goss/windows/tests/gossfile.goss.yaml | 19 +++ .../goss/windows/tests/group.goss.yaml | 6 + .../goss/windows/tests/http.goss.yaml | 16 ++ .../goss/windows/tests/interface.goss.yaml | 13 ++ .../windows/tests/kernel-param.na-goss.yaml | 6 + .../goss/windows/tests/mount.goss.yaml | 12 ++ .../goss/windows/tests/package.goss.yaml | 16 ++ .../goss/windows/tests/port.goss.yaml | 9 + .../goss/windows/tests/process.goss.yaml | 8 + .../goss/windows/tests/service.goss.yaml | 8 + .../goss/windows/tests/user.goss.yaml | 13 ++ integration-tests/run-tests-alpha.sh | 19 +++ 26 files changed, 374 insertions(+), 82 deletions(-) create mode 100644 integration-tests/goss/darwin/commands/help.goss.yaml create mode 100644 integration-tests/goss/windows/commands/add.goss.yaml create mode 100644 integration-tests/goss/windows/commands/autoadd.goss.yaml create mode 100644 integration-tests/goss/windows/commands/help.goss.yaml create mode 100644 integration-tests/goss/windows/commands/validate-input.yaml create mode 100644 integration-tests/goss/windows/commands/validate.goss.yaml create mode 100644 integration-tests/goss/windows/testdata/static-file.txt create mode 100644 integration-tests/goss/windows/tests/addr.goss.yaml create mode 100644 integration-tests/goss/windows/tests/command.goss.yaml create mode 100644 integration-tests/goss/windows/tests/dns.goss.yaml create mode 100644 integration-tests/goss/windows/tests/file.goss.yaml create mode 100644 integration-tests/goss/windows/tests/gossfile.goss.yaml create mode 100644 integration-tests/goss/windows/tests/group.goss.yaml create mode 100644 integration-tests/goss/windows/tests/http.goss.yaml create mode 100644 integration-tests/goss/windows/tests/interface.goss.yaml create mode 100644 integration-tests/goss/windows/tests/kernel-param.na-goss.yaml create mode 100644 integration-tests/goss/windows/tests/mount.goss.yaml create mode 100644 integration-tests/goss/windows/tests/package.goss.yaml create mode 100644 integration-tests/goss/windows/tests/port.goss.yaml create mode 100644 integration-tests/goss/windows/tests/process.goss.yaml create mode 100644 integration-tests/goss/windows/tests/service.goss.yaml create mode 100644 integration-tests/goss/windows/tests/user.goss.yaml create mode 100644 integration-tests/run-tests-alpha.sh diff --git a/ci/build.sh b/ci/build.sh index 8daf52e8e..1be88375f 100755 --- a/ci/build.sh +++ b/ci/build.sh @@ -5,8 +5,13 @@ os_name="${1:?"No value from TRAVIS_OS_NAME in 1st arg. This is meant to be run # darwin & windows do not support integration-testing approach via docker, so on those, just run fast tests. # linux runs all tests; unit and integration. -if [[ "${os_name}" == "windows" || "${os_name}" == "osx" ]]; then +if [[ "${os_name}" == "osx" ]]; then make test-short-all + # darwin is the GOOS value which is easier to work with + integration-tests/run-tests-alpha.sh "darwin" +elif [[ "${os_name}" == "windows" ]]; then + make test-short-all + integration-tests/run-tests-alpha.sh "windows" else make all fi diff --git a/cmd/goss/goss.go b/cmd/goss/goss.go index 53302ef18..8275e1840 100644 --- a/cmd/goss/goss.go +++ b/cmd/goss/goss.go @@ -132,6 +132,7 @@ func main() { }, }, Action: func(c *cli.Context) error { + fatalAlphaIfNeeded(c) code, err := goss.Validate(newRuntimeConfigFromCLI(c), startTime) if err != nil { color.Red(fmt.Sprintf("Error: %v\n", err)) @@ -183,6 +184,7 @@ func main() { }, }, Action: func(c *cli.Context) error { + fatalAlphaIfNeeded(c) goss.Serve(newRuntimeConfigFromCLI(c)) return nil }, @@ -198,6 +200,7 @@ func main() { }, }, Action: func(c *cli.Context) error { + fatalAlphaIfNeeded(c) j, err := goss.RenderJSON(newRuntimeConfigFromCLI(c)) if err != nil { return err @@ -213,6 +216,7 @@ func main() { Aliases: []string{"aa"}, Usage: "automatically add all matching resource to the test suite", Action: func(c *cli.Context) error { + fatalAlphaIfNeeded(c) return goss.AutoAddResources(c.GlobalString("gossfile"), c.Args(), newRuntimeConfigFromCLI(c)) }, }, @@ -231,6 +235,7 @@ func main() { Name: "package", Usage: "add new package", Action: func(c *cli.Context) error { + fatalAlphaIfNeeded(c) return goss.AddResources(c.GlobalString("gossfile"), "Package", c.Args(), newRuntimeConfigFromCLI(c)) }, }, @@ -238,6 +243,7 @@ func main() { Name: "file", Usage: "add new file", Action: func(c *cli.Context) error { + fatalAlphaIfNeeded(c) return goss.AddResources(c.GlobalString("gossfile"), "File", c.Args(), newRuntimeConfigFromCLI(c)) }, }, @@ -251,6 +257,7 @@ func main() { }, }, Action: func(c *cli.Context) error { + fatalAlphaIfNeeded(c) return goss.AddResources(c.GlobalString("gossfile"), "Addr", c.Args(), newRuntimeConfigFromCLI(c)) }, }, @@ -258,6 +265,7 @@ func main() { Name: "port", Usage: "add new listening [protocol]:port - ex: 80 or udp:123", Action: func(c *cli.Context) error { + fatalAlphaIfNeeded(c) return goss.AddResources(c.GlobalString("gossfile"), "Port", c.Args(), newRuntimeConfigFromCLI(c)) }, }, @@ -265,6 +273,7 @@ func main() { Name: "service", Usage: "add new service", Action: func(c *cli.Context) error { + fatalAlphaIfNeeded(c) return goss.AddResources(c.GlobalString("gossfile"), "Service", c.Args(), newRuntimeConfigFromCLI(c)) }, }, @@ -272,6 +281,7 @@ func main() { Name: "user", Usage: "add new user", Action: func(c *cli.Context) error { + fatalAlphaIfNeeded(c) return goss.AddResources(c.GlobalString("gossfile"), "User", c.Args(), newRuntimeConfigFromCLI(c)) }, }, @@ -279,6 +289,7 @@ func main() { Name: "group", Usage: "add new group", Action: func(c *cli.Context) error { + fatalAlphaIfNeeded(c) return goss.AddResources(c.GlobalString("gossfile"), "Group", c.Args(), newRuntimeConfigFromCLI(c)) }, }, @@ -292,6 +303,7 @@ func main() { }, }, Action: func(c *cli.Context) error { + fatalAlphaIfNeeded(c) return goss.AddResources(c.GlobalString("gossfile"), "Command", c.Args(), newRuntimeConfigFromCLI(c)) }, }, @@ -309,6 +321,7 @@ func main() { }, }, Action: func(c *cli.Context) error { + fatalAlphaIfNeeded(c) return goss.AddResources(c.GlobalString("gossfile"), "DNS", c.Args(), newRuntimeConfigFromCLI(c)) }, }, @@ -316,6 +329,7 @@ func main() { Name: "process", Usage: "add new process name", Action: func(c *cli.Context) error { + fatalAlphaIfNeeded(c) return goss.AddResources(c.GlobalString("gossfile"), "Process", c.Args(), newRuntimeConfigFromCLI(c)) }, }, @@ -343,6 +357,7 @@ func main() { }, }, Action: func(c *cli.Context) error { + fatalAlphaIfNeeded(c) return goss.AddResources(c.GlobalString("gossfile"), "HTTP", c.Args(), newRuntimeConfigFromCLI(c)) }, }, @@ -350,6 +365,7 @@ func main() { Name: "goss", Usage: "add new goss file, it will be imported from this one", Action: func(c *cli.Context) error { + fatalAlphaIfNeeded(c) return goss.AddResources(c.GlobalString("gossfile"), "Gossfile", c.Args(), newRuntimeConfigFromCLI(c)) }, @@ -358,6 +374,7 @@ func main() { Name: "kernel-param", Usage: "add new goss kernel param", Action: func(c *cli.Context) error { + fatalAlphaIfNeeded(c) return goss.AddResources(c.GlobalString("gossfile"), "KernelParam", c.Args(), newRuntimeConfigFromCLI(c)) }, }, @@ -365,6 +382,7 @@ func main() { Name: "mount", Usage: "add new mount", Action: func(c *cli.Context) error { + fatalAlphaIfNeeded(c) return goss.AddResources(c.GlobalString("gossfile"), "Mount", c.Args(), newRuntimeConfigFromCLI(c)) }, }, @@ -372,6 +390,7 @@ func main() { Name: "interface", Usage: "add new interface", Action: func(c *cli.Context) error { + fatalAlphaIfNeeded(c) return goss.AddResources(c.GlobalString("gossfile"), "Interface", c.Args(), newRuntimeConfigFromCLI(c)) }, }, @@ -379,8 +398,8 @@ func main() { }, } + addAlphaFlagIfNeeded(app) warnAlphaIfNeeded() - fatalAlphaIfNeeded() err := app.Run(os.Args) if err != nil { log.Fatal(err) @@ -388,6 +407,17 @@ func main() { warnAlphaIfNeeded() } +func addAlphaFlagIfNeeded(app *cli.App) { + if runtime.GOOS == "darwin" || runtime.GOOS == "windows" { + app.Flags = append(app.Flags, cli.StringFlag{ + Name: "use-alpha", + Usage: fmt.Sprintf("goss is alpha-quality. Set to 1 to use anyway."), + EnvVar: "GOSS_USE_ALPHA", + Value: "0", + }) + } +} + const msgFormat string = `WARNING: goss on %q is alpha-quality, work-in-progress, and not yet exercised within continuous integration. You should not expect everything to work. Treat linux as the canonical behaviour to expect. @@ -402,20 +432,17 @@ func warnAlphaIfNeeded() { } } -func fatalAlphaIfNeeded() { - if runtime.GOOS == "darwin" || runtime.GOOS == "windows" { +func fatalAlphaIfNeeded(c *cli.Context) { + if c.GlobalString("use-alpha") != "1" { howto := map[string]string{ - "darwin": "export GOSS_ALPHA=1", - "windows": "In cmd: set GOSS_ALPHA=1\nIn powershell: $env:GOSS_ALPHA=1\nIn bash: export GOSS_ALPHA=1", + "darwin": "export GOSS_USE_ALPHA=1", + "windows": "In cmd: set GOSS_USE_ALPHA=1\nIn powershell: $env:GOSS_USE_ALPHA=1\nIn bash: export GOSS_USE_ALPHA=1", } - val, found := os.LookupEnv("GOSS_ALPHA") - if !found || val != "1" { - log.Printf(`Terminating. + log.Printf(`Terminating. To bypass this and use the binary anyway: %s`, howto[runtime.GOOS]) - os.Exit(1) - } + os.Exit(1) } } diff --git a/docs/platform-feature-parity.md b/docs/platform-feature-parity.md index f7e0fef52..058b7200e 100644 --- a/docs/platform-feature-parity.md +++ b/docs/platform-feature-parity.md @@ -10,7 +10,10 @@ This matrix attempts to track parity across platforms. * `x` - full supported/tested * `w` - full working/tested, community support +* `wp-pt` - works partially / partially tested + * this is ambiguous; where you see this, check into the test coverage within `integration-tests/goss/{darwin|windows}/{test}.goss.yaml` for more detail. It might be that not all features work as on `linux`, it might be that not all features are covered by automated tests. * `w-nt` - works no automated tests +* `ni` - not implemented / needs implementation * `n/a` - Not applicable for this platform * `#585` - Link to bug(s) for implementation, fixing * ` ` - (blank) - not yet tried, no data @@ -21,110 +24,119 @@ The current integration test approach is only appropriate for validating `linux` Validating `macOS` and `Windows` binaries requires adding coverage that runs on those platforms within Travis, but since Travis does not support containerised builds for either platform, assertions are limited to assert against the state of the CI hosts, where we're relying on that to predictable. +You can find goss-files that are used to populate this matrix within `integration-tests/goss/{darwin|windows}/{test}.goss.yaml`. Where a feature does note work the same as linux, it is commented. The intent is to end up with a set of running-and-passing tests. + ## Matrix - tests/assertions | Test | `linux` | `macOS` | `Windows` | |:--------------------|---------|---------|-----------| -| **addr** | x | | | -| reachable | x | | | -| local-address | x | | | -| timeout | x | | | +| **addr** | x | | wp-pt | +| reachable | x | | wp-pt | +| local-address | x | | wp-pt | +| timeout | x | | wp-pt | | | x | | | -| **command** | x | | | -| exit-status | x | | | -| stdout | x | | | -| stderr | x | | | -| timeout | x | | | +| **command** | x | | wp-pt | +| exit-status | x | | wp-pt | +| stdout | x | | wp-pt | +| stderr | x | | wp-pt | +| timeout | x | | wp-pt | | | x | | | -| **dns** | x | | | -| resolvable | x | | | -| addrs | x | | | -| server | x | | | -| timeout | x | | | -| **file** | x | | | -| exists | x | w-nt | w | +| **dns** | x | | wp-pt | +| resolvable | x | | wp-pt | +| addrs | x | | wp-pt | +| server | x | | wp-pt | +| timeout | x | | wp-pt | +| | | | | +| **file** | x | | wp-pt | +| exists | x | | w | | mode | x | | n/a | -| size | x | | | -| owner | x | #585 | n/a | -| group | x | #585 | n/a | -| filetype | x | | | -| contains | x | w-nt | w-nt | -| md5 | x | w-nt | w-nt | -| sha256 | x | w-nt | w-nt | -| linked-to | x | w-nt | w-nt | +| size | x | | wp-pt | +| owner | x | | n/a | +| group | x | | n/a | +| filetype | x | | wp-pt | +| contains | x | | wp-pt | +| md5 | x | | wp-pt | +| sha256 | x | | wp-pt | +| linked-to | x | | | | | x | | | -| **gossfile** | x | | | +| **gossfile** | x | | wp-pt | | | x | | | -| **group** | x | | | -| exists | x | | | -| gid | x | | | +| **group** | x | | ni | +| exists | x | | ni | +| gid | x | | n/a | | | x | | | -| **http** | x | | | -| status | x | | | -| allow-insecure | x | | | -| no-follow-redirects | x | | | -| timeout | x | | | -| request-headers | x | | | -| headers | x | | | -| body | x | | | -| username | x | | | -| password | x | | | -| **interface** | x | | | -| exists | x | | | -| addrs | x | | | -| mtu | x | | | +| **http** | x | | wp-pt | +| status | x | | wp-pt | +| allow-insecure | x | | wp-pt | +| no-follow-redirects | x | | wp-pt | +| timeout | x | | wp-pt | +| request-headers | x | | wp-pt | +| headers | x | | wp-pt | +| body | x | | wp-pt | +| username | x | | wp-pt | +| password | x | | wp-pt | +| | | | | +| **interface** | x | | ni | +| exists | x | | ni | +| addrs | x | | ni | +| mtu | x | | ni | | | x | | | -| **kernel-param** | x | | | -| value | x | | | +| **kernel-param** | x | | n/a | +| value | x | | n/a | | | x | | | -| **mount** | x | | | -| exists | x | | | -| opts | x | | | -| source | x | | | -| filesystem | x | | | -| usage | x | | | +| **mount** | x | | ni | +| exists | x | | ni | +| opts | x | | n/a | +| source | x | | n/a | +| filesystem | x | | ni | +| usage | x | | ni | | | x | | | | **matching** | x | | | | | x | | | -| **package** | x | | | -| installed | x | | | -| versions | x | | | +| **package** | x | | ni | +| installed | x | | ni | +| versions | x | | ni | | | x | | | -| **port** | x | | | -| listening | x | | | +| **port** | x | | ni | +| listening | x | | ni | | ip | x | | | | | x | | | -| **process** | x | | | -| running | x | | | +| **process** | x | | wp-pt | +| running | x | | wp-pt | | | x | | | -| **service** | x | | | -| enabled | x | | | -| running | x | | | +| **service** | x | | ni | +| enabled | x | | ni | +| running | x | | ni | | | x | | | -| **user** | x | | | -| exists | x | | | -| uid | x | | | -| gid | x | | | -| groups | x | | | -| home | x | | | -| shell | x | | | +| **user** | x | | ni | +| exists | x | | ni | +| uid | x | | n/a | +| gid | x | | n/a | +| groups | x | | ni | +| home | x | | ni | +| shell | x | | ni | ## Matrix - `command`s | Test | `linux` | `macOS` | `Windows` | |:-----------|---------|---------|-----------| -| `add` | x | | | +| `add` | x | | wp-pt | | `autoadd` | x | | | -| `help` | x | | | +| `help` | x | | wp-pt | | `render` | x | | | | `serve` | x | w-nt | | -| `validate` | x | w-nt | w-nt | +| `validate` | x | w-nt | wp-pt | ### `command` testing notes ### Command: `add` -Not yet tested. +#### Windows `add` + +```powershell +.\release\goss-alpha-windows-amd64.exe add command 'echo hello' +exec: "sh": executable file not found in %PATH% +``` ### Command: `autoadd` diff --git a/integration-tests/goss/darwin/commands/help.goss.yaml b/integration-tests/goss/darwin/commands/help.goss.yaml new file mode 100644 index 000000000..7af8f2740 --- /dev/null +++ b/integration-tests/goss/darwin/commands/help.goss.yaml @@ -0,0 +1,9 @@ +--- +command: + help: + exit-status: 0 + exec: "release/goss-alpha-darwin-amd64 help" + stdout: + - alpha + stderr: [] + timeout: 5000 diff --git a/integration-tests/goss/windows/commands/add.goss.yaml b/integration-tests/goss/windows/commands/add.goss.yaml new file mode 100644 index 000000000..180f690f9 --- /dev/null +++ b/integration-tests/goss/windows/commands/add.goss.yaml @@ -0,0 +1,11 @@ +--- +# TODO: coverage for the add {test} permutations +command: + "add addr 127.0.0.1": + exit-status: 0 + exec: release/goss-alpha-windows-amd64 --use-alpha=1 add addr 127.0.0.1 + stdout: + - "timeout: 500" + stderr: [] + timeout: 5000 + diff --git a/integration-tests/goss/windows/commands/autoadd.goss.yaml b/integration-tests/goss/windows/commands/autoadd.goss.yaml new file mode 100644 index 000000000..a7aeda9e9 --- /dev/null +++ b/integration-tests/goss/windows/commands/autoadd.goss.yaml @@ -0,0 +1,13 @@ +--- +command: + "autoadd Administrator": + exit-status: 0 + exec: "release/goss-alpha-windows-amd64 --use-alpha=1 autoadd Administrator" + stdout: + - 'user:' + - ' name: Administrator' + stderr: [] + timeout: 5000 + + # needs implementation + skip: true diff --git a/integration-tests/goss/windows/commands/help.goss.yaml b/integration-tests/goss/windows/commands/help.goss.yaml new file mode 100644 index 000000000..fb0c049c3 --- /dev/null +++ b/integration-tests/goss/windows/commands/help.goss.yaml @@ -0,0 +1,9 @@ +--- +command: + help: + exit-status: 0 + exec: "release/goss-alpha-windows-amd64 help" + stdout: + - alpha + stderr: [] + timeout: 5000 diff --git a/integration-tests/goss/windows/commands/validate-input.yaml b/integration-tests/goss/windows/commands/validate-input.yaml new file mode 100644 index 000000000..fc8770063 --- /dev/null +++ b/integration-tests/goss/windows/commands/validate-input.yaml @@ -0,0 +1,4 @@ +--- +file: + non-existent.txt: + exists: false diff --git a/integration-tests/goss/windows/commands/validate.goss.yaml b/integration-tests/goss/windows/commands/validate.goss.yaml new file mode 100644 index 000000000..8eca102a8 --- /dev/null +++ b/integration-tests/goss/windows/commands/validate.goss.yaml @@ -0,0 +1,12 @@ +--- +# TODO: coverage for the add {test} permutations +command: + "validate": + exit-status: 0 + exec: "release/goss-alpha-windows-amd64 --use-alpha=1 -g integration-tests/goss/windows/commands/validate-input.yaml validate" + stdout: + - 'Count: 1' + - 'Failed: 0' + - 'Skipped: 0' + stderr: [] + timeout: 5000 diff --git a/integration-tests/goss/windows/testdata/static-file.txt b/integration-tests/goss/windows/testdata/static-file.txt new file mode 100644 index 000000000..7c591551d --- /dev/null +++ b/integration-tests/goss/windows/testdata/static-file.txt @@ -0,0 +1 @@ +nothing to see here diff --git a/integration-tests/goss/windows/tests/addr.goss.yaml b/integration-tests/goss/windows/tests/addr.goss.yaml new file mode 100644 index 000000000..6377a0fbc --- /dev/null +++ b/integration-tests/goss/windows/tests/addr.goss.yaml @@ -0,0 +1,10 @@ +--- +addr: + tcp://google.com:443: + reachable: true + timeout: 1000 + + tcp://127.0.0.1:135: + reachable: true + timeout: 1000 + local-address: true diff --git a/integration-tests/goss/windows/tests/command.goss.yaml b/integration-tests/goss/windows/tests/command.goss.yaml new file mode 100644 index 000000000..6fba37ecc --- /dev/null +++ b/integration-tests/goss/windows/tests/command.goss.yaml @@ -0,0 +1,10 @@ +--- +command: + hello world: + exit-status: 0 + exec: "echo hello world" + stdout: + - hello world + stderr: [] + timeout: 10000 + skip: false diff --git a/integration-tests/goss/windows/tests/dns.goss.yaml b/integration-tests/goss/windows/tests/dns.goss.yaml new file mode 100644 index 000000000..c9716cfce --- /dev/null +++ b/integration-tests/goss/windows/tests/dns.goss.yaml @@ -0,0 +1,9 @@ +--- +dns: + localhost: + resolvable: true + addrs: + - "127.0.0.1" + - ::1 + timeout: 500 + skip: false diff --git a/integration-tests/goss/windows/tests/file.goss.yaml b/integration-tests/goss/windows/tests/file.goss.yaml new file mode 100644 index 000000000..f41d982b7 --- /dev/null +++ b/integration-tests/goss/windows/tests/file.goss.yaml @@ -0,0 +1,15 @@ +--- +file: + integration-tests\goss\windows\testdata\static-file.txt: + exists: true + # mode: "0000" # not applicable on Windows + # user: "" # not applicable on Windows + # group: "" # not applicable on Windows + size: 21 + filetype: file + md5: dc9a07ca9789f866d21d544fe5651954 + sha256: aa8b1b4a0d9bf174f5019c8f8a9568858ee2bdf8e0ad16aec54417d49b48df49 + contains: + - "nothing to see here" + - "/nothing.*here/" + skip: false diff --git a/integration-tests/goss/windows/tests/gossfile.goss.yaml b/integration-tests/goss/windows/tests/gossfile.goss.yaml new file mode 100644 index 000000000..c1c6b1341 --- /dev/null +++ b/integration-tests/goss/windows/tests/gossfile.goss.yaml @@ -0,0 +1,19 @@ +--- +# paths are relative to the goss file that includes the gossfile directive. +gossfile: + addr.goss.yaml: {} + command.goss.yaml: {} + dns.goss.yaml: {} + file.goss.yaml: {} + # don't use gossfile; avoid self-referencing + # gossfile.goss.yaml: {} + group.goss.yaml: {} + http.goss.yaml: {} + interface.goss.yaml: {} + # kernel-param.na-goss.yaml: {} + mount.goss.yaml: {} + package.goss.yaml: {} + port.goss.yaml: {} + process.goss.yaml: {} + service.goss.yaml: {} + user.goss.yaml: {} diff --git a/integration-tests/goss/windows/tests/group.goss.yaml b/integration-tests/goss/windows/tests/group.goss.yaml new file mode 100644 index 000000000..b00e0fa5d --- /dev/null +++ b/integration-tests/goss/windows/tests/group.goss.yaml @@ -0,0 +1,6 @@ +--- +group: + 'Local Users': + exists: true + gid: 0 # not applicable on Windows + skip: true # TODO: implement on Windows diff --git a/integration-tests/goss/windows/tests/http.goss.yaml b/integration-tests/goss/windows/tests/http.goss.yaml new file mode 100644 index 000000000..69d1390f5 --- /dev/null +++ b/integration-tests/goss/windows/tests/http.goss.yaml @@ -0,0 +1,16 @@ +--- +http: + https://google.com: + status: 200 + allow-insecure: false + no-follow-redirects: false + timeout: 10000 + request-headers: + - "Content-Type: text/html" + headers: + - "Content-Type: text/html" + body: + - "google" + username: "" + password: "" + skip: false diff --git a/integration-tests/goss/windows/tests/interface.goss.yaml b/integration-tests/goss/windows/tests/interface.goss.yaml new file mode 100644 index 000000000..9c0c9b85c --- /dev/null +++ b/integration-tests/goss/windows/tests/interface.goss.yaml @@ -0,0 +1,13 @@ +--- +interface: + 'Loopback Pseudo-Interface 1': + exists: false + addrs: + - '127.0.0.1' + mtu: 1500 + skip: true + +# https://docs.microsoft.com/en-us/powershell/module/nettcpip/get-netipinterface?view=win10-ps +# Get-NetIPInterface +# https://docs.microsoft.com/en-us/powershell/module/netadapter/get-netadapter?view=win10-ps +# Get-NetAdapter - and would then need to choose one with a name that will work in CI, and skip this test when running locally, etc diff --git a/integration-tests/goss/windows/tests/kernel-param.na-goss.yaml b/integration-tests/goss/windows/tests/kernel-param.na-goss.yaml new file mode 100644 index 000000000..2575d1c06 --- /dev/null +++ b/integration-tests/goss/windows/tests/kernel-param.na-goss.yaml @@ -0,0 +1,6 @@ +--- +# Not applicable on Windows +kernel-param: + notapplicable.on-windows: + value: foobar + skip: true diff --git a/integration-tests/goss/windows/tests/mount.goss.yaml b/integration-tests/goss/windows/tests/mount.goss.yaml new file mode 100644 index 000000000..3d503a809 --- /dev/null +++ b/integration-tests/goss/windows/tests/mount.goss.yaml @@ -0,0 +1,12 @@ +--- +mount: + 'c:': + exists: true + filesystem: ntfs + + opts: [] # not applicable on Windows + source: '' # not applicable on Windows + usage: + lt: 95 + + skip: true # needs implementation diff --git a/integration-tests/goss/windows/tests/package.goss.yaml b/integration-tests/goss/windows/tests/package.goss.yaml new file mode 100644 index 000000000..48b790150 --- /dev/null +++ b/integration-tests/goss/windows/tests/package.goss.yaml @@ -0,0 +1,16 @@ +--- +package: + golang: + # required attributes + installed: true + # optional attributes + versions: + - 1.14.1 + + # needs implementation + # needs discussion + design + # support question for: + # * chocolatey https://chocolatey.org + # * scoop https://scoop.sh/ + # * winget-cli https://github.com/microsoft/winget-cli + skip: true diff --git a/integration-tests/goss/windows/tests/port.goss.yaml b/integration-tests/goss/windows/tests/port.goss.yaml new file mode 100644 index 000000000..f51fb778a --- /dev/null +++ b/integration-tests/goss/windows/tests/port.goss.yaml @@ -0,0 +1,9 @@ +--- +port: + tcp:135: + listening: true + ip: + - 0.0.0.0 + + # needs implementation + skip: true diff --git a/integration-tests/goss/windows/tests/process.goss.yaml b/integration-tests/goss/windows/tests/process.goss.yaml new file mode 100644 index 000000000..cf2e15132 --- /dev/null +++ b/integration-tests/goss/windows/tests/process.goss.yaml @@ -0,0 +1,8 @@ +--- +process: + explorer.exe: + running: true + + # note - must use .exe suffix on Windows currently + explorer: + running: false diff --git a/integration-tests/goss/windows/tests/service.goss.yaml b/integration-tests/goss/windows/tests/service.goss.yaml new file mode 100644 index 000000000..f29e31286 --- /dev/null +++ b/integration-tests/goss/windows/tests/service.goss.yaml @@ -0,0 +1,8 @@ +--- +service: + MSDTC: + enabled: true + running: true + + # needs implementation + skip: true diff --git a/integration-tests/goss/windows/tests/user.goss.yaml b/integration-tests/goss/windows/tests/user.goss.yaml new file mode 100644 index 000000000..96e89fde7 --- /dev/null +++ b/integration-tests/goss/windows/tests/user.goss.yaml @@ -0,0 +1,13 @@ +--- +user: + Administrator: + exists: true + uid: 65534 # not applicable on Windows + gid: 65534 # not applicable on Windows + groups: + - nfsnobody + home: /var/lib/nfs + shell: /sbin/nologin + + # needs implementation + skip: true diff --git a/integration-tests/run-tests-alpha.sh b/integration-tests/run-tests-alpha.sh new file mode 100644 index 000000000..1c89aa0c6 --- /dev/null +++ b/integration-tests/run-tests-alpha.sh @@ -0,0 +1,19 @@ +#!/usr/bin/env bash +set -euo pipefail + +os_name="${1:?Enter the OS name you want to run (windows|darwin)}" + +repo_root="$(git rev-parse --show-toplevel)" +export GOSS_BINARY="${repo_root}/release/goss-alpha-${os_name}-amd64" +echo "Using ${GOSS_BINARY}" +readarray -t goss_test_files < <(find integration-tests -type f -name "*.goss.yaml" | grep "${os_name}" | sort | uniq) + +export GOSS_USE_ALPHA=1 +for file in "${goss_test_files[@]}"; do + args=( + "-g=${file}" + "validate" + ) + echo -e "\nTesting \`${GOSS_BINARY} ${args[*]}\` ...\n" + "${GOSS_BINARY}" "${args[@]}" +done From 7bc01d7dbcff8dd6ef07a4b014276713408512b0 Mon Sep 17 00:00:00 2001 From: Peter Mounce Date: Sun, 24 May 2020 15:47:09 +0100 Subject: [PATCH 47/71] +x --- integration-tests/run-tests-alpha.sh | 0 1 file changed, 0 insertions(+), 0 deletions(-) mode change 100644 => 100755 integration-tests/run-tests-alpha.sh diff --git a/integration-tests/run-tests-alpha.sh b/integration-tests/run-tests-alpha.sh old mode 100644 new mode 100755 From 9a24740f180db454a61f1a4818454847618490a7 Mon Sep 17 00:00:00 2001 From: Peter Mounce Date: Sun, 24 May 2020 15:53:09 +0100 Subject: [PATCH 48/71] oops! --- cmd/goss/goss.go | 16 +++++++++------- 1 file changed, 9 insertions(+), 7 deletions(-) diff --git a/cmd/goss/goss.go b/cmd/goss/goss.go index 8275e1840..406624b1d 100644 --- a/cmd/goss/goss.go +++ b/cmd/goss/goss.go @@ -433,16 +433,18 @@ func warnAlphaIfNeeded() { } func fatalAlphaIfNeeded(c *cli.Context) { - if c.GlobalString("use-alpha") != "1" { - howto := map[string]string{ - "darwin": "export GOSS_USE_ALPHA=1", - "windows": "In cmd: set GOSS_USE_ALPHA=1\nIn powershell: $env:GOSS_USE_ALPHA=1\nIn bash: export GOSS_USE_ALPHA=1", - } - log.Printf(`Terminating. + if runtime.GOOS == "darwin" || runtime.GOOS == "windows" { + if c.GlobalString("use-alpha") != "1" { + howto := map[string]string{ + "darwin": "export GOSS_USE_ALPHA=1", + "windows": "In cmd: set GOSS_USE_ALPHA=1\nIn powershell: $env:GOSS_USE_ALPHA=1\nIn bash: export GOSS_USE_ALPHA=1", + } + log.Printf(`Terminating. To bypass this and use the binary anyway: %s`, howto[runtime.GOOS]) - os.Exit(1) + os.Exit(1) + } } } From 7a28410f1f2f0e2dc70974fb9472ca2d699e8786 Mon Sep 17 00:00:00 2001 From: Peter Mounce Date: Sun, 24 May 2020 15:56:34 +0100 Subject: [PATCH 49/71] debug --- ci/build.sh | 2 ++ 1 file changed, 2 insertions(+) diff --git a/ci/build.sh b/ci/build.sh index 1be88375f..21d962b33 100755 --- a/ci/build.sh +++ b/ci/build.sh @@ -7,10 +7,12 @@ os_name="${1:?"No value from TRAVIS_OS_NAME in 1st arg. This is meant to be run # linux runs all tests; unit and integration. if [[ "${os_name}" == "osx" ]]; then make test-short-all + pwd # darwin is the GOOS value which is easier to work with integration-tests/run-tests-alpha.sh "darwin" elif [[ "${os_name}" == "windows" ]]; then make test-short-all + pwd integration-tests/run-tests-alpha.sh "windows" else make all From b1f60f57f6a8685cdaa7a42fc9cdfd1dd1b3a125 Mon Sep 17 00:00:00 2001 From: Peter Mounce Date: Sun, 24 May 2020 16:02:58 +0100 Subject: [PATCH 50/71] bash and debug --- .travis.yml | 4 +++- integration-tests/run-tests-alpha.sh | 2 +- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/.travis.yml b/.travis.yml index fb9d97fed..c11701e28 100644 --- a/.travis.yml +++ b/.travis.yml @@ -19,7 +19,9 @@ services: - docker before_install: -- if [ "${TRAVIS_OS_NAME}" == "windows" ]; then choco install make; fi + - if [[ "${TRAVIS_OS_NAME}" == "windows" ]]; then choco install make; fi + # bash from macOS is too old to have readarray. Install newer version. + - if [[ "${TRAVIS_OS_NAME}" == "osx" ]]; then brew install bash; fi install: - ./ci/install.sh "${TRAVIS_OS_NAME}" diff --git a/integration-tests/run-tests-alpha.sh b/integration-tests/run-tests-alpha.sh index 1c89aa0c6..925c0a4d2 100755 --- a/integration-tests/run-tests-alpha.sh +++ b/integration-tests/run-tests-alpha.sh @@ -5,7 +5,7 @@ os_name="${1:?Enter the OS name you want to run (windows|darwin)}" repo_root="$(git rev-parse --show-toplevel)" export GOSS_BINARY="${repo_root}/release/goss-alpha-${os_name}-amd64" -echo "Using ${GOSS_BINARY}" +echo "Using: '${GOSS_BINARY}', cwd: '$(pwd)'" readarray -t goss_test_files < <(find integration-tests -type f -name "*.goss.yaml" | grep "${os_name}" | sort | uniq) export GOSS_USE_ALPHA=1 From cfa15840bef3a4c1ebb1cb15fa632adf8a6ed3c5 Mon Sep 17 00:00:00 2001 From: Peter Mounce Date: Mon, 25 May 2020 11:03:21 +0100 Subject: [PATCH 51/71] actually building the binary helps when running it! --- ci/build.sh | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/ci/build.sh b/ci/build.sh index 21d962b33..eceaca9b4 100755 --- a/ci/build.sh +++ b/ci/build.sh @@ -6,13 +6,11 @@ os_name="${1:?"No value from TRAVIS_OS_NAME in 1st arg. This is meant to be run # darwin & windows do not support integration-testing approach via docker, so on those, just run fast tests. # linux runs all tests; unit and integration. if [[ "${os_name}" == "osx" ]]; then - make test-short-all - pwd + make test-short-all release/goss-alpha-darwin-amd64 # darwin is the GOOS value which is easier to work with integration-tests/run-tests-alpha.sh "darwin" elif [[ "${os_name}" == "windows" ]]; then - make test-short-all - pwd + make test-short-all release/goss-alpha-windows-amd64 integration-tests/run-tests-alpha.sh "windows" else make all From 1e7aa4eb16baea2547cc2184d8df0e14ae4e1925 Mon Sep 17 00:00:00 2001 From: Peter Mounce Date: Mon, 25 May 2020 11:13:24 +0100 Subject: [PATCH 52/71] apparently it's not on travis --- integration-tests/goss/windows/tests/process.goss.yaml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/integration-tests/goss/windows/tests/process.goss.yaml b/integration-tests/goss/windows/tests/process.goss.yaml index cf2e15132..30cebb951 100644 --- a/integration-tests/goss/windows/tests/process.goss.yaml +++ b/integration-tests/goss/windows/tests/process.goss.yaml @@ -1,8 +1,8 @@ --- process: - explorer.exe: + 'wininit.exe': running: true # note - must use .exe suffix on Windows currently - explorer: + wininit: running: false From 9e94b49f35206447b53c5034f1ee9e48bbd3eb88 Mon Sep 17 00:00:00 2001 From: Peter Mounce Date: Mon, 25 May 2020 11:51:31 +0100 Subject: [PATCH 53/71] Darwin coverage --- .../goss/darwin/commands/add.goss.yaml | 11 +++++++++++ .../goss/darwin/commands/autoadd.goss.yaml | 13 +++++++++++++ .../goss/darwin/commands/validate-input.yaml | 4 ++++ .../goss/darwin/commands/validate.goss.yaml | 12 ++++++++++++ .../goss/darwin/tests/addr.goss.yaml | 10 ++++++++++ .../goss/darwin/tests/command.goss.yaml | 9 +++++++++ .../goss/darwin/tests/dns.goss.yaml | 8 ++++++++ .../goss/darwin/tests/file.goss.yaml | 14 ++++++++++++++ .../goss/darwin/tests/gossfile.goss.yaml | 19 +++++++++++++++++++ .../goss/darwin/tests/group.goss.yaml | 6 ++++++ .../goss/darwin/tests/http.goss.yaml | 15 +++++++++++++++ .../goss/darwin/tests/interface.goss.yaml | 8 ++++++++ .../goss/darwin/tests/kernel-param.goss.yaml | 6 ++++++ .../goss/darwin/tests/mount.goss.yaml | 12 ++++++++++++ .../goss/darwin/tests/package.goss.yaml | 15 +++++++++++++++ .../goss/darwin/tests/port.goss.yaml | 9 +++++++++ .../goss/darwin/tests/process.goss.yaml | 4 ++++ .../goss/darwin/tests/service.goss.yaml | 8 ++++++++ .../goss/darwin/tests/user.goss.yaml | 13 +++++++++++++ .../{windows => }/testdata/static-file.txt | 0 .../goss/windows/tests/command.goss.yaml | 1 - .../goss/windows/tests/dns.goss.yaml | 1 - .../goss/windows/tests/file.goss.yaml | 3 +-- .../goss/windows/tests/http.goss.yaml | 1 - 24 files changed, 197 insertions(+), 5 deletions(-) create mode 100644 integration-tests/goss/darwin/commands/add.goss.yaml create mode 100644 integration-tests/goss/darwin/commands/autoadd.goss.yaml create mode 100644 integration-tests/goss/darwin/commands/validate-input.yaml create mode 100644 integration-tests/goss/darwin/commands/validate.goss.yaml create mode 100644 integration-tests/goss/darwin/tests/addr.goss.yaml create mode 100644 integration-tests/goss/darwin/tests/command.goss.yaml create mode 100644 integration-tests/goss/darwin/tests/dns.goss.yaml create mode 100644 integration-tests/goss/darwin/tests/file.goss.yaml create mode 100644 integration-tests/goss/darwin/tests/gossfile.goss.yaml create mode 100644 integration-tests/goss/darwin/tests/group.goss.yaml create mode 100644 integration-tests/goss/darwin/tests/http.goss.yaml create mode 100644 integration-tests/goss/darwin/tests/interface.goss.yaml create mode 100644 integration-tests/goss/darwin/tests/kernel-param.goss.yaml create mode 100644 integration-tests/goss/darwin/tests/mount.goss.yaml create mode 100644 integration-tests/goss/darwin/tests/package.goss.yaml create mode 100644 integration-tests/goss/darwin/tests/port.goss.yaml create mode 100644 integration-tests/goss/darwin/tests/process.goss.yaml create mode 100644 integration-tests/goss/darwin/tests/service.goss.yaml create mode 100644 integration-tests/goss/darwin/tests/user.goss.yaml rename integration-tests/goss/{windows => }/testdata/static-file.txt (100%) diff --git a/integration-tests/goss/darwin/commands/add.goss.yaml b/integration-tests/goss/darwin/commands/add.goss.yaml new file mode 100644 index 000000000..4b532158e --- /dev/null +++ b/integration-tests/goss/darwin/commands/add.goss.yaml @@ -0,0 +1,11 @@ +--- +# TODO: coverage for the add {test} permutations +command: + "add addr 127.0.0.1": + exit-status: 0 + exec: release/goss-alpha-darwin-amd64 --use-alpha=1 add addr 127.0.0.1 + stdout: + - "timeout: 500" + stderr: [] + timeout: 5000 + diff --git a/integration-tests/goss/darwin/commands/autoadd.goss.yaml b/integration-tests/goss/darwin/commands/autoadd.goss.yaml new file mode 100644 index 000000000..09dda111b --- /dev/null +++ b/integration-tests/goss/darwin/commands/autoadd.goss.yaml @@ -0,0 +1,13 @@ +--- +command: + "autoadd travis": + exit-status: 0 + exec: "release/goss-alpha-darwin-amd64 --use-alpha=1 autoadd travis" + stdout: + - 'user:' + - ' name: travis' + stderr: [] + timeout: 5000 + + # needs implementation + # skip: true diff --git a/integration-tests/goss/darwin/commands/validate-input.yaml b/integration-tests/goss/darwin/commands/validate-input.yaml new file mode 100644 index 000000000..fc8770063 --- /dev/null +++ b/integration-tests/goss/darwin/commands/validate-input.yaml @@ -0,0 +1,4 @@ +--- +file: + non-existent.txt: + exists: false diff --git a/integration-tests/goss/darwin/commands/validate.goss.yaml b/integration-tests/goss/darwin/commands/validate.goss.yaml new file mode 100644 index 000000000..edf22cad6 --- /dev/null +++ b/integration-tests/goss/darwin/commands/validate.goss.yaml @@ -0,0 +1,12 @@ +--- +# TODO: coverage for the add {test} permutations +command: + "validate": + exit-status: 0 + exec: "release/goss-alpha-darwin-amd64 --use-alpha=1 -g integration-tests/goss/darwin/commands/validate-input.yaml validate" + stdout: + - 'Count: 1' + - 'Failed: 0' + - 'Skipped: 0' + stderr: [] + timeout: 5000 diff --git a/integration-tests/goss/darwin/tests/addr.goss.yaml b/integration-tests/goss/darwin/tests/addr.goss.yaml new file mode 100644 index 000000000..6377a0fbc --- /dev/null +++ b/integration-tests/goss/darwin/tests/addr.goss.yaml @@ -0,0 +1,10 @@ +--- +addr: + tcp://google.com:443: + reachable: true + timeout: 1000 + + tcp://127.0.0.1:135: + reachable: true + timeout: 1000 + local-address: true diff --git a/integration-tests/goss/darwin/tests/command.goss.yaml b/integration-tests/goss/darwin/tests/command.goss.yaml new file mode 100644 index 000000000..5110650e2 --- /dev/null +++ b/integration-tests/goss/darwin/tests/command.goss.yaml @@ -0,0 +1,9 @@ +--- +command: + hello world: + exit-status: 0 + exec: "echo hello world" + stdout: + - hello world + stderr: [] + timeout: 10000 diff --git a/integration-tests/goss/darwin/tests/dns.goss.yaml b/integration-tests/goss/darwin/tests/dns.goss.yaml new file mode 100644 index 000000000..a9a9cfa18 --- /dev/null +++ b/integration-tests/goss/darwin/tests/dns.goss.yaml @@ -0,0 +1,8 @@ +--- +dns: + localhost: + resolvable: true + addrs: + - "127.0.0.1" + - ::1 + timeout: 500 diff --git a/integration-tests/goss/darwin/tests/file.goss.yaml b/integration-tests/goss/darwin/tests/file.goss.yaml new file mode 100644 index 000000000..d3cc2f269 --- /dev/null +++ b/integration-tests/goss/darwin/tests/file.goss.yaml @@ -0,0 +1,14 @@ +--- +file: + integration-tests/goss/testdata/static-file.txt: + exists: true + mode: "0644" + # user: "" # TODO: not working on Darwin + # group: "" # TODO: not working on Darwin + size: 21 + filetype: file + md5: dc9a07ca9789f866d21d544fe5651954 + sha256: aa8b1b4a0d9bf174f5019c8f8a9568858ee2bdf8e0ad16aec54417d49b48df49 + contains: + - "nothing to see here" + - "/nothing.*here/" diff --git a/integration-tests/goss/darwin/tests/gossfile.goss.yaml b/integration-tests/goss/darwin/tests/gossfile.goss.yaml new file mode 100644 index 000000000..c1c6b1341 --- /dev/null +++ b/integration-tests/goss/darwin/tests/gossfile.goss.yaml @@ -0,0 +1,19 @@ +--- +# paths are relative to the goss file that includes the gossfile directive. +gossfile: + addr.goss.yaml: {} + command.goss.yaml: {} + dns.goss.yaml: {} + file.goss.yaml: {} + # don't use gossfile; avoid self-referencing + # gossfile.goss.yaml: {} + group.goss.yaml: {} + http.goss.yaml: {} + interface.goss.yaml: {} + # kernel-param.na-goss.yaml: {} + mount.goss.yaml: {} + package.goss.yaml: {} + port.goss.yaml: {} + process.goss.yaml: {} + service.goss.yaml: {} + user.goss.yaml: {} diff --git a/integration-tests/goss/darwin/tests/group.goss.yaml b/integration-tests/goss/darwin/tests/group.goss.yaml new file mode 100644 index 000000000..8e242c39b --- /dev/null +++ b/integration-tests/goss/darwin/tests/group.goss.yaml @@ -0,0 +1,6 @@ +--- +group: + _developers: + exists: true + gid: 0 + # skip: true diff --git a/integration-tests/goss/darwin/tests/http.goss.yaml b/integration-tests/goss/darwin/tests/http.goss.yaml new file mode 100644 index 000000000..3ba7b60e9 --- /dev/null +++ b/integration-tests/goss/darwin/tests/http.goss.yaml @@ -0,0 +1,15 @@ +--- +http: + https://google.com: + status: 200 + allow-insecure: false + no-follow-redirects: false + timeout: 10000 + request-headers: + - "Content-Type: text/html" + headers: + - "Content-Type: text/html" + body: + - "google" + username: "" + password: "" diff --git a/integration-tests/goss/darwin/tests/interface.goss.yaml b/integration-tests/goss/darwin/tests/interface.goss.yaml new file mode 100644 index 000000000..7be3671ba --- /dev/null +++ b/integration-tests/goss/darwin/tests/interface.goss.yaml @@ -0,0 +1,8 @@ +--- +interface: + eth0: + exists: true + addrs: + - '127.0.0.1' + mtu: 1500 + # skip: true diff --git a/integration-tests/goss/darwin/tests/kernel-param.goss.yaml b/integration-tests/goss/darwin/tests/kernel-param.goss.yaml new file mode 100644 index 000000000..1d9c6788e --- /dev/null +++ b/integration-tests/goss/darwin/tests/kernel-param.goss.yaml @@ -0,0 +1,6 @@ +--- +# Not applicable on Windows +kernel-param: + notapplicable.on-darwin: + value: foobar + # skip: true diff --git a/integration-tests/goss/darwin/tests/mount.goss.yaml b/integration-tests/goss/darwin/tests/mount.goss.yaml new file mode 100644 index 000000000..5c7f41509 --- /dev/null +++ b/integration-tests/goss/darwin/tests/mount.goss.yaml @@ -0,0 +1,12 @@ +--- +mount: + '/': + exists: true + filesystem: hdfs + + opts: [] + source: '' + usage: + lt: 95 + + # skip: true # needs implementation diff --git a/integration-tests/goss/darwin/tests/package.goss.yaml b/integration-tests/goss/darwin/tests/package.goss.yaml new file mode 100644 index 000000000..b89fd8a40 --- /dev/null +++ b/integration-tests/goss/darwin/tests/package.goss.yaml @@ -0,0 +1,15 @@ +--- +package: + golang: + # required attributes + installed: true + # optional attributes + versions: + - 1.14.1 + + # needs implementation + # needs discussion + design + # support question for: + # * homebrew + # * macports + skip: true diff --git a/integration-tests/goss/darwin/tests/port.goss.yaml b/integration-tests/goss/darwin/tests/port.goss.yaml new file mode 100644 index 000000000..1ef2e92e9 --- /dev/null +++ b/integration-tests/goss/darwin/tests/port.goss.yaml @@ -0,0 +1,9 @@ +--- +port: + tcp:135: + listening: true + ip: + - 0.0.0.0 + + # needs implementation + # skip: true diff --git a/integration-tests/goss/darwin/tests/process.goss.yaml b/integration-tests/goss/darwin/tests/process.goss.yaml new file mode 100644 index 000000000..97db8f590 --- /dev/null +++ b/integration-tests/goss/darwin/tests/process.goss.yaml @@ -0,0 +1,4 @@ +--- +process: + bash: + running: true diff --git a/integration-tests/goss/darwin/tests/service.goss.yaml b/integration-tests/goss/darwin/tests/service.goss.yaml new file mode 100644 index 000000000..aadb18a6f --- /dev/null +++ b/integration-tests/goss/darwin/tests/service.goss.yaml @@ -0,0 +1,8 @@ +--- +service: + launchd: + enabled: true + running: true + + # needs implementation + skip: true diff --git a/integration-tests/goss/darwin/tests/user.goss.yaml b/integration-tests/goss/darwin/tests/user.goss.yaml new file mode 100644 index 000000000..4a93fcd72 --- /dev/null +++ b/integration-tests/goss/darwin/tests/user.goss.yaml @@ -0,0 +1,13 @@ +--- +user: + travis: + exists: true + uid: 65534 + gid: 65534 + groups: + - _developers + home: /Users/travis + shell: /sbin/nologin + + # needs implementation + skip: false diff --git a/integration-tests/goss/windows/testdata/static-file.txt b/integration-tests/goss/testdata/static-file.txt similarity index 100% rename from integration-tests/goss/windows/testdata/static-file.txt rename to integration-tests/goss/testdata/static-file.txt diff --git a/integration-tests/goss/windows/tests/command.goss.yaml b/integration-tests/goss/windows/tests/command.goss.yaml index 6fba37ecc..5110650e2 100644 --- a/integration-tests/goss/windows/tests/command.goss.yaml +++ b/integration-tests/goss/windows/tests/command.goss.yaml @@ -7,4 +7,3 @@ command: - hello world stderr: [] timeout: 10000 - skip: false diff --git a/integration-tests/goss/windows/tests/dns.goss.yaml b/integration-tests/goss/windows/tests/dns.goss.yaml index c9716cfce..a9a9cfa18 100644 --- a/integration-tests/goss/windows/tests/dns.goss.yaml +++ b/integration-tests/goss/windows/tests/dns.goss.yaml @@ -6,4 +6,3 @@ dns: - "127.0.0.1" - ::1 timeout: 500 - skip: false diff --git a/integration-tests/goss/windows/tests/file.goss.yaml b/integration-tests/goss/windows/tests/file.goss.yaml index f41d982b7..80f1b7508 100644 --- a/integration-tests/goss/windows/tests/file.goss.yaml +++ b/integration-tests/goss/windows/tests/file.goss.yaml @@ -1,6 +1,6 @@ --- file: - integration-tests\goss\windows\testdata\static-file.txt: + integration-tests\goss\testdata\static-file.txt: exists: true # mode: "0000" # not applicable on Windows # user: "" # not applicable on Windows @@ -12,4 +12,3 @@ file: contains: - "nothing to see here" - "/nothing.*here/" - skip: false diff --git a/integration-tests/goss/windows/tests/http.goss.yaml b/integration-tests/goss/windows/tests/http.goss.yaml index 69d1390f5..3ba7b60e9 100644 --- a/integration-tests/goss/windows/tests/http.goss.yaml +++ b/integration-tests/goss/windows/tests/http.goss.yaml @@ -13,4 +13,3 @@ http: - "google" username: "" password: "" - skip: false From 19d59148759028905d2c0ad30e8595d601cbaf32 Mon Sep 17 00:00:00 2001 From: Peter Mounce Date: Mon, 25 May 2020 12:01:40 +0100 Subject: [PATCH 54/71] fix --- integration-tests/goss/darwin/commands/autoadd.goss.yaml | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/integration-tests/goss/darwin/commands/autoadd.goss.yaml b/integration-tests/goss/darwin/commands/autoadd.goss.yaml index 09dda111b..38ccb70ce 100644 --- a/integration-tests/goss/darwin/commands/autoadd.goss.yaml +++ b/integration-tests/goss/darwin/commands/autoadd.goss.yaml @@ -2,12 +2,13 @@ command: "autoadd travis": exit-status: 0 - exec: "release/goss-alpha-darwin-amd64 --use-alpha=1 autoadd travis" + exec: "release/goss-alpha-darwin-amd64 --use-alpha=1 autoadd /Users/travis" stdout: - - 'user:' - - ' name: travis' + - 'file:' + - ' exists: true' + - ' filetype: directory' stderr: [] timeout: 5000 # needs implementation - # skip: true + skip: true From 926203f2161e54212d506b6e8d1e702e99c31c42 Mon Sep 17 00:00:00 2001 From: Peter Mounce Date: Mon, 25 May 2020 12:01:57 +0100 Subject: [PATCH 55/71] enable --- integration-tests/goss/darwin/commands/autoadd.goss.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/integration-tests/goss/darwin/commands/autoadd.goss.yaml b/integration-tests/goss/darwin/commands/autoadd.goss.yaml index 38ccb70ce..4d4f27790 100644 --- a/integration-tests/goss/darwin/commands/autoadd.goss.yaml +++ b/integration-tests/goss/darwin/commands/autoadd.goss.yaml @@ -11,4 +11,4 @@ command: timeout: 5000 # needs implementation - skip: true + skip: false From 9a4c64cd35700fd458526f91b25d6b1754aa44f1 Mon Sep 17 00:00:00 2001 From: Peter Mounce Date: Mon, 25 May 2020 12:02:19 +0100 Subject: [PATCH 56/71] rename --- integration-tests/goss/darwin/commands/autoadd.goss.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/integration-tests/goss/darwin/commands/autoadd.goss.yaml b/integration-tests/goss/darwin/commands/autoadd.goss.yaml index 4d4f27790..03e708a60 100644 --- a/integration-tests/goss/darwin/commands/autoadd.goss.yaml +++ b/integration-tests/goss/darwin/commands/autoadd.goss.yaml @@ -1,6 +1,6 @@ --- command: - "autoadd travis": + "autoadd /Users/travis": exit-status: 0 exec: "release/goss-alpha-darwin-amd64 --use-alpha=1 autoadd /Users/travis" stdout: From bc7eaa4e7db01173d9ad4812cd16cca3ed1d31b7 Mon Sep 17 00:00:00 2001 From: Peter Mounce Date: Mon, 25 May 2020 12:10:43 +0100 Subject: [PATCH 57/71] skip --- integration-tests/goss/darwin/commands/autoadd.goss.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/integration-tests/goss/darwin/commands/autoadd.goss.yaml b/integration-tests/goss/darwin/commands/autoadd.goss.yaml index 03e708a60..f2243cf92 100644 --- a/integration-tests/goss/darwin/commands/autoadd.goss.yaml +++ b/integration-tests/goss/darwin/commands/autoadd.goss.yaml @@ -11,4 +11,4 @@ command: timeout: 5000 # needs implementation - skip: false + skip: true From 94248a89cbcc2507d837e80b3d7210d2861f698f Mon Sep 17 00:00:00 2001 From: Peter Mounce Date: Mon, 25 May 2020 12:22:46 +0100 Subject: [PATCH 58/71] skip --- integration-tests/goss/darwin/tests/addr.goss.yaml | 1 + 1 file changed, 1 insertion(+) diff --git a/integration-tests/goss/darwin/tests/addr.goss.yaml b/integration-tests/goss/darwin/tests/addr.goss.yaml index 6377a0fbc..8ca0888be 100644 --- a/integration-tests/goss/darwin/tests/addr.goss.yaml +++ b/integration-tests/goss/darwin/tests/addr.goss.yaml @@ -8,3 +8,4 @@ addr: reachable: true timeout: 1000 local-address: true + skip: true # TODO: needs implementation (or figure out a likely listening port on macOS/travis) \ No newline at end of file From f4063212d147ee033225338584e1d7062b09f814 Mon Sep 17 00:00:00 2001 From: Peter Mounce Date: Mon, 25 May 2020 12:29:47 +0100 Subject: [PATCH 59/71] no skip --- integration-tests/goss/darwin/tests/addr.goss.yaml | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/integration-tests/goss/darwin/tests/addr.goss.yaml b/integration-tests/goss/darwin/tests/addr.goss.yaml index 8ca0888be..ec81f705e 100644 --- a/integration-tests/goss/darwin/tests/addr.goss.yaml +++ b/integration-tests/goss/darwin/tests/addr.goss.yaml @@ -4,8 +4,8 @@ addr: reachable: true timeout: 1000 - tcp://127.0.0.1:135: - reachable: true - timeout: 1000 - local-address: true - skip: true # TODO: needs implementation (or figure out a likely listening port on macOS/travis) \ No newline at end of file + # TODO: needs implementation (or figure out a likely listening port on macOS/travis) + # tcp://127.0.0.1:135: + # reachable: true + # timeout: 1000 + # local-address: true From d8042f39c049aa5cbb0d37028ded0055532d6cd8 Mon Sep 17 00:00:00 2001 From: Peter Mounce Date: Mon, 25 May 2020 12:40:10 +0100 Subject: [PATCH 60/71] adjust for darwin --- integration-tests/goss/darwin/tests/file.goss.yaml | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/integration-tests/goss/darwin/tests/file.goss.yaml b/integration-tests/goss/darwin/tests/file.goss.yaml index d3cc2f269..0f428a235 100644 --- a/integration-tests/goss/darwin/tests/file.goss.yaml +++ b/integration-tests/goss/darwin/tests/file.goss.yaml @@ -5,10 +5,10 @@ file: mode: "0644" # user: "" # TODO: not working on Darwin # group: "" # TODO: not working on Darwin - size: 21 + size: 20 filetype: file - md5: dc9a07ca9789f866d21d544fe5651954 - sha256: aa8b1b4a0d9bf174f5019c8f8a9568858ee2bdf8e0ad16aec54417d49b48df49 + md5: 9dcea4037b1439a2a96e4d206eda63a4 + sha256: e73d885411a52a0d29142e830e104e0cc9252fbb1dc3c92a430ef7c369f089ef contains: - "nothing to see here" - "/nothing.*here/" From 2bd23c388b690ab7c883d84c989c93352cb0187d Mon Sep 17 00:00:00 2001 From: Peter Mounce Date: Mon, 25 May 2020 21:36:54 +0100 Subject: [PATCH 61/71] skip the not-working bits --- integration-tests/goss/darwin/commands/add.goss.yaml | 1 - integration-tests/goss/darwin/tests/group.goss.yaml | 4 +++- integration-tests/goss/darwin/tests/interface.goss.yaml | 4 +++- integration-tests/goss/darwin/tests/kernel-param.goss.yaml | 1 - integration-tests/goss/darwin/tests/mount.goss.yaml | 3 ++- integration-tests/goss/darwin/tests/port.goss.yaml | 4 ++-- integration-tests/goss/darwin/tests/service.goss.yaml | 2 +- integration-tests/goss/darwin/tests/user.goss.yaml | 4 ++-- 8 files changed, 13 insertions(+), 10 deletions(-) diff --git a/integration-tests/goss/darwin/commands/add.goss.yaml b/integration-tests/goss/darwin/commands/add.goss.yaml index 4b532158e..c07a27f90 100644 --- a/integration-tests/goss/darwin/commands/add.goss.yaml +++ b/integration-tests/goss/darwin/commands/add.goss.yaml @@ -8,4 +8,3 @@ command: - "timeout: 500" stderr: [] timeout: 5000 - diff --git a/integration-tests/goss/darwin/tests/group.goss.yaml b/integration-tests/goss/darwin/tests/group.goss.yaml index 8e242c39b..78411bcec 100644 --- a/integration-tests/goss/darwin/tests/group.goss.yaml +++ b/integration-tests/goss/darwin/tests/group.goss.yaml @@ -3,4 +3,6 @@ group: _developers: exists: true gid: 0 - # skip: true + + # TODO: needs implementation + skip: true diff --git a/integration-tests/goss/darwin/tests/interface.goss.yaml b/integration-tests/goss/darwin/tests/interface.goss.yaml index 7be3671ba..1b37596d1 100644 --- a/integration-tests/goss/darwin/tests/interface.goss.yaml +++ b/integration-tests/goss/darwin/tests/interface.goss.yaml @@ -5,4 +5,6 @@ interface: addrs: - '127.0.0.1' mtu: 1500 - # skip: true + + # TODO: needs implementation + skip: true diff --git a/integration-tests/goss/darwin/tests/kernel-param.goss.yaml b/integration-tests/goss/darwin/tests/kernel-param.goss.yaml index 1d9c6788e..20621e3ac 100644 --- a/integration-tests/goss/darwin/tests/kernel-param.goss.yaml +++ b/integration-tests/goss/darwin/tests/kernel-param.goss.yaml @@ -1,5 +1,4 @@ --- -# Not applicable on Windows kernel-param: notapplicable.on-darwin: value: foobar diff --git a/integration-tests/goss/darwin/tests/mount.goss.yaml b/integration-tests/goss/darwin/tests/mount.goss.yaml index 5c7f41509..5345c26fa 100644 --- a/integration-tests/goss/darwin/tests/mount.goss.yaml +++ b/integration-tests/goss/darwin/tests/mount.goss.yaml @@ -9,4 +9,5 @@ mount: usage: lt: 95 - # skip: true # needs implementation + # TODO: needs implementation + skip: true diff --git a/integration-tests/goss/darwin/tests/port.goss.yaml b/integration-tests/goss/darwin/tests/port.goss.yaml index 1ef2e92e9..37e8f1007 100644 --- a/integration-tests/goss/darwin/tests/port.goss.yaml +++ b/integration-tests/goss/darwin/tests/port.goss.yaml @@ -5,5 +5,5 @@ port: ip: - 0.0.0.0 - # needs implementation - # skip: true + # TODO: needs implementation + skip: true diff --git a/integration-tests/goss/darwin/tests/service.goss.yaml b/integration-tests/goss/darwin/tests/service.goss.yaml index aadb18a6f..2e64e3413 100644 --- a/integration-tests/goss/darwin/tests/service.goss.yaml +++ b/integration-tests/goss/darwin/tests/service.goss.yaml @@ -4,5 +4,5 @@ service: enabled: true running: true - # needs implementation + # TODO: needs implementation skip: true diff --git a/integration-tests/goss/darwin/tests/user.goss.yaml b/integration-tests/goss/darwin/tests/user.goss.yaml index 4a93fcd72..4b764eb0d 100644 --- a/integration-tests/goss/darwin/tests/user.goss.yaml +++ b/integration-tests/goss/darwin/tests/user.goss.yaml @@ -9,5 +9,5 @@ user: home: /Users/travis shell: /sbin/nologin - # needs implementation - skip: false + # TODO: needs implementation + skip: true From 17d2a39bb5f96676faf680bacd33b639c895e7f7 Mon Sep 17 00:00:00 2001 From: Peter Mounce Date: Mon, 25 May 2020 21:41:18 +0100 Subject: [PATCH 62/71] Clarify wording, set support expectations --- cmd/goss/goss.go | 2 +- docs/platform-feature-parity.md | 4 +++- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/cmd/goss/goss.go b/cmd/goss/goss.go index 406624b1d..301d9f7ec 100644 --- a/cmd/goss/goss.go +++ b/cmd/goss/goss.go @@ -418,7 +418,7 @@ func addAlphaFlagIfNeeded(app *cli.App) { } } -const msgFormat string = `WARNING: goss on %q is alpha-quality, work-in-progress, and not yet exercised within continuous integration. +const msgFormat string = `WARNING: goss for this platform (%q) is alpha-quality, work-in-progress, and not yet exercised within continuous integration. You should not expect everything to work. Treat linux as the canonical behaviour to expect. diff --git a/docs/platform-feature-parity.md b/docs/platform-feature-parity.md index 058b7200e..6a52ee31f 100644 --- a/docs/platform-feature-parity.md +++ b/docs/platform-feature-parity.md @@ -1,6 +1,8 @@ # Platform feature-parity -macOS and Windows binaries are new and considered alpha-quality. Some functionality may be missing, some may be broken. (Enhancements and bug-reports welcome, please see [#551: Multi-OS support](https://github.com/aelsabbahy/goss/issues/551)) +macOS and Windows binaries are new and considered alpha-quality. Some functionality may be missing, some may be broken. (Enhancements and bug-reports welcome, please see [#551: Multi-OS support](https://github.com/aelsabbahy/goss/issues/551)). + +The macOS and Windows support is community driven; there is no commitment to adding features / fixing bugs for those platforms. [See thread](https://github.com/aelsabbahy/goss/pull/585#discussion_r429968540). This matrix attempts to track parity across platforms. From fae7f38de2cc6ae9e3ae1398e04e5901f088aae3 Mon Sep 17 00:00:00 2001 From: Peter Mounce Date: Mon, 25 May 2020 21:43:20 +0100 Subject: [PATCH 63/71] oops --- integration-tests/goss/darwin/tests/kernel-param.goss.yaml | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/integration-tests/goss/darwin/tests/kernel-param.goss.yaml b/integration-tests/goss/darwin/tests/kernel-param.goss.yaml index 20621e3ac..a32195ced 100644 --- a/integration-tests/goss/darwin/tests/kernel-param.goss.yaml +++ b/integration-tests/goss/darwin/tests/kernel-param.goss.yaml @@ -2,4 +2,6 @@ kernel-param: notapplicable.on-darwin: value: foobar - # skip: true + + # TODO: need implementation or signal no support on Darwin + skip: true From 92c20cf2da47e6d2bda853519a3dc51669f34752 Mon Sep 17 00:00:00 2001 From: Peter Mounce Date: Mon, 25 May 2020 21:49:48 +0100 Subject: [PATCH 64/71] n/a + docs --- docs/platform-feature-parity.md | 130 +++++++++--------- ...am.goss.yaml => kernel-param.na-goss.yaml} | 0 2 files changed, 65 insertions(+), 65 deletions(-) rename integration-tests/goss/darwin/tests/{kernel-param.goss.yaml => kernel-param.na-goss.yaml} (100%) diff --git a/docs/platform-feature-parity.md b/docs/platform-feature-parity.md index 6a52ee31f..8aaf0f27c 100644 --- a/docs/platform-feature-parity.md +++ b/docs/platform-feature-parity.md @@ -32,91 +32,91 @@ You can find goss-files that are used to populate this matrix within `integratio | Test | `linux` | `macOS` | `Windows` | |:--------------------|---------|---------|-----------| -| **addr** | x | | wp-pt | -| reachable | x | | wp-pt | +| **addr** | x | wp-pt | wp-pt | +| reachable | x | wp-pt | wp-pt | | local-address | x | | wp-pt | -| timeout | x | | wp-pt | +| timeout | x | w-nt | w-nt | | | x | | | -| **command** | x | | wp-pt | -| exit-status | x | | wp-pt | -| stdout | x | | wp-pt | -| stderr | x | | wp-pt | -| timeout | x | | wp-pt | +| **command** | x | wp-pt | wp-pt | +| exit-status | x | wp-pt | wp-pt | +| stdout | x | wp-pt | wp-pt | +| stderr | x | w-nt | w-nt | +| timeout | x | w-nt | w-nt | | | x | | | -| **dns** | x | | wp-pt | -| resolvable | x | | wp-pt | -| addrs | x | | wp-pt | +| **dns** | x | wp-pt | wp-pt | +| resolvable | x | wp-pt | wp-pt | +| addrs | x | wp-pt | wp-pt | | server | x | | wp-pt | -| timeout | x | | wp-pt | +| timeout | x | w-nt | wp-pt | | | | | | -| **file** | x | | wp-pt | -| exists | x | | w | -| mode | x | | n/a | -| size | x | | wp-pt | -| owner | x | | n/a | -| group | x | | n/a | -| filetype | x | | wp-pt | -| contains | x | | wp-pt | -| md5 | x | | wp-pt | -| sha256 | x | | wp-pt | +| **file** | x | wp-pt | wp-pt | +| exists | x | wp-pt | w | +| mode | x | wp-pt | n/a | +| size | x | wp-pt | wp-pt | +| owner | x | broken | n/a | +| group | x | broken | n/a | +| filetype | x | wp-pt | wp-pt | +| contains | x | wp-pt | wp-pt | +| md5 | x | wp-pt | wp-pt | +| sha256 | x | wp-pt | wp-pt | | linked-to | x | | | | | x | | | -| **gossfile** | x | | wp-pt | +| **gossfile** | x | wp-pt | wp-pt | | | x | | | -| **group** | x | | ni | -| exists | x | | ni | -| gid | x | | n/a | +| **group** | x | ni | ni | +| exists | x | ni | ni | +| gid | x | ni | n/a | | | x | | | -| **http** | x | | wp-pt | -| status | x | | wp-pt | -| allow-insecure | x | | wp-pt | -| no-follow-redirects | x | | wp-pt | -| timeout | x | | wp-pt | -| request-headers | x | | wp-pt | -| headers | x | | wp-pt | -| body | x | | wp-pt | -| username | x | | wp-pt | -| password | x | | wp-pt | +| **http** | x | wp-pt | wp-pt | +| status | x | wp-pt | wp-pt | +| allow-insecure | x | wp-pt | wp-pt | +| no-follow-redirects | x | wp-pt | wp-pt | +| timeout | x | w-nt | wp-pt | +| request-headers | x | wp-pt | wp-pt | +| headers | x | wp-pt | wp-pt | +| body | x | wp-pt | wp-pt | +| username | x | w-nt | wp-pt | +| password | x | w-nt | wp-pt | | | | | | -| **interface** | x | | ni | -| exists | x | | ni | -| addrs | x | | ni | -| mtu | x | | ni | +| **interface** | x | ni | ni | +| exists | x | ni | ni | +| addrs | x | ni | ni | +| mtu | x | ni | ni | | | x | | | -| **kernel-param** | x | | n/a | -| value | x | | n/a | +| **kernel-param** | x | n/a | n/a | +| value | x | n/a | n/a | | | x | | | -| **mount** | x | | ni | -| exists | x | | ni | -| opts | x | | n/a | -| source | x | | n/a | -| filesystem | x | | ni | -| usage | x | | ni | +| **mount** | x | ni | ni | +| exists | x | ni | ni | +| opts | x | ni | n/a | +| source | x | ni | n/a | +| filesystem | x | ni | ni | +| usage | x | ni | ni | | | x | | | | **matching** | x | | | | | x | | | -| **package** | x | | ni | -| installed | x | | ni | -| versions | x | | ni | +| **package** | x | ni | ni | +| installed | x | ni | ni | +| versions | x | ni | ni | | | x | | | -| **port** | x | | ni | -| listening | x | | ni | +| **port** | x | ni | ni | +| listening | x | ni | ni | | ip | x | | | | | x | | | -| **process** | x | | wp-pt | -| running | x | | wp-pt | +| **process** | x | wp-pt | wp-pt | +| running | x | wp-pt | wp-pt | | | x | | | -| **service** | x | | ni | -| enabled | x | | ni | -| running | x | | ni | +| **service** | x | ni | ni | +| enabled | x | ni | ni | +| running | x | ni | ni | | | x | | | -| **user** | x | | ni | -| exists | x | | ni | -| uid | x | | n/a | -| gid | x | | n/a | -| groups | x | | ni | -| home | x | | ni | -| shell | x | | ni | +| **user** | x | ni | ni | +| exists | x | ni | ni | +| uid | x | ni | n/a | +| gid | x | ni | n/a | +| groups | x | ni | ni | +| home | x | ni | ni | +| shell | x | ni | ni | ## Matrix - `command`s diff --git a/integration-tests/goss/darwin/tests/kernel-param.goss.yaml b/integration-tests/goss/darwin/tests/kernel-param.na-goss.yaml similarity index 100% rename from integration-tests/goss/darwin/tests/kernel-param.goss.yaml rename to integration-tests/goss/darwin/tests/kernel-param.na-goss.yaml From 43f631381555a00d910d023aaf939b3a1e57bd6f Mon Sep 17 00:00:00 2001 From: Peter Mounce Date: Mon, 25 May 2020 22:09:34 +0100 Subject: [PATCH 65/71] try to appease codeclimate --- system/file_posix.go | 33 ++++++++++++++++----------------- 1 file changed, 16 insertions(+), 17 deletions(-) diff --git a/system/file_posix.go b/system/file_posix.go index b0b6396f9..3c9757f61 100644 --- a/system/file_posix.go +++ b/system/file_posix.go @@ -10,27 +10,18 @@ import ( ) func (f *DefFile) Mode() (string, error) { - if err := f.setup(); err != nil { - return "", err - } - - fi, err := os.Lstat(f.realPath) + fi, err := f.getFileInfo() if err != nil { return "", err } - sys := fi.Sys() - stat := sys.(*syscall.Stat_t) + stat := fi.Sys().(*syscall.Stat_t) mode := fmt.Sprintf("%04o", (stat.Mode & 07777)) return mode, nil } func (f *DefFile) Owner() (string, error) { - if err := f.setup(); err != nil { - return "", err - } - - fi, err := os.Lstat(f.realPath) + fi, err := f.getFileInfo() if err != nil { return "", err } @@ -44,11 +35,7 @@ func (f *DefFile) Owner() (string, error) { } func (f *DefFile) Group() (string, error) { - if err := f.setup(); err != nil { - return "", err - } - - fi, err := os.Lstat(f.realPath) + fi, err := f.getFileInfo() if err != nil { return "", err } @@ -60,3 +47,15 @@ func (f *DefFile) Group() (string, error) { } return getGroupForGid(gid) } + +func (f *DefFile) getFileInfo() (os.FileInfo, error) { + if err := f.setup(); err != nil { + return nil, err + } + + fi, err := os.Lstat(f.realPath) + if err != nil { + return nil, err + } + return fi, nil +} From 50c8328cc947c95846b54e602fa4f4ff73fe9f93 Mon Sep 17 00:00:00 2001 From: Peter Mounce Date: Tue, 26 May 2020 10:04:32 +0100 Subject: [PATCH 66/71] Surely the codeclimate duplication gods approve now --- system/file_posix.go | 25 ++++++++++++++----------- 1 file changed, 14 insertions(+), 11 deletions(-) diff --git a/system/file_posix.go b/system/file_posix.go index 3c9757f61..ae06be3f8 100644 --- a/system/file_posix.go +++ b/system/file_posix.go @@ -10,23 +10,25 @@ import ( ) func (f *DefFile) Mode() (string, error) { - fi, err := f.getFileInfo() + mode, err := f.getFileInfo(func(fi os.FileInfo) string { + stat := fi.Sys().(*syscall.Stat_t) + return fmt.Sprintf("%04o", (stat.Mode & 07777)) + }) if err != nil { return "", err } - stat := fi.Sys().(*syscall.Stat_t) - mode := fmt.Sprintf("%04o", (stat.Mode & 07777)) return mode, nil } func (f *DefFile) Owner() (string, error) { - fi, err := f.getFileInfo() + uidS, err := f.getFileInfo(func(fi os.FileInfo) string { + return fmt.Sprint(fi.Sys().(*syscall.Stat_t).Uid) + }) if err != nil { return "", err } - uidS := fmt.Sprint(fi.Sys().(*syscall.Stat_t).Uid) uid, err := strconv.Atoi(uidS) if err != nil { return "", err @@ -35,12 +37,13 @@ func (f *DefFile) Owner() (string, error) { } func (f *DefFile) Group() (string, error) { - fi, err := f.getFileInfo() + gidS, err := f.getFileInfo(func(fi os.FileInfo) string { + return fmt.Sprint(fi.Sys().(*syscall.Stat_t).Gid) + }) if err != nil { return "", err } - gidS := fmt.Sprint(fi.Sys().(*syscall.Stat_t).Gid) gid, err := strconv.Atoi(gidS) if err != nil { return "", err @@ -48,14 +51,14 @@ func (f *DefFile) Group() (string, error) { return getGroupForGid(gid) } -func (f *DefFile) getFileInfo() (os.FileInfo, error) { +func (f *DefFile) getFileInfo(selectorFunc func(os.FileInfo) string) (string, error) { if err := f.setup(); err != nil { - return nil, err + return "", err } fi, err := os.Lstat(f.realPath) if err != nil { - return nil, err + return "", err } - return fi, nil + return selectorFunc(fi), nil } From 97c4250729eeaca91270c21f527403ddb5b2702e Mon Sep 17 00:00:00 2001 From: Peter Mounce Date: Tue, 26 May 2020 10:11:26 +0100 Subject: [PATCH 67/71] well, perhaps the gods like this one? --- cmd/goss/goss.go | 27 +++++++++++---------------- 1 file changed, 11 insertions(+), 16 deletions(-) diff --git a/cmd/goss/goss.go b/cmd/goss/goss.go index 301d9f7ec..9dda5919e 100644 --- a/cmd/goss/goss.go +++ b/cmd/goss/goss.go @@ -56,6 +56,13 @@ func newRuntimeConfigFromCLI(c *cli.Context) *util.Config { return cfg } +func timeoutFlag(value time.Duration) cli.DurationFlag { + return cli.DurationFlag{ + Name: "timeout", + Value: value, + } +} + func main() { startTime := time.Now() app := cli.NewApp() @@ -251,10 +258,7 @@ func main() { Name: "addr", Usage: "add new remote address:port - ex: google.com:80", Flags: []cli.Flag{ - cli.DurationFlag{ - Name: "timeout", - Value: 500 * time.Millisecond, - }, + timeoutFlag(500 * time.Millisecond), }, Action: func(c *cli.Context) error { fatalAlphaIfNeeded(c) @@ -297,10 +301,7 @@ func main() { Name: "command", Usage: "add new command", Flags: []cli.Flag{ - cli.DurationFlag{ - Name: "timeout", - Value: 10 * time.Second, - }, + timeoutFlag(10 * time.Second), }, Action: func(c *cli.Context) error { fatalAlphaIfNeeded(c) @@ -311,10 +312,7 @@ func main() { Name: "dns", Usage: "add new dns", Flags: []cli.Flag{ - cli.DurationFlag{ - Name: "timeout", - Value: 500 * time.Millisecond, - }, + timeoutFlag(500 * time.Millisecond), cli.StringFlag{ Name: "server", Usage: "The IP address of a DNS server to query", @@ -343,10 +341,7 @@ func main() { cli.BoolFlag{ Name: "no-follow-redirects, r", }, - cli.DurationFlag{ - Name: "timeout", - Value: 5 * time.Second, - }, + timeoutFlag(5 * time.Second), cli.StringFlag{ Name: "username, u", Usage: "Username for basic auth", From 143e895a09e35205a9a37a3a358adb1d0f8a4bcc Mon Sep 17 00:00:00 2001 From: Peter Mounce Date: Wed, 10 Jun 2020 10:05:16 +0100 Subject: [PATCH 68/71] Return -1 as 'not applicable' --- system/file_windows.go | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/system/file_windows.go b/system/file_windows.go index f9c97f8aa..5ab5e6795 100644 --- a/system/file_windows.go +++ b/system/file_windows.go @@ -3,13 +3,13 @@ package system func (f *DefFile) Mode() (string, error) { - return "0000", nil // TODO implement + return "-1", nil // not applicable on Windows } func (f *DefFile) Owner() (string, error) { - return getUserForUid(1000) + return "-1", nil // not applicable on Windows } func (f *DefFile) Group() (string, error) { - return getGroupForGid(1000) + return "-1", nil // not applicable on Windows } From 9ebab4ae5d6efc27b0e04a8c62e727832d9f7a28 Mon Sep 17 00:00:00 2001 From: Peter Mounce Date: Mon, 15 Jun 2020 20:59:23 +0100 Subject: [PATCH 69/71] Remember go env --- ci/after-build.sh | 2 +- ci/before-build.sh | 2 +- ci/build.sh | 14 +++++--------- ci/go-fmt.sh | 2 +- ci/install.sh | 6 +----- 5 files changed, 9 insertions(+), 17 deletions(-) diff --git a/ci/after-build.sh b/ci/after-build.sh index dbd798bed..8970a6375 100755 --- a/ci/after-build.sh +++ b/ci/after-build.sh @@ -1,7 +1,7 @@ #!/usr/bin/env bash set -euo pipefail -os_name="${1:?"No value from TRAVIS_OS_NAME in 1st arg. This is meant to be run in Travis CI, see also https://docs.travis-ci.com/user/environment-variables/#convenience-variables"}" +os_name="$(go env GOOS)" if [[ "${os_name}" != "windows" ]]; then ./cc-test-reporter after-build --exit-code "${TRAVIS_TEST_RESULT}" -d diff --git a/ci/before-build.sh b/ci/before-build.sh index ac74476e5..0c5475d4f 100755 --- a/ci/before-build.sh +++ b/ci/before-build.sh @@ -1,7 +1,7 @@ #!/usr/bin/env bash set -euo pipefail -os_name="${1:?"No value from TRAVIS_OS_NAME in 1st arg. This is meant to be run in Travis CI, see also https://docs.travis-ci.com/user/environment-variables/#convenience-variables"}" +os_name="$(go env GOOS)" if [[ "${os_name}" != "windows" ]]; then ./cc-test-reporter before-build diff --git a/ci/build.sh b/ci/build.sh index eceaca9b4..b97d2bd33 100755 --- a/ci/build.sh +++ b/ci/build.sh @@ -1,17 +1,13 @@ #!/usr/bin/env bash set -euo pipefail -os_name="${1:?"No value from TRAVIS_OS_NAME in 1st arg. This is meant to be run in Travis CI, see also https://docs.travis-ci.com/user/environment-variables/#convenience-variables"}" +os_name="$(go env GOOS)" # darwin & windows do not support integration-testing approach via docker, so on those, just run fast tests. -# linux runs all tests; unit and integration. -if [[ "${os_name}" == "osx" ]]; then - make test-short-all release/goss-alpha-darwin-amd64 - # darwin is the GOOS value which is easier to work with - integration-tests/run-tests-alpha.sh "darwin" -elif [[ "${os_name}" == "windows" ]]; then - make test-short-all release/goss-alpha-windows-amd64 - integration-tests/run-tests-alpha.sh "windows" +if [[ "${os_name}" == "darwin" || "${os_name}" == "windows" ]]; then + make test-short-all release/goss-alpha-${os_name}-amd64 + integration-tests/run-tests-alpha.sh "${os_name}" else + # linux runs all tests; unit and integration. make all fi diff --git a/ci/go-fmt.sh b/ci/go-fmt.sh index 46d0a2d7f..dd216ced8 100755 --- a/ci/go-fmt.sh +++ b/ci/go-fmt.sh @@ -1,7 +1,7 @@ #!/usr/bin/env bash set -euo pipefail -os_name="${TRAVIS_OS_NAME:?"No value from TRAVIS_OS_NAME. This is meant to be run in Travis CI, see also https://docs.travis-ci.com/user/environment-variables/#convenience-variables"}" +os_name="$(go env GOOS)" # gofmt must be on PATH command -v gofmt diff --git a/ci/install.sh b/ci/install.sh index a5bb6bbd5..c1cad7cff 100755 --- a/ci/install.sh +++ b/ci/install.sh @@ -1,11 +1,7 @@ #!/usr/bin/env bash set -euo pipefail -os_name="${1:?"No value from TRAVIS_OS_NAME in 1st arg. This is meant to be run in Travis CI, see also https://docs.travis-ci.com/user/environment-variables/#convenience-variables"}" -goos="${os_name}" -if [[ "${goos}" == "osx" ]]; then - goos="darwin" -fi +os_name="$(go env GOOS)" go get -u golang.org/x/lint/golint From ed0c66558c3db14ebe05ffd6ad35ec1f57335e22 Mon Sep 17 00:00:00 2001 From: Peter Mounce Date: Mon, 15 Jun 2020 21:07:40 +0100 Subject: [PATCH 70/71] oops --- ci/install.sh | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/ci/install.sh b/ci/install.sh index c1cad7cff..8dea0dab3 100755 --- a/ci/install.sh +++ b/ci/install.sh @@ -5,7 +5,7 @@ os_name="$(go env GOOS)" go get -u golang.org/x/lint/golint -if [[ "${goos}" != "windows" ]]; then - curl -L "https://codeclimate.com/downloads/test-reporter/test-reporter-latest-${goos}-amd64" > "./cc-test-reporter" +if [[ "${os_name}" != "windows" ]]; then + curl -L "https://codeclimate.com/downloads/test-reporter/test-reporter-latest-${os_name}-amd64" > "./cc-test-reporter" chmod +x "./cc-test-reporter" fi From 7a762a14270c789e9c08f7229acf2bc2abff8867 Mon Sep 17 00:00:00 2001 From: Peter Mounce Date: Mon, 15 Jun 2020 22:27:54 +0100 Subject: [PATCH 71/71] now unnecessary --- .travis.yml | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/.travis.yml b/.travis.yml index c11701e28..9ce3e6608 100644 --- a/.travis.yml +++ b/.travis.yml @@ -24,16 +24,16 @@ before_install: - if [[ "${TRAVIS_OS_NAME}" == "osx" ]]; then brew install bash; fi install: - - ./ci/install.sh "${TRAVIS_OS_NAME}" + - ./ci/install.sh before_script: - - ./ci/before-build.sh "${TRAVIS_OS_NAME}" + - ./ci/before-build.sh script: - - ./ci/build.sh "${TRAVIS_OS_NAME}" + - ./ci/build.sh after_script: - - ./ci/after-build.sh "${TRAVIS_OS_NAME}" + - ./ci/after-build.sh deploy: provider: releases