2 system ? builtins.currentSystem,
4 pkgs ? import ../../.. { inherit system config; },
9 inherit (import ./common.nix { inherit pkgs lib; }) mkTestName mariadbPackages mysqlPackages perconaPackages;
11 makeTest = import ./../make-test-python.nix;
15 name ? mkTestName package,
18 hasRocksDB ? pkgs.stdenv.hostPlatform.is64bit
22 maintainers = lib.teams.helsinki-systems.members;
30 groups.testusers = { };
46 { name = "testdb3"; schema = ./testdb.sql; }
48 # note that using pkgs.writeText here is generally not a good idea,
49 # as it will store the password in world-readable /nix/store ;)
50 initialScript = pkgs.writeText "mysql-init.sql" (if (!useSocketAuth) then ''
51 CREATE USER 'testuser3'@'localhost' IDENTIFIED BY 'secure';
52 GRANT ALL PRIVILEGES ON testdb3.* TO 'testuser3'@'localhost';
54 ALTER USER root@localhost IDENTIFIED WITH unix_socket;
55 DELETE FROM mysql.user WHERE password = ''' AND plugin = ''';
56 DELETE FROM mysql.user WHERE user = ''';
60 ensureDatabases = [ "testdb" "testdb2" ];
64 "testdb.*" = "ALL PRIVILEGES";
69 "testdb2.*" = "ALL PRIVILEGES";
75 plugin-load-add = lib.optional hasMroonga "ha_mroonga.so"
76 ++ lib.optional hasRocksDB "ha_rocksdb.so";
87 machine.wait_for_unit("mysql")
89 "echo 'use testdb; create table tests (test_id INT, PRIMARY KEY (test_id));' | sudo -u testuser mysql -u testuser"
92 "echo 'use testdb; insert into tests values (42);' | sudo -u testuser mysql -u testuser"
94 # Ensure testuser2 is not able to insert into testdb as mysql testuser2
96 "echo 'use testdb; insert into tests values (23);' | sudo -u testuser2 mysql -u testuser2"
98 # Ensure testuser2 is not able to authenticate as mysql testuser
100 "echo 'use testdb; insert into tests values (23);' | sudo -u testuser2 mysql -u testuser"
103 "echo 'use testdb; select test_id from tests;' | sudo -u testuser mysql -u testuser -N | grep 42"
106 ${lib.optionalString hasMroonga ''
107 # Check if Mroonga plugin works
109 "echo 'use testdb; create table mroongadb (test_id INT, PRIMARY KEY (test_id)) ENGINE = Mroonga;' | sudo -u testuser mysql -u testuser"
112 "echo 'use testdb; insert into mroongadb values (25);' | sudo -u testuser mysql -u testuser"
115 "echo 'use testdb; select test_id from mroongadb;' | sudo -u testuser mysql -u testuser -N | grep 25"
118 "echo 'use testdb; drop table mroongadb;' | sudo -u testuser mysql -u testuser"
122 ${lib.optionalString hasRocksDB ''
123 # Check if RocksDB plugin works
125 "echo 'use testdb; create table rocksdb (test_id INT, PRIMARY KEY (test_id)) ENGINE = RocksDB;' | sudo -u testuser mysql -u testuser"
128 "echo 'use testdb; insert into rocksdb values (28);' | sudo -u testuser mysql -u testuser"
131 "echo 'use testdb; select test_id from rocksdb;' | sudo -u testuser mysql -u testuser -N | grep 28"
134 "echo 'use testdb; drop table rocksdb;' | sudo -u testuser mysql -u testuser"
140 lib.mapAttrs (_: package: makeMySQLTest {
142 hasRocksDB = false; hasMroonga = false; useSocketAuth = false;
144 // (lib.mapAttrs (_: package: makeMySQLTest {
147 // (lib.mapAttrs (_: package: makeMySQLTest {
149 name = builtins.replaceStrings ["-"] ["_"] package.pname;
150 hasMroonga = false; useSocketAuth = false;