Skip to content

Commit e0de6dc

Browse files
committed
feat:调整pg插件的代码结构
1 parent 01f6bfd commit e0de6dc

File tree

4 files changed

+553
-43
lines changed

4 files changed

+553
-43
lines changed

.github/workflows/integration.yaml

Lines changed: 67 additions & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -59,6 +59,21 @@ jobs:
5959
goos: linux
6060

6161
runs-on: ${{ matrix.os }}
62+
services:
63+
# Label used to access the service container
64+
redis:
65+
# Docker Hub image
66+
image: redis
67+
# Set health checks to wait until redis has started
68+
options: >-
69+
--health-cmd "redis-cli ping"
70+
--health-interval 10s
71+
--health-timeout 5s
72+
--health-retries 5
73+
ports:
74+
# Maps port 6379 on service container to the host
75+
- 6379:6379
76+
# TODO 拉起一个PG docker 实例
6277
steps:
6378
# Setup the environment.
6479
- name: Setup Go
@@ -74,44 +89,61 @@ jobs:
7489
env:
7590
GOOS: ${{ matrix.goos }}
7691
GOARCH: ${{ matrix.goarch }}
77-
run: make build
92+
run: make build STORE_PG_PLUGIN_VERSION= POLARIS_SERVER_VERSION=v1.17.2
7893

7994
# Run interface tests
8095
- name: run tests
8196
run: |
82-
# work_dir=$(ls | grep polaris-server-release | sed -n '1p')
83-
# echo "work_dir is $work_dir"
84-
# cd $work_dir
97+
export STORE_MODE=sqldb
98+
echo "cur STORE MODE=${STORE_MODE}"
99+
100+
# # 设置严格模式
101+
# mysql -h127.0.0.1 -P3306 -uroot -p"polaris" -e "set sql_mode='STRICT_TRANS_TABLES,NO_AUTO_CREATE_USER,NO_ENGINE_SUBSTITUTION'";
102+
# # 清空数据
103+
# mysql -h127.0.0.1 -P3306 -uroot -p"polaris" -e "DROP DATABASE IF EXISTS polaris_server";
104+
# # 初始化 polaris 数据库
105+
# mysql -h127.0.0.1 -P3306 -uroot -p"polaris" < store/mysql/scripts/polaris_server.sql
106+
# # 临时放开 DB 的最大连接数
107+
# mysql -h127.0.0.1 -P3306 -uroot -p"polaris" -e "set GLOBAL max_connections = 3000;"
108+
85109

86-
# ls -alR
87-
88-
# if [[ "$(uname)" == "Darwin" ]]; then
89-
# # Mac OS X 操作系统
90-
# echo "Run on MacOS"
91-
# # sed -i '' 's/consoleOpen: true/consoleOpen: false/g' conf/polaris-server.yaml
92-
# else
93-
# # GNU/Linux操作系统
94-
# echo "Run on Linux"
95-
# # sed -i 's/consoleOpen: \(true\|false\)/consoleOpen: false/g' conf/polaris-server.yaml
96-
# fi
97-
98-
# chmod +x ./tool/*.sh
99-
# ./tool/start.sh
100-
101-
# sleep 120s
102-
# ls -alR
103-
# cat ./log/stdout 2>&1
104-
105-
# cd ..
106-
# ls -lstrh
107-
# # 先测试普通的集成测试
108-
# pushd ./test/integrate
109-
# echo "[INTEGRATION TEST] begin"
110-
# curl http://127.0.0.1:8090
111-
# go test -count=1 -v -tags integration
112-
# echo "[INTEGRATION TEST] end"
113-
# popd
114-
# cd $work_dir
115-
# ./tool/stop.sh
116-
# cd ..
110+
work_dir="build_resource/polaris/polaris-server-release-xxxx"
111+
work_dir=$(ls | grep polaris-server-release | sed -n '1p')
112+
echo "work_dir is $work_dir"
113+
114+
cp -rf ./test/data/polaris-server.yaml $work_dir/
115+
116+
cd $work_dir
117+
118+
ls -alR
119+
120+
if [[ "$(uname)" == "Darwin" ]]; then
121+
# Mac OS X 操作系统
122+
echo "Run on MacOS"
123+
# sed -i '' 's/consoleOpen: true/consoleOpen: false/g' conf/polaris-server.yaml
124+
else
125+
# GNU/Linux操作系统
126+
echo "Run on Linux"
127+
# sed -i 's/consoleOpen: \(true\|false\)/consoleOpen: false/g' conf/polaris-server.yaml
128+
fi
129+
130+
chmod +x ./tool/*.sh
131+
./tool/start.sh
132+
133+
sleep 120s
134+
ls -alR
135+
cat ./log/stdout 2>&1
136+
137+
cd ..
138+
ls -lstrh
139+
# 先测试普通的集成测试
140+
pushd ./test/integrate
141+
echo "[INTEGRATION TEST] begin"
142+
curl http://127.0.0.1:8090
143+
go test -count=1 -v -tags integration -timeout 60m
144+
echo "[INTEGRATION TEST] end"
145+
popd
146+
cd $work_dir
147+
./tool/stop.sh
148+
cd ..
117149

README.md

Lines changed: 2 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -4,12 +4,12 @@
44

55
#### 构建
66

7-
执行构建脚本 `build.sh` 即可
7+
执行构建脚本 `Makefile` 即可
88

99
```bash
1010
# ${store_pg_plugin_version}: store-postgresql 插件版本,默认为 main 的最新 commit
1111
# ${polaris_server_tag}: 北极星服务端版本信息,默认为 main 分支
12-
make build STORE_PG_PLUGIN_VERSION=${store_pg_plugin_version} POLARIS_SERVER_VERSION=${polaris_server_tag}
12+
make build STORE_PG_PLUGIN_VERSION=latest POLARIS_SERVER_VERSION=${polaris_server_tag}
1313
```
1414

1515
#### 配置文件调整
@@ -34,8 +34,3 @@ store:
3434
connMaxLifetime: 300 # Unit second
3535
txIsolationLevel: 2 #LevelReadCommitted
3636
```
37-
38-
39-
## 其他
40-
41-
- NACOS 中的 struct 数据结构定义大部份引用自 [nacos-sdk-go](https://github.com/nacos-group/nacos-sdk-go)

build.sh

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,10 +41,11 @@ fi
4141
cat ../plugin_store_pg.go.temp >plugin_store_pg.go
4242

4343
go clean --modcache
44-
go get -ugithub.com/polaris-contrib/polaris-store-postgresql@${store_pg_plugin_version}
44+
go get -u github.com/polaris-contrib/polaris-store-postgresql@${store_pg_plugin_version}
4545
go mod tidy
4646

4747
make build VERSION=${polaris_server_tag}
4848

4949
release_file=$(ls -lstrh | grep ".zip" | awk '{print $10}' | grep -v "md5")
5050
cp ${release_file} ${workdir}
51+

0 commit comments

Comments
 (0)