Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions .fossa.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
version: 3

paths:
exclude:
- ./e2e
70 changes: 38 additions & 32 deletions .github/workflows/e2e.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,8 @@ jobs:
with:
context: .
tags: controller:local
cache-from: type=gha
cache-to: type=gha,mode=max
outputs: type=docker,dest=/tmp/controller.tar

- name: Upload artifact
Expand All @@ -39,6 +41,11 @@ jobs:
name: Go end2end tests
runs-on: ubuntu-latest
needs: build
strategy:
fail-fast: false
# matrix:
# SHARD: [0]
# SHARDS: [1]

steps:
- name: Set up Docker Buildx
Expand Down Expand Up @@ -68,11 +75,11 @@ jobs:
- name: Checkout code
uses: actions/checkout@v3

- name: Make docker-build
run: make docker-build

- name: Run e2e tests
run: make test-e2e
run: make test-e2e-ci
# env:
# SHARD: ${{ matrix.SHARD }}
# SHARDS: ${{ matrix.SHARDS }}

- name: Archive Test Results
if: always()
Expand All @@ -82,10 +89,14 @@ jobs:
path: build/_test
retention-days: 5

chart-minio:
chart:
name: Shell script tests with chart install
runs-on: ubuntu-latest
needs: build
strategy:
fail-fast: false
matrix:
kube: ["1.22", "1.23", "1.24", "1.25", "1.26", "1.27"]

steps:
- name: Set up Docker Buildx
Expand All @@ -102,11 +113,6 @@ jobs:
docker load --input /tmp/controller.tar
docker image ls -a

- name: Set up Go
uses: actions/setup-go@v4
with:
go-version: ${{ env.GO_VERSION }}

- name: Set up kubectl
uses: azure/setup-kubectl@v3
with:
Expand All @@ -115,31 +121,31 @@ jobs:
- name: Checkout code
uses: actions/checkout@v3

- name: Make docker-build
run: make docker-build
# See https://github.com/kubernetes-sigs/kind/releases/tag/v0.20.0
- name: Determine KinD node image version
id: node_image
run: |
case ${{ matrix.kube }} in
1.22)
NODE_IMAGE=kindest/node:v1.22.17@sha256:f5b2e5698c6c9d6d0adc419c0deae21a425c07d81bbf3b6a6834042f25d4fba2 ;;
1.23)
NODE_IMAGE=kindest/node:v1.23.17@sha256:59c989ff8a517a93127d4a536e7014d28e235fb3529d9fba91b3951d461edfdb ;;
1.24)
NODE_IMAGE=kindest/node:v1.24.15@sha256:7db4f8bea3e14b82d12e044e25e34bd53754b7f2b0e9d56df21774e6f66a70ab ;;
1.25)
NODE_IMAGE=kindest/node:v1.25.11@sha256:227fa11ce74ea76a0474eeefb84cb75d8dad1b08638371ecf0e86259b35be0c8 ;;
1.26)
NODE_IMAGE=kindest/node:v1.26.6@sha256:6e2d8b28a5b601defe327b98bd1c2d1930b49e5d8c512e1895099e4504007adb ;;
1.27)
NODE_IMAGE=kindest/node:v1.27.3@sha256:3966ac761ae0136263ffdb6cfd4db23ef8a83cba8a463690e98317add2c9ba72 ;;
esac

echo "image=$NODE_IMAGE" >> $GITHUB_OUTPUT

- name: Make setup
run: make kind-cluster stern

- name: Kubernetes setup
run: |
kubectl create namespace logging

kubectl create -n logging -f hack/minio.yaml
kubectl wait -n logging --for=condition=available deployment/minio-deployment --timeout=120s
minio="$(kubectl get pod -n logging -l app=minio -o 'jsonpath={.items[0].metadata.name}')"
kubectl wait -n logging --for=condition=Ready pod "${minio}" --timeout=120s

kubectl create -n logging -f hack/minio-mc.yaml
kubectl wait -n logging --for=condition=available deployment/minio-mc-deployment --timeout=120s
mc_pod="$(kubectl get pod -n logging -l app=minio-mc -o 'jsonpath={.items[0].metadata.name}')"
kubectl wait -n logging --for=condition=Ready pod "${mc_pod}" --timeout=120s

