build-and-test.yml 15 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478
  1. name: build-and-test
  2. on: push
  3. env:
  4. CC: gcc-4.9
  5. CXX: g++-4.9
  6. secret_account: ${{ secrets.DOCKER_USERNAME }}
  7. jobs:
  8. building:
  9. runs-on: ubuntu-20.04
  10. steps:
  11. - uses: actions/checkout@v3
  12. - name: Install gcc env
  13. run: |
  14. echo "deb http://dk.archive.ubuntu.com/ubuntu/ xenial main" | sudo tee -a /etc/apt/sources.list
  15. echo "deb http://dk.archive.ubuntu.com/ubuntu/ xenial universe" | sudo tee -a /etc/apt/sources.list
  16. sudo apt update
  17. sudo apt install gcc-4.9 g++-4.9
  18. shell: bash
  19. - name: Install dependency
  20. run: |
  21. sudo apt-get install -y make zlib1g zlib1g-dev bzip2 liblz4-dev libasan0 openssl libmxml-dev wget
  22. - name: update hsql
  23. run: |
  24. sh ${{github.workspace}}/script/download.sh
  25. tar -zxvf hsql.tar.gz
  26. cd hsql
  27. cp -rf include/ ${{github.workspace}}/src/libs/hsql/
  28. cp -f libs/libsqlparser.so ${{github.workspace}}/src/libs/hsql/libs/libsqlparser.so
  29. cp -f libs/libsqlparser.a ${{github.workspace}}/src/libs/hsql/libs/libsqlparser.a
  30. - name: cmake project
  31. run: |
  32. cd ${{github.workspace}}
  33. mkdir build
  34. cd build
  35. cmake ../
  36. make
  37. - name: Login docker hub
  38. uses: docker/login-action@v2
  39. with:
  40. username: ${{ secrets.DOCKER_USERNAME }}
  41. password: ${{ secrets.DOCKER_PASSWORD }}
  42. - name: Publish devel docker
  43. run: |
  44. cd ${{github.workspace}}
  45. cp build/src/core/dtcd dockerfiles/devel/
  46. cp build/src/agent/dtcagent dockerfiles/devel/
  47. cp build/src/agent-watchdog/agent-watchdog dockerfiles/devel/
  48. cp build/src/complex/async-conn dockerfiles/devel/
  49. cp build/src/connector/connector dockerfiles/devel/
  50. cp build/src/data_lifecycle/data-lifecycle-manager dockerfiles/devel/
  51. cp build/src/hwcserver/hwcserver dockerfiles/devel/
  52. cp build/src/rule/librule.so dockerfiles/devel/
  53. cp src/libs/hsql/libs/libsqlparser.so dockerfiles/devel/
  54. cp build/src/utils/conf-gen-utils dockerfiles/devel/
  55. cp src/libs/api/cc_api/libs/libdtcapi.so dockerfiles/devel/
  56. cd dockerfiles/devel/
  57. docker build -t ${{ secrets.DOCKER_USERNAME }}/devel:all .
  58. docker push ${{ secrets.DOCKER_USERNAME }}/devel:all
  59. docker build -t ${{ secrets.DOCKER_USERNAME }}/devel:latest .
  60. docker push ${{ secrets.DOCKER_USERNAME }}/devel:latest
  61. # Core Junction
  62. CORE:
  63. needs: building
  64. runs-on: ubuntu-20.04
  65. steps:
  66. - run: echo "Core Junction."
  67. # Agent Junction
  68. AGENT:
  69. needs: building
  70. runs-on: ubuntu-20.04
  71. steps:
  72. - run: echo "Agent Junction."
  73. # Layered Junction
  74. LAYERED:
  75. needs: building
  76. runs-on: ubuntu-20.04
  77. steps:
  78. - run: echo "Layered Junction."
  79. # Testing Cache Only
  80. test-dtc-cache-only:
  81. needs: CORE
  82. runs-on: ubuntu-20.04
  83. services:
  84. dtc:
  85. image: docker.io/kfysck/devel:all
  86. ports:
  87. - 20015:20015
  88. volumes:
  89. - /usr/local/etc:/usr/local/dtc/conf/
  90. options: --name dtc
  91. env:
  92. DTC_BIN: agent-watchdog
  93. DTC_ARGV: -c
  94. steps:
  95. - uses: actions/checkout@v3
  96. - name: Install python dependency
  97. run: |
  98. python -m pip install --upgrade pip
  99. pip install pytest
  100. pip install pymysql
  101. - name: Set up Python 3.7
  102. uses: actions/setup-python@v2
  103. with:
  104. python-version: "3.7"
  105. - name: Copy conf files.
  106. run: |
  107. cd ${{github.workspace}}
  108. sudo cp -f conf/log4cplus.conf /usr/local/etc/
  109. sudo cp -f conf/log4cplus-hwc.conf /usr/local/etc/
  110. sudo cp -f conf/log4cplus-wd.conf /usr/local/etc/
  111. sudo cp -f conf/log4cplus-async.conf /usr/local/etc/
  112. sudo cp -f conf/log4cplus-agent.conf /usr/local/etc/
  113. sudo cp -f conf/log4cplus-life.conf /usr/local/etc/
  114. sudo cp -f dockerfiles/devel/dtc.cacheonly.yaml /usr/local/etc/dtc.yaml
  115. - name: Run Testing Cases
  116. run: |
  117. sleep 5s
  118. docker ps -a
  119. docker logs dtc
  120. cd ${{github.workspace}}/tests
  121. pytest test_dtcd_cache_only.py
  122. # Testing Cache Only via Agent.
  123. test-agent-cache-only:
  124. if: false
  125. needs: AGENT
  126. runs-on: ubuntu-20.04
  127. services:
  128. dtc:
  129. image: docker.io/kfysck/devel:all
  130. ports:
  131. - 20015:20015
  132. volumes:
  133. - /usr/local/etc:/usr/local/dtc/conf/
  134. options: --name dtc
  135. env:
  136. DTC_BIN: agent-watchdog
  137. DTC_ARGV: -c
  138. agent:
  139. image: docker.io/kfysck/devel:all
  140. ports:
  141. - 12001:12001
  142. volumes:
  143. - /usr/local/etc:/usr/local/dtc/conf/
  144. options: --name agent
  145. env:
  146. DTC_BIN: agent-watchdog
  147. DTC_ARGV: -a
  148. steps:
  149. - uses: actions/checkout@v3
  150. - name: Install python dependency
  151. run: |
  152. python -m pip install --upgrade pip
  153. pip install pytest
  154. pip install pymysql
  155. sudo apt update
  156. sudo apt install -y net-tools
  157. - name: Set up Python 3.7
  158. uses: actions/setup-python@v2
  159. with:
  160. python-version: "3.7"
  161. - name: Copy conf files.
  162. run: |
  163. cd ${{github.workspace}}
  164. sudo cp -f conf/log4cplus.conf /usr/local/etc/
  165. sudo cp -f conf/log4cplus-hwc.conf /usr/local/etc/
  166. sudo cp -f conf/log4cplus-wd.conf /usr/local/etc/
  167. sudo cp -f conf/log4cplus-async.conf /usr/local/etc/
  168. sudo cp -f conf/log4cplus-agent.conf /usr/local/etc/
  169. sudo cp -f conf/log4cplus-life.conf /usr/local/etc/
  170. sudo cp -f dockerfiles/devel/dtc.cacheonly.yaml /usr/local/etc/dtc.yaml
  171. sudo cp -f dockerfiles/devel/agent.single.dtcd.xml /usr/local/etc/agent.xml
  172. - name: Run Testing Cases
  173. run: |
  174. sleep 5s
  175. docker ps -a
  176. netstat -ntpl
  177. docker logs agent
  178. docker logs dtc
  179. cd ${{github.workspace}}/tests
  180. pytest test_agent_cache_only.py
  181. # Testing Layered Storage.
  182. test-agent-layered:
  183. if: false
  184. needs: LAYERED
  185. runs-on: ubuntu-20.04
  186. services:
  187. mysql:
  188. image: mysql:5.7
  189. ports:
  190. - 3306:3306
  191. env:
  192. MYSQL_ROOT_PASSWORD: 123456
  193. agent:
  194. image: docker.io/kfysck/devel:all
  195. ports:
  196. - 12001:12001
  197. volumes:
  198. - /usr/local/etc:/usr/local/dtc/conf/
  199. options: --name agent
  200. env:
  201. DTC_BIN: agent-watchdog
  202. DTC_ARGV: -ayc
  203. steps:
  204. - uses: actions/checkout@v3
  205. - name: Install python dependency
  206. run: |
  207. python -m pip install --upgrade pip
  208. pip install pytest
  209. pip install pymysql
  210. - name: Set up Python 3.7
  211. uses: actions/setup-python@v2
  212. with:
  213. python-version: "3.7"
  214. - name: Init db table
  215. run: |
  216. sleep 5s
  217. mysql -h127.0.0.1 -uroot -p123456 -e "create database layer2;"
  218. mysql -h127.0.0.1 -uroot -p123456 -Dlayer2 -e "source tests/init.s1.sql;"
  219. mysql -h127.0.0.1 -uroot -p123456 -Dlayer2 -e "show tables;"
  220. mysql -h127.0.0.1 -uroot -p123456 -Dlayer2 -e "desc opensource;"
  221. mysql -h127.0.0.1 -uroot -p123456 -e "create database layer3;"
  222. mysql -h127.0.0.1 -uroot -p123456 -Dlayer3 -e "source tests/init.s1.sql;"
  223. mysql -h127.0.0.1 -uroot -p123456 -Dlayer3 -e "show tables;"
  224. mysql -h127.0.0.1 -uroot -p123456 -Dlayer3 -e "desc opensource;"
  225. - name: Copy conf files.
  226. run: |
  227. cd ${{github.workspace}}
  228. sudo cp -f conf/log4cplus.conf /usr/local/etc/
  229. sudo cp -f conf/log4cplus-hwc.conf /usr/local/etc/
  230. sudo cp -f conf/log4cplus-wd.conf /usr/local/etc/
  231. sudo cp -f conf/log4cplus-async.conf /usr/local/etc/
  232. sudo cp -f conf/log4cplus-agent.conf /usr/local/etc/
  233. sudo cp -f conf/log4cplus-life.conf /usr/local/etc/
  234. sudo cp -f dockerfiles/devel/dtc.layered.yaml /usr/local/etc/dtc.yaml
  235. sudo cp -f dockerfiles/devel/agent.layered.xml /usr/local/etc/agent.xml
  236. - name: Run Testing Cases
  237. run: |
  238. sleep 5s
  239. docker ps -a
  240. netstat -ntpl
  241. docker logs agent
  242. cd ${{github.workspace}}/tests
  243. echo "show databases;"
  244. mysql -h127.0.0.1 -P12001 -uroot -p123456 -e "show databases;"
  245. echo "use layer2;"
  246. mysql -h127.0.0.1 -P12001 -uroot -p123456 -Dlayer2 -e "use layer2;"
  247. echo "show tables;"
  248. mysql -h127.0.0.1 -P12001 -uroot -p123456 -Dlayer2 -e "show tables;"
  249. # pytest test_agent_cache_only.py
  250. # Testing Cache with Datasource Scene 1 (Single DB and Single Table)
  251. test-dtc-ds-S-db-S-table:
  252. needs: CORE
  253. runs-on: ubuntu-20.04
  254. services:
  255. mysql:
  256. image: mysql:5.7
  257. ports:
  258. - 3306:3306
  259. env:
  260. MYSQL_ROOT_PASSWORD: 123456
  261. dtc:
  262. image: docker.io/kfysck/devel:all
  263. ports:
  264. - 20015:20015
  265. volumes:
  266. - /usr/local/etc:/usr/local/dtc/conf/
  267. options: --name dtc
  268. env:
  269. DTC_BIN: agent-watchdog
  270. DTC_ARGV: -c
  271. steps:
  272. - uses: actions/checkout@v3
  273. - name: Install python dependency
  274. run: |
  275. python -m pip install --upgrade pip
  276. pip install pytest
  277. pip install pymysql
  278. - name: Set up Python 3.7
  279. uses: actions/setup-python@v2
  280. with:
  281. python-version: "3.7"
  282. - name: Init db table
  283. run: |
  284. sleep 5s
  285. mysql -h127.0.0.1 -uroot -p123456 -e "create database layer2;"
  286. mysql -h127.0.0.1 -uroot -p123456 -Dlayer2 -e "source tests/init.s1.sql;"
  287. mysql -h127.0.0.1 -uroot -p123456 -Dlayer2 -e "show tables;"
  288. mysql -h127.0.0.1 -uroot -p123456 -Dlayer2 -e "desc opensource;"
  289. - name: Copy conf files.
  290. run: |
  291. cd ${{github.workspace}}
  292. sudo cp -f conf/log4cplus.conf /usr/local/etc/
  293. sudo cp -f conf/log4cplus-wd.conf /usr/local/etc/
  294. sudo cp -f conf/log4cplus-hwc.conf /usr/local/etc/
  295. sudo cp -f conf/log4cplus-async.conf /usr/local/etc/
  296. sudo cp -f conf/log4cplus-agent.conf /usr/local/etc/
  297. sudo cp -f conf/log4cplus-life.conf /usr/local/etc/
  298. sudo cp -f dockerfiles/devel/dtc.dbaddition.s1.yaml /usr/local/etc/dtc.yaml
  299. - name: Run Testing Cases
  300. run: |
  301. sleep 5s
  302. docker ps -a
  303. docker logs dtc
  304. cd ${{github.workspace}}/tests
  305. pytest test_dtcd_datasource_s1.py
  306. # Testing Cache with Datasource Scene 1 (Single DB and Single Table) via Agent
  307. test-agent-ds-S-db-S-table:
  308. needs: AGENT
  309. if: false
  310. runs-on: ubuntu-20.04
  311. services:
  312. mysql:
  313. image: mysql:5.7
  314. ports:
  315. - 3306:3306
  316. env:
  317. MYSQL_ROOT_PASSWORD: 123456
  318. agent:
  319. image: docker.io/kfysck/devel:all
  320. ports:
  321. - 12001:12001
  322. volumes:
  323. - /usr/local/etc:/usr/local/dtc/conf/
  324. options: --name agent
  325. env:
  326. DTC_BIN: dtcagent
  327. dtc:
  328. image: docker.io/kfysck/devel:all
  329. ports:
  330. - 20015:20015
  331. volumes:
  332. - /usr/local/etc:/usr/local/dtc/conf/
  333. options: --name dtc
  334. env:
  335. DTC_BIN: agent-watchdog
  336. DTC_ARGV: -c
  337. steps:
  338. - uses: actions/checkout@v3
  339. - name: Install python dependency
  340. run: |
  341. python -m pip install --upgrade pip
  342. pip install pytest
  343. pip install pymysql
  344. - name: Set up Python 3.7
  345. uses: actions/setup-python@v2
  346. with:
  347. python-version: "3.7"
  348. - name: Init db table
  349. run: |
  350. sleep 5s
  351. mysql -h127.0.0.1 -uroot -p123456 -e "create database layer2;"
  352. mysql -h127.0.0.1 -uroot -p123456 -Dlayer2 -e "source tests/init.s1.sql;"
  353. mysql -h127.0.0.1 -uroot -p123456 -Dlayer2 -e "show tables;"
  354. mysql -h127.0.0.1 -uroot -p123456 -Dlayer2 -e "desc opensource;"
  355. - name: Copy conf files.
  356. run: |
  357. cd ${{github.workspace}}
  358. sudo cp -f conf/log4cplus.conf /usr/local/etc/
  359. sudo cp -f conf/log4cplus-hwc.conf /usr/local/etc/
  360. sudo cp -f conf/log4cplus-wd.conf /usr/local/etc/
  361. sudo cp -f conf/log4cplus-async.conf /usr/local/etc/
  362. sudo cp -f conf/log4cplus-agent.conf /usr/local/etc/
  363. sudo cp -f conf/log4cplus-life.conf /usr/local/etc/
  364. sudo cp -f dockerfiles/devel/dtc.dbaddition.s1.yaml /usr/local/etc/dtc.yaml
  365. sudo cp -f dockerfiles/devel/agent.single.dtcd.xml /usr/local/etc/agent.xml
  366. - name: Run Testing Cases
  367. run: |
  368. sleep 5s
  369. docker ps -a
  370. docker logs agent
  371. docker logs dtc
  372. cd ${{github.workspace}}/tests
  373. pytest test_agent_datasource_s1.py
  374. # Testing Cache with Datasource Scene 2 (Single DB and Multi Table)
  375. test-dtc-ds-S-db-M-table:
  376. needs: CORE
  377. runs-on: ubuntu-20.04
  378. services:
  379. mysql:
  380. image: mysql:5.7
  381. ports:
  382. - 3306:3306
  383. env:
  384. MYSQL_ROOT_PASSWORD: 123456
  385. dtc:
  386. image: docker.io/kfysck/devel:all
  387. ports:
  388. - 20015:20015
  389. volumes:
  390. - /usr/local/etc:/usr/local/dtc/conf/
  391. options: --name dtc
  392. env:
  393. DTC_BIN: agent-watchdog
  394. DTC_ARGV: -c
  395. steps:
  396. - uses: actions/checkout@v3
  397. - name: Install python dependency
  398. run: |
  399. python -m pip install --upgrade pip
  400. pip install pytest
  401. pip install pymysql
  402. - name: Set up Python 3.7
  403. uses: actions/setup-python@v2
  404. with:
  405. python-version: "3.7"
  406. - name: Init db table
  407. run: |
  408. sleep 5s
  409. mysql -h127.0.0.1 -uroot -p123456 -e "create database layer2;"
  410. mysql -h127.0.0.1 -uroot -p123456 -Dlayer2 -e "source tests/init.s2.sql;"
  411. mysql -h127.0.0.1 -uroot -p123456 -Dlayer2 -e "show tables;"
  412. - name: Copy conf files.
  413. run: |
  414. cd ${{github.workspace}}
  415. sudo cp -f conf/log4cplus.conf /usr/local/etc/
  416. sudo cp -f conf/log4cplus-hwc.conf /usr/local/etc/
  417. sudo cp -f conf/log4cplus-wd.conf /usr/local/etc/
  418. sudo cp -f conf/log4cplus-agent.conf /usr/local/etc/
  419. sudo cp -f conf/log4cplus-async.conf /usr/local/etc/
  420. sudo cp -f conf/log4cplus-life.conf /usr/local/etc/
  421. sudo cp -f dockerfiles/devel/dtc.dbaddition.s2.yaml /usr/local/etc/dtc.yaml
  422. - name: Run Testing Cases
  423. run: |
  424. sleep 5s
  425. docker ps -a
  426. docker logs dtc
  427. cd ${{github.workspace}}/tests
  428. pytest test_dtcd_datasource_s2.py