Skip to content

Commit

Permalink
Merge branch 'main' into patch-1
Browse files Browse the repository at this point in the history
  • Loading branch information
kensipe authored Nov 28, 2022
2 parents 09a3856 + 6f1ad38 commit e97b4eb
Show file tree
Hide file tree
Showing 41 changed files with 360 additions and 93 deletions.
22 changes: 22 additions & 0 deletions .github/workflows/e2e.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
name: "E2E tests"

on:
push:
branches: [ main ]
pull_request:
branches: [ main ]

jobs:
e2e-tests:
runs-on: ubuntu-20.04
steps:
- uses: actions/setup-go@v2.1.4
with:
go-version: 1.18
- uses: actions/checkout@v2.4.0
- name: "Install etcd"
run: ./hack/install-etcd.sh
- name: "Install kube-apiserver"
run: ./hack/install-kube-apiserver.sh
- name: "Run E2E tests"
run: make e2e-test INTEGRATION_OUTPUT_JUNIT="true"
22 changes: 22 additions & 0 deletions .github/workflows/integration-test.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
name: "Integration tests"

on:
push:
branches: [ main ]
pull_request:
branches: [ main ]

jobs:
integration-tests:
runs-on: ubuntu-20.04
steps:
- uses: actions/setup-go@v2.1.4
with:
go-version: 1.18
- uses: actions/checkout@v2.4.0
- name: "Install etcd"
run: ./hack/install-etcd.sh
- name: "Install kube-apiserver"
run: ./hack/install-kube-apiserver.sh
- name: "Run integration tests"
run: make integration-test INTEGRATION_OUTPUT_JUNIT="true"
22 changes: 22 additions & 0 deletions .github/workflows/lint.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
name: "Lint code"

on:
push:
branches: [ main ]
pull_request:
branches: [ main ]

jobs:
lint:
runs-on: ubuntu-20.04
steps:
- uses: actions/setup-go@v2.1.4
with:
go-version: 1.18
- uses: actions/checkout@v2.4.0
- name: "Lint the code"
run: make lint
- name: "Verify generate"
run: ./hack/verify-generate.sh
- name: "Verify go clean"
run: ./hack/verify-go-clean.sh
18 changes: 18 additions & 0 deletions .github/workflows/unittest.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
name: "Unit tests"

on:
push:
branches: [ main ]
pull_request:
branches: [ main ]

jobs:
unit-tests:
runs-on: ubuntu-latest
steps:
- uses: actions/setup-go@v2.1.4
with:
go-version: 1.18
- uses: actions/checkout@v2.4.0
- name: "Run unit tests"
run: make test
20 changes: 20 additions & 0 deletions .golangci.yml
Original file line number Diff line number Diff line change
@@ -1,25 +1,45 @@
linters:
auto-fix: false
enable:
- asasalint
- asciicheck
- bidichk
- bodyclose
- containedctx
- decorder
- dogsled
- durationcheck
- dupl
- errcheck
- errname
- exportloopref
- gochecknoinits
- goconst
- gocritic
- gocyclo
- gofmt
- goimports
- gosimple
- govet
- grouper
- importas
- ineffassign
- lll
- makezero
- misspell
- nakedret
- noctx
- nolintlint
- nosprintfhostport
- revive
- staticcheck
- stylecheck
- typecheck
- unconvert
- unparam
- unused
- wastedassign
- whitespace
run:
go: '1.17'
skip-dirs:
Expand Down
2 changes: 1 addition & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ BUILD_DATE_PATH := github.com/kudobuilder/kuttl/pkg/version.buildDate
DATE_FMT := "%Y-%m-%dT%H:%M:%SZ"
BUILD_DATE := $(shell date -u -d "@$SOURCE_DATE_EPOCH" "+${DATE_FMT}" 2>/dev/null || date -u -r "${SOURCE_DATE_EPOCH}" "+${DATE_FMT}" 2>/dev/null || date -u "+${DATE_FMT}")
LDFLAGS := -X ${GIT_VERSION_PATH}=${GIT_VERSION} -X ${GIT_COMMIT_PATH}=${GIT_COMMIT} -X ${BUILD_DATE_PATH}=${BUILD_DATE}
GOLANGCI_LINT_VER = "1.49.0"
GOLANGCI_LINT_VER = "1.50.1"

export GO111MODULE=on

