Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add make e2e command for e2e tests based on skywalking-e2e-infra #422

Merged
merged 4 commits into from
Jul 15, 2022
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
126 changes: 126 additions & 0 deletions .ci/clusters/values_skywalking_e2e_cluster.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,126 @@
#
# Licensed to the Apache Software Foundation (ASF) under one
# or more contributor license agreements. See the NOTICE file
# distributed with this work for additional information
# regarding copyright ownership. The ASF licenses this file
# to you under the Apache License, Version 2.0 (the
# "License"); you may not use this file except in compliance
# with the License. You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing,
# software distributed under the License is distributed on an
# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
# KIND, either express or implied. See the License for the
# specific language governing permissions and limitations
# under the License.
#

## deployed withh emptyDir
volumes:
persistence: false

# disabled AntiAffinity
affinity:
anti_affinity: false

# disable auto recovery
components:
autorecovery: false
pulsar_manager: false
sql_worker: false
proxy: false

## disable monitoring stack
monitoring:
# monitoring - prometheus
prometheus: false
# monitoring - grafana
grafana: false
# monitoring - node_exporter
node_exporter: false

images:
zookeeper:
repository: streamnative/pulsar-all
tag: 2.9.2.23
bookie:
repository: streamnative/pulsar-all
tag: 2.9.2.23
broker:
repository: streamnative/pulsar-all
tag: 2.9.2.23
functions:
repository: streamnative/pulsar-all
tag: 2.9.2.23

zookeeper:
replicaCount: 1
resources:
requests:
memory: 256Mi
cpu: 50m

bookkeeper:
replicaCount: 0
metadata:
image:
repository: streamnative/pulsar-all
tag: 2.9.2.23
resources:
requests:
memory: 256Mi
cpu: 50m
configData:
PULSAR_PREFIX_autoRecoveryDaemonEnabled: "false"
PULSAR_PREFIX_dlog.bkcEnsembleSize: "1"
PULSAR_PREFIX_dlog.bkcWriteQuorumSize: "1"
PULSAR_PREFIX_dlog.bkcAckQuorumSize: "1"
# `BOOKIE_MEM` is used for `bookie shell`
BOOKIE_MEM: >
-Xms128m
-Xmx256m
-XX:MaxDirectMemorySize=256m
# we use `bin/pulsar` for starting bookie daemons
PULSAR_MEM: >
-Xms128m
-Xmx256m
-XX:MaxDirectMemorySize=256m
PULSAR_GC: >
-XX:+UseG1GC
-XX:MaxGCPauseMillis=10
-XX:+ParallelRefProcEnabled
-XX:+UnlockExperimentalVMOptions
-XX:+AggressiveOpts
-XX:+DoEscapeAnalysis
-XX:ParallelGCThreads=4
-XX:ConcGCThreads=4
-XX:G1NewSizePercent=50
-XX:+DisableExplicitGC
-XX:-ResizePLAB
-XX:+ExitOnOutOfMemoryError
-XX:+PerfDisableSharedMem

pulsar_metadata:
image:
repository: streamnative/pulsar-all
tag: 2.9.2.23

broker:
replicaCount: 1
configData:
## Enable `autoSkipNonRecoverableData` since bookkeeper is running
## without persistence
autoSkipNonRecoverableData: "true"
# storage settings
managedLedgerDefaultEnsembleSize: "1"
managedLedgerDefaultWriteQuorum: "1"
managedLedgerDefaultAckQuorum: "1"
resources:
requests:
memory: 256Mi
cpu: 50m

