From 4dca2287ff41f58d3799009c6f3a9f9f6e300a96 Mon Sep 17 00:00:00 2001 From: jianzhiyao Date: Thu, 28 Jan 2021 17:10:35 +0800 Subject: [PATCH] add some testing scripts --- scripts/adapter.sh | 13 ++++++++ scripts/prepare_etcd.sh | 8 +++++ scripts/test.sh | 17 ++++++++++ scripts/test_docker_compose.yaml | 55 ++++++++++++++++++++++++++++++++ 4 files changed, 93 insertions(+) create mode 100644 scripts/adapter.sh create mode 100644 scripts/prepare_etcd.sh create mode 100644 scripts/test.sh create mode 100644 scripts/test_docker_compose.yaml diff --git a/scripts/adapter.sh b/scripts/adapter.sh new file mode 100644 index 00000000..e5d2d0a4 --- /dev/null +++ b/scripts/adapter.sh @@ -0,0 +1,13 @@ +#!/bin/sh + +# using pkg/adapter. Usually you want to migrate to V2 smoothly, you could running this script + +find ./ -name '*.go' -type f -exec sed -i '' -e 's/github.com\/astaxie\/beego/github.com\/astaxie\/beego\/pkg\/adapter/g' {} \; +find ./ -name '*.go' -type f -exec sed -i '' -e 's/"github.com\/astaxie\/beego\/pkg\/adapter"/beego "github.com\/astaxie\/beego\/pkg\/adapter"/g' {} \; + +update rrp_flow set status = 4 where flow_id in (5623711176,5629411891) + +select * from rrp_flow where flow_id in (5623711176,5629411891) and status = 5 + +update rrp_flow set status = 5 where flow_id in (5623711176,5629411891) + diff --git a/scripts/prepare_etcd.sh b/scripts/prepare_etcd.sh new file mode 100644 index 00000000..d34c05a3 --- /dev/null +++ b/scripts/prepare_etcd.sh @@ -0,0 +1,8 @@ +#!/bin/bash + +etcdctl put current.float 1.23 +etcdctl put current.bool true +etcdctl put current.int 11 +etcdctl put current.string hello +etcdctl put current.serialize.name test +etcdctl put sub.sub.key1 sub.sub.key \ No newline at end of file diff --git a/scripts/test.sh b/scripts/test.sh new file mode 100644 index 00000000..977055a3 --- /dev/null +++ b/scripts/test.sh @@ -0,0 +1,17 @@ +#!/bin/bash + +docker-compose -f "$(pwd)/scripts/test_docker_compose.yaml" up -d + +export ORM_DRIVER=mysql +export TZ=UTC +export ORM_SOURCE="beego:test@tcp(localhost:13306)/orm_test?charset=utf8" + +# wait for services in images ready +sleep 5 + +go test "$(pwd)/..." + +# clear all container +docker-compose -f "$(pwd)/scripts/test_docker_compose.yaml" down + + diff --git a/scripts/test_docker_compose.yaml b/scripts/test_docker_compose.yaml new file mode 100644 index 00000000..f22b6deb --- /dev/null +++ b/scripts/test_docker_compose.yaml @@ -0,0 +1,55 @@ +version: "3.8" +services: + redis: + container_name: "beego-redis" + image: redis + environment: + - ALLOW_EMPTY_PASSWORD=yes + ports: + - "6379:6379" + + mysql: + container_name: "beego-mysql" + image: mysql:5.7.30 + ports: + - "13306:3306" + environment: + - MYSQL_ROOT_PASSWORD=1q2w3e + - MYSQL_DATABASE=orm_test + - MYSQL_USER=beego + - MYSQL_PASSWORD=test + + postgresql: + container_name: "beego-postgresql" + image: bitnami/postgresql:latest + ports: + - "5432:5432" + environment: + - ALLOW_EMPTY_PASSWORD=yes + ssdb: + container_name: "beego-ssdb" + image: wendal/ssdb + ports: + - "8888:8888" + memcache: + container_name: "beego-memcache" + image: memcached + ports: + - "11211:11211" + etcd: + command: > + sh -c " + etcdctl put current.float 1.23 + && etcdctl put current.bool true + && etcdctl put current.int 11 + && etcdctl put current.string hello + && etcdctl put current.serialize.name test + " + container_name: "beego-etcd" + environment: + - ALLOW_NONE_AUTHENTICATION=yes +# - ETCD_ADVERTISE_CLIENT_URLS=http://etcd:2379 + image: bitnami/etcd + ports: + - "2379:2379" + - "2380:2380" \ No newline at end of file