Expand Down
52 changes: 52 additions & 0 deletions crds/testassert-json-schema.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -5,3 +5,55 @@ properties:
description: Number of seconds that the test is allowed to run for
type: integer
default: 30
collectors:
type: object
properties:
type:
type: string
description: Type of collector to run. Values are one of `pod`, `command`, or `events`. If the field named `command` is specified, `type` is assumed to be `command`. If the field named `pod` is specified, `type` is assumed to be `pod`.
default: pod
pod:
type: string
description: The pod name from which to access logs.
namespace:
type: string
description: Namespace in which the pod or events can be located.
container:
type: string
description: Container name inside the pod from which to fetch logs. If empty assumes all containers.
selector:
type: string
description: Label query to select a pod.
tail:
type: integer
description: The number of last lines to collect from a pod. If omitted or zero, then the default is 10 if you use a selector, or -1 (all) if you use a pod name. This matches default behavior of `kubectl logs`.
command:
type: string
description: Command to run. Requires an empty type or type `command`. Must not specify fields `pod`, `namespace`, `container`, or `selector` if present.
commands:
description: Commands is a set of commands to be run as assertions for the current step
type: array
items:
description: The TestAssertCommand object is used by TestAssert to enable running arbitrary commands in asserts
type: object
properties:
command:
description: The command and argument to run as a string.
type: string
script:
description: |
Allows a shell script to run
- namespaced and command should not be used with script.
- namespaced is ignored and command is an error.
- env expansion is depended upon the shell but ENV is passed to the runtime env.
type: string
namespaced:
description: |
If set, the --namespace flag will be appended to the command with the namespace to use
(the test namespace).
type: boolean
skipLogOutput:
description: |
If set, the output from the command is not logged.
Useful for sensitive logs or to reduce noise.
type: boolean
52 changes: 52 additions & 0 deletions crds/testassert_crd.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -21,3 +21,55 @@ spec:
description: Number of seconds that the test is allowed to run for
type: integer
default: 30
collectors:
type: object
properties:
type:
type: string
description: Type of collector to run. Values are one of `pod`, `command`, or `events`. If the field named `command` is specified, `type` is assumed to be `command`. If the field named `pod` is specified, `type` is assumed to be `pod`.
default: pod
pod:
type: string
description: The pod name from which to access logs.
namespace:
type: string
description: Namespace in which the pod or events can be located.
container:
type: string
description: Container name inside the pod from which to fetch logs. If empty assumes all containers.
selector:
type: string
description: Label query to select a pod.
tail:
type: integer
description: The number of last lines to collect from a pod. If omitted or zero, then the default is 10 if you use a selector, or -1 (all) if you use a pod name. This matches default behavior of `kubectl logs`.
command:
type: string
description: Command to run. Requires an empty type or type `command`. Must not specify fields `pod`, `namespace`, `container`, or `selector` if present.
commands:
description: Commands is a set of commands to be run as assertions for the current step
type: array
items:
description: The TestAssertCommand object is used by TestAssert to enable running arbitrary commands in asserts
type: object
properties:
command:
description: The command and argument to run as a string.
type: string
script:
description: |
Allows a shell script to run
- namespaced and command should not be used with script.
- namespaced is ignored and command is an error.
- env expansion is depended upon the shell but ENV is passed to the runtime env.
type: string
namespaced:
description: |
If set, the --namespace flag will be appended to the command with the namespace to use
(the test namespace).
type: boolean
skipLogOutput:
description: |
If set, the output from the command is not logged.
Useful for sensitive logs or to reduce noise.
type: boolean
23 changes: 21 additions & 2 deletions crds/teststep-json-schema.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -27,12 +27,28 @@ properties:
If specified, a label selector to use when looking up objects to delete.
If both labels and name are unspecified, then all resources of the specified kind in the namespace will be deleted.
type: object


apply:
type: array
description: A list of files to apply as part of this step. Specified path is relative to that in which the step occurs.
items:
type: string
assert:
type: array
description: A list of files to assert as part of this step. See documentation for [asserts and errors](asserts-errors.md) for more information. Specified path is relative to that in which the step occurs.
items:
type: string
error:
type: array
description: A list of files to error as part of this step. See documentation for [asserts and errors](asserts-errors.md) for more information. Specified path is relative to that in which the step occurs.
items:
type: string

index:
description: Override the test step's index.
type: integer
unitTest:
type: boolean
description: Indicates that this is a unit test - safe to run without a real Kubernetes cluster.
commands:
description: Commands to run prior at the beginning of the test step.
type: array
Expand Down Expand Up @@ -71,3 +87,6 @@ properties:
timeout:
description: Override the TestSuite timeout for this command (in seconds).
type: integer
kubeconfig:
type: string
description: Kubeconfig to use when applying and asserting for this step. Optional.
22 changes: 22 additions & 0 deletions crds/teststep_crd.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -43,9 +43,28 @@ spec:
If specified, a label selector to use when looking up objects to delete.
If both labels and name are unspecified, then all resources of the specified kind in the namespace will be deleted.
type: object
apply:
type: array
description: A list of files to apply as part of this step. Specified path is relative to that in which the step occurs.
items:
type: string
assert:
type: array
description: A list of files to assert as part of this step. See documentation for [asserts and errors](asserts-errors.md) for more information. Specified path is relative to that in which the step occurs.
items:
type: string
error:
type: array
description: A list of files to error as part of this step. See documentation for [asserts and errors](asserts-errors.md) for more information. Specified path is relative to that in which the step occurs.
items:
type: string