functions:
functionState: true
4 changes: 4 additions & 0 deletions .ci/tests/env
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
PULSAR_NAMESPACE=default
PULSAR_RELEASE_NAME=sn-platform
FUNCTION_MESH_NAMESPACE=function-mesh
FUNCTION_MESH_RELEASE_NAME=function-mesh
72 changes: 72 additions & 0 deletions .ci/tests/integration/cases/java-function/manifests.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,72 @@
apiVersion: compute.functionmesh.io/v1alpha1
kind: Function
metadata:
name: function-sample
namespace: default
spec:
image: streamnative/pulsar-functions-java-sample:2.9.2.23
className: org.apache.pulsar.functions.api.examples.ExclamationFunction
forwardSourceMessageProperty: true
maxPendingAsyncRequests: 1000
replicas: 1
maxReplicas: 5
logTopic: persistent://public/default/logging-function-logs
input:
topics:
- persistent://public/default/input-java-topic
typeClassName: java.lang.String
output:
topic: persistent://public/default/output-java-topic
typeClassName: java.lang.String
resources:
requests:
cpu: 50m
memory: 1G
limits:
cpu: "0.2"
memory: 1.1G
# each secret will be loaded ad an env variable from the `path` secret with the `key` in that secret in the name of `name`
secretsMap:
"name":
path: "test-secret"
key: "username"
"pwd":
path: "test-secret"
key: "password"
pulsar:
pulsarConfig: "test-pulsar"
#authConfig: "test-auth"
java:
jar: /pulsar/examples/api-examples.jar
# to be delete & use admission hook
clusterName: test
autoAck: true
---
apiVersion: v1
kind: ConfigMap
metadata:
name: test-pulsar
data:
webServiceURL: http://sn-platform-pulsar-broker.default.svc.cluster.local:8080
brokerServiceURL: pulsar://sn-platform-pulsar-broker.default.svc.cluster.local:6650
#---
#apiVersion: v1
#kind: ConfigMap
#metadata:
# name: test-auth
#data:
# clientAuthenticationPlugin: "abc"
# clientAuthenticationParameters: "xyz"
# tlsTrustCertsFilePath: "uvw"
# useTls: "true"
# tlsAllowInsecureConnection: "false"
# tlsHostnameVerificationEnable: "true"
---
apiVersion: v1
data:
username: YWRtaW4=
password: MWYyZDFlMmU2N2Rm
kind: Secret
metadata:
name: test-secret
type: Opaque
50 changes: 50 additions & 0 deletions .ci/tests/integration/cases/java-function/verify.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
#!/usr/bin/env bash
#
# Licensed to the Apache Software Foundation (ASF) under one
# or more contributor license agreements. See the NOTICE file
# distributed with this work for additional information
# regarding copyright ownership. The ASF licenses this file
# to you under the Apache License, Version 2.0 (the
# "License"); you may not use this file except in compliance
# with the License. You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing,
# software distributed under the License is distributed on an
# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
# KIND, either express or implied. See the License for the
# specific language governing permissions and limitations
# under the License.
#

set -e

E2E_DIR=$(dirname "$0")
BASE_DIR=$(cd "${E2E_DIR}"/../../../../..;pwd)
PULSAR_NAMESPACE=${PULSAR_NAMESPACE:-"default"}
PULSAR_RELEASE_NAME=${PULSAR_RELEASE_NAME:-"sn-platform"}
E2E_KUBECONFIG=${E2E_KUBECONFIG:-"/tmp/e2e-k8s.config"}

source "${BASE_DIR}"/.ci/helm.sh

if [ ! "$KUBECONFIG" ]; then
export KUBECONFIG=${E2E_KUBECONFIG}
fi

kubectl apply -f "${BASE_DIR}"/.ci/tests/integration/cases/java-function/manifests.yaml > /dev/null 2>&1

verify_fm_result=$(ci::verify_function_mesh function-sample 2>&1)
if [ $? -ne 0 ]; then
echo "$verify_fm_result"
kubectl delete -f "${BASE_DIR}"/.ci/tests/integration/cases/java-function/manifests.yaml > /dev/null 2>&1 || true
exit 1
fi

verify_java_result=$(NAMESPACE=${PULSAR_NAMESPACE} CLUSTER=${PULSAR_RELEASE_NAME} ci::verify_java_function 2>&1)
if [ $? -eq 0 ]; then
echo "e2e-test: ok" | yq eval -
else
echo "$verify_java_result"
fi
kubectl delete -f "${BASE_DIR}"/.ci/tests/integration/cases/java-function/manifests.yaml > /dev/null 2>&1 || true
93 changes: 93 additions & 0 deletions .ci/tests/integration/e2e.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,93 @@
setup:
env: kind
file: ../kind.yaml
init-system-environment: ../env
steps:
- name: build images
command: |
chmod +x images/build.sh images/samples/build.sh
PULSAR_IMAGE_TAG=2.9.2.23 PULSAR_IMAGE=streamnative/pulsar-all KIND_PUSH=true images/build.sh
PULSAR_IMAGE_TAG=2.9.2.23 KIND_PUSH=true images/samples/build.sh

- name: install helm
command: |
curl https://raw.githubusercontent.com/helm/helm/main/scripts/get-helm-3 | bash

- name: setup cert-manager
command: |
helm repo add jetstack https://charts.jetstack.io
helm repo update
helm install cert-manager jetstack/cert-manager --set installCRDs=true
wait:
- namespace: default
resource: pod
label-selector: app=cert-manager
for: condition=Ready

