diff options
author | ben smith <polynomial@users.noreply.github.com> | 2016-07-22 15:37:05 -0700 |
---|---|---|
committer | Rok Garbas <rok@garbas.si> | 2016-07-23 00:37:05 +0200 |
commit | c38e6a2a6060434d842f173ebe5a4a7d4d99781a (patch) | |
tree | cd90903c64af83649703d81595f929b10605c5e1 /nixos | |
parent | e8343fbb3882e932d23af6141d00a195528cc0b0 (diff) | |
download | nixpkgs-c38e6a2a6060434d842f173ebe5a4a7d4d99781a.tar nixpkgs-c38e6a2a6060434d842f173ebe5a4a7d4d99781a.tar.gz nixpkgs-c38e6a2a6060434d842f173ebe5a4a7d4d99781a.tar.bz2 nixpkgs-c38e6a2a6060434d842f173ebe5a4a7d4d99781a.tar.lz nixpkgs-c38e6a2a6060434d842f173ebe5a4a7d4d99781a.tar.xz nixpkgs-c38e6a2a6060434d842f173ebe5a4a7d4d99781a.tar.zst nixpkgs-c38e6a2a6060434d842f173ebe5a4a7d4d99781a.zip |
mysql: fix replication tests (#17174)
Eliminate race condition in replication test Remove replication configuration from standalone test Improve mysql command syntax consistency
Diffstat (limited to 'nixos')
-rw-r--r-- | nixos/modules/services/databases/mysql.nix | 3 | ||||
-rw-r--r-- | nixos/tests/mysql-replication.nix | 15 | ||||
-rw-r--r-- | nixos/tests/mysql.nix | 1 |
3 files changed, 9 insertions, 10 deletions
diff --git a/nixos/modules/services/databases/mysql.nix b/nixos/modules/services/databases/mysql.nix index 60c6b22e059..0b2f99f8fff 100644 --- a/nixos/modules/services/databases/mysql.nix +++ b/nixos/modules/services/databases/mysql.nix @@ -240,8 +240,9 @@ in # Set up the replication master ( echo "use mysql;" + echo "CREATE USER '${cfg.replication.masterUser}'@'${cfg.replication.slaveHost}' IDENTIFIED WITH mysql_native_password;" + echo "SET PASSWORD FOR '${cfg.replication.masterUser}'@'${cfg.replication.slaveHost}' = PASSWORD('${cfg.replication.masterPassword}');" echo "GRANT REPLICATION SLAVE ON *.* TO '${cfg.replication.masterUser}'@'${cfg.replication.slaveHost}';" - echo "update user set Password=password('${cfg.replication.masterPassword}') where User='${cfg.replication.masterUser}';" ) | ${mysql}/bin/mysql -u root -N ''} diff --git a/nixos/tests/mysql-replication.nix b/nixos/tests/mysql-replication.nix index 0cd8c4484bd..b20bce8edce 100644 --- a/nixos/tests/mysql-replication.nix +++ b/nixos/tests/mysql-replication.nix @@ -19,12 +19,10 @@ in services.mysql.enable = true; services.mysql.package = pkgs.mysql; services.mysql.replication.role = "master"; + services.mysql.replication.slaveHost = "%"; + services.mysql.replication.masterUser = replicateUser; + services.mysql.replication.masterPassword = replicatePassword; services.mysql.initialDatabases = [ { name = "testdb"; schema = ./testdb.sql; } ]; - services.mysql.initialScript = pkgs.writeText "initmysql" - '' - create user '${replicateUser}'@'%' identified by '${replicatePassword}'; - grant replication slave on *.* to '${replicateUser}'@'%'; - ''; networking.firewall.allowedTCPPorts = [ 3306 ]; }; @@ -56,10 +54,11 @@ in }; testScript = '' - startAll; - - $master->waitForUnit("mysql"); + $master->start; $master->waitForUnit("mysql"); + $slave1->start; + $slave2->start; + $slave1->waitForUnit("mysql"); $slave2->waitForUnit("mysql"); $slave2->sleep(100); # Hopefully this is long enough!! $slave2->succeed("echo 'use testdb; select * from tests' | mysql -u root -N | grep 4"); diff --git a/nixos/tests/mysql.nix b/nixos/tests/mysql.nix index 58841161777..baaebf9f10d 100644 --- a/nixos/tests/mysql.nix +++ b/nixos/tests/mysql.nix @@ -10,7 +10,6 @@ import ./make-test.nix ({ pkgs, ...} : { { services.mysql.enable = true; - services.mysql.replication.role = "master"; services.mysql.initialDatabases = [ { name = "testdb"; schema = ./testdb.sql; } ]; services.mysql.package = pkgs.mysql; }; |