blob: 0d9da317a0d071ac43670cf77a7edaa68a747ba8 [file] [log] [blame]
#
# 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.
#
name: Integration Test for Operator Helm Charts
on:
pull_request:
branches: [ main ]
paths:
- 'charts/apache-shardingsphere-operator-charts/**'
- '.github/workflows/operator-integration.yml'
jobs:
run:
name: Integration Test for ShardingSphere Operator Helm Charts
runs-on: ubuntu-latest
steps:
- name: "checkout codes"
uses: actions/checkout@v3
- name: Prepare Kind
run: |
curl -Lo ./kind https://kind.sigs.k8s.io/dl/v0.11.1/kind-linux-amd64
chmod +x ./kind
sudo mv kind /usr/local/bin
- name: Prepare Helm
run: |
curl -Lo ./helm.tar.gz https://get.helm.sh/helm-v3.10.1-linux-amd64.tar.gz
tar zxvf helm.tar.gz
sudo mv linux-amd64/helm /usr/local/bin
- name: Create K8s cluster
shell: bash
run: |
# make kind-up
kind create cluster
kubectl wait --for=condition=Ready nodes --all
- name: "Install Helm Charts for ShardingSphere Operator"
run: |
set -x
kubectl create namespace shardingsphere-operator
cd charts/apache-shardingsphere-operator-charts/
helm dependency build
cd ../
helm install shardingsphere-operator apache-shardingsphere-operator-charts -n shardingsphere-operator --set replicaCount=1 --set operator.featureGates.computeNode=true --set operator.image.tag=0.2.0
sleep 60
kubectl wait --timeout=120s --for=condition=Ready --all pod -n shardingsphere-operator
kubectl get pod -n shardingsphere-operator --show-labels
- name: "Install ComputeNode"
run: |
sed -i 's#${PLEASE_REPLACE_THIS_WITH_YOUR_ZOOKEEPER_SERVICE}#shardingsphere-operator-zookeeper.shardingsphere-operator:2181#g' .github/kubernetes/shardingsphere-computenode-mysql-cluster.yaml
kubectl apply -f .github/kubernetes/shardingsphere-computenode-mysql-cluster.yaml
kubectl wait --timeout=120s --for=condition=Ready --all pod -n default
kubectl get pod -n default --show-labels
kubectl port-forward svc/foo 3307:3307 &
- name: "Prepare MySQL for ShardingSphere Proxy test"
run: |
set -x
kubectl apply -f hack/kubernetes/mysql.yml
sleep 60
kubectl get pod,svc -n default --show-labels
kubectl wait --timeout=60s --for=condition=Ready --all pod -n default
kubectl get pod,svc -n default --show-labels
kubectl port-forward svc/mysql-1 3316:3306 -n default &
kubectl port-forward svc/mysql-2 3326:3306 -n default &
sleep 3
- name: "Install MySQL"
run: "sudo apt-get install -y mysql-client"
- name: "Create schema from MySQL-1"
run: mysql -h127.0.0.1 -P3316 -uroot -proot -e 'CREATE DATABASE ds_1;'
- name: "Create schema from MySQL-2"
run: mysql -h127.0.0.1 -P3326 -uroot -proot -e 'CREATE DATABASE ds_2;'
- name: "Create sharding db"
run: |
mysql -h127.0.0.1 -P3307 -uroot -proot -e 'CREATE DATABASE sharding_db; USE sharding_db; REGISTER STORAGE UNIT ds_1 (HOST="mysql-1.default", PORT=3306, DB="ds_1", USER="root", PASSWORD="root"),ds_2 (HOST="mysql-2.default", PORT=3306, DB="ds_2", USER="root", PASSWORD="root"); CREATE SHARDING TABLE RULE t_order(STORAGE_UNITS(ds_1,ds_2),SHARDING_COLUMN=order_id,TYPE(NAME="hash_mod",PROPERTIES("sharding-count"="2")),KEY_GENERATE_STRATEGY(COLUMN=order_id,TYPE(NAME="snowflake")));'
- name: "Create sharding table"
run: |
mysql -h127.0.0.1 -P3307 -uroot -proot -e 'USE sharding_db; CREATE TABLE `t_order` (`order_id` int NOT NULL,`user_id` int NOT NULL,`status` varchar(45) DEFAULT NULL,PRIMARY KEY (`order_id`)) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4;'
- name: "Insert data into sharding db"
run: |
sleep 3;
mysql -h127.0.0.1 -P3307 -uroot -proot -e 'USE sharding_db; INSERT INTO `t_order` VALUES(1, 1, "code1"),(2, 2, "code2"), (3, 3, "code3"), (4, 4, "code4");'
- name: "Query data from sharding_db"
run: mysql -h127.0.0.1 -P3307 -uroot -proot -e 'USE sharding_db;SELECT * FROM t_order;'
- name: "Query data from MySQL-1"
run: mysql -h127.0.0.1 -P3316 -uroot -proot -e 'USE ds_1;SELECT * FROM `t_order_0`;'
- name: "Query data from MySQL-2 "
run: mysql -h127.0.0.1 -P3326 -uroot -proot -e 'USE ds_2;SELECT * FROM `t_order_1`;'