- name: install pulsar cluster
command: |
helm repo add streamnative https://charts.streamnative.io
rm -rf pulsar-charts/
git clone https://github.com/streamnative/charts.git pulsar-charts
cd pulsar-charts/
./scripts/pulsar/prepare_helm_release.sh -n default -k ${PULSAR_RELEASE_NAME} -c
helm repo add loki https://grafana.github.io/loki/charts
helm dependency update charts/pulsar
helm install ${PULSAR_RELEASE_NAME} --set initialize=true --values ../.ci/clusters/values_skywalking_e2e_cluster.yaml charts/pulsar

- name: wait for pulsar cluster ready
command: |
echo "wait until pulsar init job is completed"
succeeded_num=0
while [[ ${succeeded_num} -lt 1 ]]; do
sleep 10s
kubectl get pods -n ${PULSAR_NAMESPACE}
succeeded_num=$(kubectl get jobs -n ${PULSAR_NAMESPACE} ${PULSAR_RELEASE_NAME}-pulsar-pulsar-init -o jsonpath='{.status.succeeded}')
done
kubectl scale statefulset --replicas=1 ${PULSAR_RELEASE_NAME}-pulsar-bookie
wait:
- namespace: default
resource: pod
label-selector: app=pulsar
for: condition=Ready

- name: wait for producer active
command: |
kubectl exec -n ${PULSAR_NAMESPACE} ${PULSAR_RELEASE_NAME}-pulsar-toolset-0 -- bash -c 'until nslookup sn-platform-pulsar-broker; do sleep 3; done'
kubectl exec -n ${PULSAR_NAMESPACE} ${PULSAR_RELEASE_NAME}-pulsar-broker-0 -- bin/pulsar-admin tenants create sn-platform
kubectl exec -n ${PULSAR_NAMESPACE} ${PULSAR_RELEASE_NAME}-pulsar-broker-0 -- bin/pulsar-admin namespaces create sn-platform/test
kubectl exec -n ${PULSAR_NAMESPACE} ${PULSAR_RELEASE_NAME}-pulsar-broker-0 -- bin/pulsar-client produce -m "test-message" sn-platform/test/test-topic
kubectl exec -n ${PULSAR_NAMESPACE} ${PULSAR_RELEASE_NAME}-pulsar-bookie-0 -- df -h
kubectl exec -n ${PULSAR_NAMESPACE} ${PULSAR_RELEASE_NAME}-pulsar-bookie-0 -- cat conf/bookkeeper.conf
kubectl exec -n ${PULSAR_NAMESPACE} ${PULSAR_RELEASE_NAME}-pulsar-bookie-0 -- nc -zv 127.0.0.1 4181

- name: install function-mesh operator
command: |
make generate
make helm-crds
image="function-mesh-operator:latest"
IMG=${image} make docker-build-skip-test
kind load docker-image ${image}
helm install ${FUNCTION_MESH_RELEASE_NAME} -n ${FUNCTION_MESH_NAMESPACE} --set operatorImage=${image} --create-namespace charts/function-mesh-operator
wait:
- namespace: function-mesh
resource: pod
label-selector: app.kubernetes.io/name=function-mesh-operator
for: condition=Ready
timeout: 60m

cleanup:
# always never success failure
on: success

verify:
# verify with retry strategy
retry:
# max retry count
count: 60
# the interval between two attempts, e.g. 10s, 1m.
interval: 10s
cases:
# java function test
- query: bash .ci/tests/integration/cases/java-function/verify.sh
expected: expected.data.yaml
1 change: 1 addition & 0 deletions .ci/tests/integration/expected.data.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
e2e-test: ok
34 changes: 34 additions & 0 deletions .ci/tests/kind.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
# this config file contains all config fields with comments
# NOTE: this is not a particularly useful config file
kind: Cluster
apiVersion: kind.x-k8s.io/v1alpha4
# patch the generated kubeadm config with some extra settings
kubeadmConfigPatches:
- |
apiVersion: kubelet.config.k8s.io/v1beta1
kind: KubeletConfiguration
evictionHard:
nodefs.available: "0%"
# patch it further using a JSON 6902 patch
kubeadmConfigPatchesJSON6902:
- group: kubeadm.k8s.io
version: v1beta2
kind: ClusterConfiguration
patch: |
- op: add
path: /apiServer/certSANs/-
value: my-hostname
# 1 control plane node (worker)
nodes:
# the control plane node (worker) config
- role: control-plane
image: kindest/node:v1.18.20
extraPortMappings:
- containerPort: 31234
hostPort: 31234
# optional: set the bind address on the host
# 0.0.0.0 is the current default
listenAddress: "127.0.0.1"
# optional: set the protocol to one of TCP, UDP, SCTP.
# TCP is the default
protocol: TCP
Loading