index:
description: Override the test step's index.
type: integer
unitTest:
type: boolean
description: Indicates that this is a unit test - safe to run without a real Kubernetes cluster.
commands:
description: Commands to run prior at the beginning of the test step.
type: array
Expand Down Expand Up @@ -84,3 +103,6 @@ spec:
timeout:
description: Override the TestSuite timeout for this command (in seconds).
type: integer
kubeconfig:
type: string
description: Kubeconfig to use when applying and asserting for this step. Optional.
2 changes: 1 addition & 1 deletion crds/testsuite-json-schema.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -105,7 +105,7 @@ properties:
type: string
reportName:
description: The name of report to create. This field is not used unless reportFormat is set.
default: "kuttl-test"
default: "kuttl-report"
type: string
namespace:
description: |
Expand Down
2 changes: 1 addition & 1 deletion crds/testsuite_crd.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -121,7 +121,7 @@ spec:
type: string
reportName:
description: The name of report to create. This field is not used unless reportFormat is set.
default: "kuttl-test"
default: "kuttl-report"
type: string
namespace:
description: |
Expand Down
1 change: 1 addition & 0 deletions hack/generate_krew.sh
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,7 @@ EOF

generate_platform linux amd64 ./kubectl-kuttl >> kuttl.yaml
generate_platform linux 386 ./kubectl-kuttl >> kuttl.yaml
generate_platform linux arm64 ./kubectl-kuttl >> kuttl.yaml
generate_platform darwin amd64 ./kubectl-kuttl >> kuttl.yaml
generate_platform darwin arm64 ./kubectl-kuttl >> kuttl.yaml

Expand Down
12 changes: 12 additions & 0 deletions hack/install-etcd.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
#!/usr/bin/env bash
echo Installing etcd

ETCD_VER=v3.3.11
DOWNLOAD_URL=https://github.com/etcd-io/etcd/releases/download

sudo mkdir -p /usr/local/kubebuilder/bin
sudo curl -L ${DOWNLOAD_URL}/${ETCD_VER}/etcd-${ETCD_VER}-linux-amd64.tar.gz -o /usr/local/kubebuilder/bin/etcd-${ETCD_VER}-linux-amd64.tar.gz
sudo tar xzvf /usr/local/kubebuilder/bin/etcd-${ETCD_VER}-linux-amd64.tar.gz -C /usr/local/kubebuilder/bin/ --strip-components=1
sudo chmod +x /usr/local/kubebuilder/bin/etcd

export PATH=$PATH:/usr/local/kubebuilder/bin
13 changes: 13 additions & 0 deletions hack/install-kube-apiserver.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
#!/usr/bin/env bash
echo Installing kube-apiserver

sudo mkdir -p /usr/local/kubebuilder/bin

sudo curl -L https://dl.k8s.io/v1.16.4/kubernetes-server-linux-amd64.tar.gz -o /usr/local/kubebuilder/bin/kubernetes-server-linux-amd64.tar.gz
sudo tar xzvf /usr/local/kubebuilder/bin/kubernetes-server-linux-amd64.tar.gz -C /usr/local/kubebuilder/bin/ --strip-components=1

sudo cp /usr/local/kubebuilder/bin/server/bin/kube-apiserver /usr/local/kubebuilder/bin

sudo chmod +x /usr/local/kubebuilder/bin/kube-apiserver

export PATH=$PATH:/usr/local/kubebuilder/bin
2 changes: 1 addition & 1 deletion hack/run-e2e-tests.sh
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ then
go get github.com/jstemmer/go-junit-report
go install github.com/jstemmer/go-junit-report
go mod tidy

./bin/kubectl-kuttl test pkg/test/test_data/ 2>&1 \
| tee /dev/fd/2 \
| go-junit-report -set-exit-code \
Expand Down
2 changes: 1 addition & 1 deletion pkg/apis/testharness/v1beta1/test_types.go
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ type TestSuite struct {
// maps to report.Type, however we don't want generated.deepcopy to have reference to it.
ReportFormat string `json:"reportFormat"`

// ReportName defines the name of report to create. It defaults to "kuttl-test" and is not used unless ReportFormat is defined.
// ReportName defines the name of report to create. It defaults to "kuttl-report" and is not used unless ReportFormat is defined.
ReportName string `json:"reportName"`
// Namespace defines the namespace to use for tests
// The value "" means to auto-generate tests namespaces, these namespaces will be created and removed for each test
Expand Down
Loading

0 comments on commit e97b4eb

Please sign in to comment.