kubectl exec -n logging "${mc_pod}" -- \
mc config host add minio \
'http://minio-service.logging.svc.cluster.local:9000' \
'minio_access_key' \
'minio_secret_key'
env:
KIND_IMAGE: ${{ steps.node_image.outputs.image }}

- name: Test
run: hack/test.sh
Expand Down
22 changes: 15 additions & 7 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -23,8 +23,8 @@ VERSION := $(shell git describe --abbrev=0 --tags)

E2E_TEST_TIMEOUT ?= 20m

CONTROLLER_GEN = ${BIN}/controller-gen
CONTROLLER_GEN_VERSION = v0.6.0
CONTROLLER_GEN := ${BIN}/controller-gen
CONTROLLER_GEN_VERSION := v0.6.0

ENVTEST_BIN_DIR := ${BIN}/envtest
ENVTEST_K8S_VERSION := 1.24.1
Expand All @@ -37,8 +37,8 @@ HELM_DOCS := ${BIN}/helm-docs
HELM_DOCS_VERSION = 1.11.0

KIND := ${BIN}/kind
KIND_VERSION := v0.19.0
KIND_IMAGE := kindest/node:v1.23.17@sha256:f77f8cf0b30430ca4128cc7cfafece0c274a118cd0cdb251049664ace0dee4ff
KIND_VERSION ?= v0.20.0
KIND_IMAGE ?= kindest/node:v1.23.17@sha256:f77f8cf0b30430ca4128cc7cfafece0c274a118cd0cdb251049664ace0dee4ff
KIND_CLUSTER := kind

KUBEBUILDER := ${BIN}/kubebuilder
Expand All @@ -47,6 +47,8 @@ KUBEBUILDER_VERSION = v3.1.0
LICENSEI := ${BIN}/licensei
LICENSEI_VERSION = v0.8.0

STERN_VERSION := 1.25.0

SETUP_ENVTEST := ${BIN}/setup-envtest

## =============
Expand Down Expand Up @@ -100,8 +102,6 @@ generate: ${CONTROLLER_GEN} tidy ## Generate code
cd pkg/sdk && $(CONTROLLER_GEN) object:headerFile=./../../hack/boilerplate.go.txt paths=./logging/api/...
cd pkg/sdk && $(CONTROLLER_GEN) object:headerFile=./../../hack/boilerplate.go.txt paths=./logging/model/...
cd pkg/sdk && $(CONTROLLER_GEN) object:headerFile=./../../hack/boilerplate.go.txt paths=./extensions/api/...
cd pkg/sdk && $(CONTROLLER_GEN) object:headerFile=./../../hack/boilerplate.go.txt paths=./resourcebuilder/...
cd pkg/sdk && go generate ./static

.PHONY: install
install: manifests ## Install CRDs into the cluster in ~/.kube/config
Expand Down Expand Up @@ -155,7 +155,15 @@ test: generate fmt vet manifests ${ENVTEST_BINARY_ASSETS} ${KUBEBUILDER} ## Run
ENVTEST_BINARY_ASSETS=${ENVTEST_BINARY_ASSETS} go test ./controllers/extensions/... ./pkg/... -coverprofile cover.out

.PHONY: test-e2e
test-e2e: ${KIND} docker-build generate fmt vet manifests stern ## Run E2E tests
test-e2e: ${KIND} generate manifests docker-build stern ## Run E2E tests
$(MAKE) test-e2e-nodeps

.PHONY: test-e2e-ci
test-e2e-ci: ${BIN}
curl -Lo ./bin/kind https://kind.sigs.k8s.io/dl/${KIND_VERSION}/kind-linux-amd64
chmod +x ./bin/kind
curl -L https://github.com/stern/stern/releases/download/v${STERN_VERSION}/stern_${STERN_VERSION}_linux_amd64.tar.gz | tar xz -C bin stern
chmod +x ./bin/stern
cd e2e && \
LOGGING_OPERATOR_IMAGE="${IMG}" \
KIND_PATH="$(KIND)" \
Expand Down
1 change: 1 addition & 0 deletions charts/logging-operator/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -93,6 +93,7 @@ Use `createCustomResource=false` with Helm v3 to avoid trying to create CRDs fro
| logging.hostTailer | object | `{}` | HostTailer config |
| testReceiver.enabled | bool | `false` | |
| testReceiver.image | string | `"fluent/fluent-bit"` | |
| testReceiver.pullPolicy | string | `"IfNotPresent"` | |
| testReceiver.port | int | `8080` | |
| testReceiver.args[0] | string | `"-i"` | |
| testReceiver.args[1] | string | `"http"` | |
Expand Down
2 changes: 1 addition & 1 deletion charts/logging-operator/templates/test_receiver.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ spec:
{{- range .Values.testReceiver.args }}
- {{ . }}
{{- end }}
imagePullPolicy: {{ .Values.image.pullPolicy }}
imagePullPolicy: {{ .Values.testReceiver.pullPolicy }}
resources:
{{- toYaml .Values.testReceiver.resources | nindent 12 }}
ports:
Expand Down
5 changes: 0 additions & 5 deletions charts/logging-operator/values-logging-example.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -6,11 +6,6 @@ testReceiver:

