Skip to content

Conversation

@runkecheng
Copy link
Collaborator

@runkecheng runkecheng commented Nov 17, 2021

What type of PR is this?

/enhancement

Which issue(s) this PR fixes?

Fixes #

What this PR does?

Summary:

  • example code for e2e
  • ci

Special notes for your reviewer?

Usage

step1: Configure environment variables

export KUBECONFIG=$HOME/.kube/config

step2: Configure test context

Fill Endpoints in text_context.go like

flag.StringVar(&TestContext.KubeHost, "kubernetes-host", "https://139.198.30.60:16443", "The kubernetes host, or apiserver, to connect to")

If the host and the K8s cluster are not in the same network, you need to configure external network access.

Run test

example

/radondb-mysql-kubernetes/test/e2e$ go test -timeout 3000s -run ^TestE2E$
go test -v ./test/e2e   -timeout 20m
=== RUN   TestE2E
STEP: Creating framework with timeout: 1200
Running Suite: MySQL Operator E2E Suite
=======================================
Random Seed: 1639707312 - Will randomize all specs
Will run 1 of 1 specs

STEP: Install operator
NAME: demo
LAST DEPLOYED: Fri Dec 17 10:15:14 2021
NAMESPACE: mysql-operator
STATUS: deployed
REVISION: 1
TEST SUITE: None
NOTES:
You can create a new mysqlcluster by issuing:

cat <<EOF | kubectl apply -f-
apiVersion: mysql.radondb.com/v1alpha1
kind: MysqlCluster
metadata:
  name: sample
spec:
  replicas: 3
EOF
MySQL Cluster E2E Tests 
  scale out/in a cluster, 2 -> 3 -> 5 -> 3 -> 2
  /home/runkecheng/goCode/src/radondb-mysql-kubernetes/test/e2e/cluster/cluster.go:77
[BeforeEach] MySQL Cluster E2E Tests
  /home/runkecheng/goCode/src/radondb-mysql-kubernetes/test/e2e/framework/framework.go:63
STEP: creating a kubernetes client
STEP: create a namespace api object (e2e-mc-1-bvrb2)
[BeforeEach] MySQL Cluster E2E Tests
  /home/runkecheng/goCode/src/radondb-mysql-kubernetes/test/e2e/cluster/cluster.go:58
STEP: creating a new cluster
STEP: testing the cluster readiness
STEP: create sysbench pod for preparing data
STEP: wait pod ready
STEP: testing the data readiness
[It] scale out/in a cluster, 2 -> 3 -> 5 -> 3 -> 2
  /home/runkecheng/goCode/src/radondb-mysql-kubernetes/test/e2e/cluster/cluster.go:77
STEP: create sysbench pod for testing oltp
STEP: wait pod ready
STEP: test cluster is ready after scale out 2 -> 3
STEP: test cluster is ready after scale out 3 -> 5
STEP: test cluster is ready after scale in 5 -> 3
STEP: test cluster is ready after scale in 3 -> 2
[AfterEach] MySQL Cluster E2E Tests
  /home/runkecheng/goCode/src/radondb-mysql-kubernetes/test/e2e/framework/framework.go:64
STEP: Collecting logs
STEP: Run cleanup actions
STEP: Delete testing namespace

• [SLOW TEST:1023.235 seconds]
MySQL Cluster E2E Tests
/home/runkecheng/goCode/src/radondb-mysql-kubernetes/test/e2e/cluster/cluster.go:39
  scale out/in a cluster, 2 -> 3 -> 5 -> 3 -> 2
  /home/runkecheng/goCode/src/radondb-mysql-kubernetes/test/e2e/cluster/cluster.go:77
------------------------------
STEP: Remove operator release
release "demo" uninstalled
STEP: Delete operator namespace


Ran 1 of 1 Specs in 742.686 seconds
SUCCESS! -- 1 Passed | 0 Failed | 0 Pending | 0 Skipped

@runkecheng runkecheng added enhancement New feature or request k8s kubernetes labels Nov 17, 2021
@runkecheng runkecheng added this to the v2.1.1 milestone Nov 17, 2021
@runkecheng runkecheng self-assigned this Nov 17, 2021
@runkecheng runkecheng added e2e and removed k8s kubernetes labels Nov 17, 2021
@runkecheng runkecheng force-pushed the test_e2e branch 3 times, most recently from b9840f2 to c1b1f71 Compare November 18, 2021 07:43
@andyli029 andyli029 modified the milestones: v2.1.1, v2.1.2 Nov 22, 2021
@acekingke
Copy link
Contributor

Got error:
Random Seed: 1639542724 - Will randomize all specs
Will run 1 of 1 specs

Failure [0.003 seconds]
[BeforeSuite] BeforeSuite
/root/radondb-mysql-kubernetes/test/e2e/e2e.go:50

can't instantiate k8s client: the server rejected our request for an unknown reason

/root/radondb-mysql-kubernetes/test/e2e/e2e.go:57

@acekingke
Copy link
Contributor

need set env

 "KUBERNETES_SERVICE_HOST":"xxxx",
  "KUBERNETES_SERVICE_PORT":"6443",
"ACK_GINKGO_DEPRECATIONS":"1.16.5"

@acekingke
Copy link
Contributor

image

@acekingke
Copy link
Contributor

use https:// it works.

@runkecheng
Copy link
Collaborator Author

image

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

e2e enhancement New feature or request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants