Execute integration test mysql deploy with docker

Execute integration test mysql deploy with docker

The integration test needs to use flywayDB to manage the script information of the database according to the test case. Each time before the production goes online, it must pass the integration test to verify the accuracy of the data. Therefore, each integration test is the database instance mysql-5.7.16-instance-group1 of the docker.

Note: This is not the configuration information of the complete project, but the configuration related to docker mysql

Using docker compose to start scripts

-rw-r--r-- 1 root  root   312 1month  15 10:47 docker-compose-mysql.yml
-rw-r--r-- 1 root  root   624 1month  15 17:06 mysqld_charset.cnf
[root@wallbase ~]# docker-compose -f docker-compose-mysql.yml up -d

Using docker to deploy mysql migration

  • TZ: "Asia/Shanghai" time zone configuration, the default is zero time zone, so you need to modify it yourself
  • "/ data/mysql/data:/var/lib/mysql" the mysql database is persisted to the host disk (in fact, the test does not need to be saved to the disk, but the data will be retained for a month for other reasons).

docker-compose-mysql.yml

version: "2.0"
services:
  mysqldb:
    image: mysql:5.7.16
    container_name: mysql-5.7.16
    restart: always
    ports:
      - "3306:3306"
    environment:
      TZ: "Asia/Shanghai"
    volumes:
       - "/data/mysql/data:/var/lib/mysql"
       - "./mysqld_charset.cnf:/etc/mysql/conf.d/mysqld_charset.cnf"

Notes on mysql configuration

  • autocommit = 1 commit the transaction by default. The configuration file is the configuration item placed in / etc/mysql/conf.d, which will overwrite the previous configuration item

mysqld_charset.cnf

[client]
default-character-set          = utf8

[mysql]
default-character-set          = utf8mb4

[mysqld]
port                           = 3306
autocommit                     = 1
#character_set_filesystem      = utf8
character_set_server           = utf8
collation-server               = utf8_general_ci
init-connect                   = 'SET NAMES utf8'
init_connect                   = 'SET collation_connection = utf8_general_ci'
skip-character-set-client-handshake
max_allowed_packet             = 100M
default-storage-engine         = INNODB
sql_mode                       = NO_ENGINE_SUBSTITUTION,STRICT_TRANS_TABLES

Tags: MySQL Docker Database

Posted on Mon, 04 May 2020 17:40:07 -0700 by Entanio