logging:
enabled: true
fluentbit:
filterKubernetes:
K8S-Logging.Exclude: "On"
tls:
enabled: false
clusterFlows:
- name: all
spec:
Expand Down
1 change: 1 addition & 0 deletions charts/logging-operator/values.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -265,6 +265,7 @@ logging:
testReceiver:
enabled: false
image: fluent/fluent-bit
pullPolicy: IfNotPresent
port: 8080
args: ["-i", "http", "-p", "port=8080", "-o", "stdout"]
resources:
Expand Down
17 changes: 17 additions & 0 deletions e2e/common/helpers.go
Original file line number Diff line number Diff line change
Expand Up @@ -16,15 +16,32 @@ package common

import (
"fmt"
"os"
"sync/atomic"
"testing"

"emperror.dev/errors"
"github.com/spf13/cast"
"github.com/stretchr/testify/assert"
)

var sequence uint32

func RequireNoError(t *testing.T, err error) {
if err != nil {
assert.Fail(t, fmt.Sprintf("Received unexpected error:\n%#v %+v", err, errors.GetDetails(err)))
t.FailNow()
}
}

func Initialize(t *testing.T) {
localSeq := atomic.AddUint32(&sequence, 1)
shards := cast.ToUint32(os.Getenv("SHARDS"))
shard := cast.ToUint32(os.Getenv("SHARD"))
if shards > 0 {
if localSeq%shards != shard {
t.Skipf("skipping %s as sequence %d not in shard %d", t.Name(), localSeq, shard)
}
}
t.Parallel()
}
6 changes: 2 additions & 4 deletions e2e/common/kind.go
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,7 @@
package common

import (
"bytes"
"os/exec"
"strings"

"github.com/kube-logging/logging-operator/e2e/common/kind"
)
Expand All @@ -37,6 +36,5 @@ func KindClusterKubeconfig(name string) ([]byte, error) {
}

func isClusterAlreadyExistsError(err error) bool {
exitErr, _ := err.(*exec.ExitError)
return exitErr != nil && bytes.Contains(exitErr.Stderr, []byte("failed to create cluster: node(s) already exist for a cluster with the name"))
return strings.Contains(err.Error(), "failed to create cluster: node(s) already exist for a cluster with the name")
}
18 changes: 11 additions & 7 deletions e2e/common/kind/commands.go
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,10 @@
package kind

import (
"bytes"
"errors"
"fmt"
"io"
"os"
"os/exec"
"strings"
Expand All @@ -27,8 +30,8 @@ var KindImage string
func init() {
KindPath = os.Getenv("KIND_PATH")
if KindPath == "" {
fmt.Fprintln(os.Stderr, "KIND_PATH need to be set")
os.Exit(1)
KindPath = "../../bin/kind"
fmt.Println("KIND_PATH is not set, defaulting to ../../bin/kind")
}
KindImage = os.Getenv("KIND_IMAGE")
}
Expand All @@ -40,12 +43,13 @@ func CreateCluster(options CreateClusterOptions) error {
}
args = options.AppendToArgs(args)
cmd := exec.Command(KindPath, args...)
cmd.Stderr = os.Stderr
o, err := cmd.Output()
if err != nil {
fmt.Println(o)
cmderr := &bytes.Buffer{}
cmd.Stdout = os.Stdout
cmd.Stderr = io.MultiWriter(os.Stderr, cmderr)
if err := cmd.Run(); err != nil {
return errors.New(cmderr.String())
}
return err
return nil
}

type CreateClusterOptions struct {
Expand Down
Loading