mirror of
https://github.com/NixOS/nixpkgs.git
synced 2024-11-24 16:03:23 +00:00
nixos/mysql: expand tests to mariadb and ensureUsers / ensureDatabases
This commit is contained in:
parent
5bec5e8cb1
commit
3d8090458c
@ -5,7 +5,7 @@ import ./make-test.nix ({ pkgs, ...} : {
|
||||
};
|
||||
|
||||
nodes = {
|
||||
master =
|
||||
mysql =
|
||||
{ pkgs, ... }:
|
||||
|
||||
{
|
||||
@ -13,12 +13,34 @@ import ./make-test.nix ({ pkgs, ...} : {
|
||||
services.mysql.initialDatabases = [ { name = "testdb"; schema = ./testdb.sql; } ];
|
||||
services.mysql.package = pkgs.mysql;
|
||||
};
|
||||
|
||||
mariadb =
|
||||
{ pkgs, ... }:
|
||||
|
||||
{
|
||||
users.users.testuser = { };
|
||||
services.mysql.enable = true;
|
||||
services.mysql.ensureDatabases = [ "testdb" ];
|
||||
services.mysql.ensureUsers = [{
|
||||
name = "testuser";
|
||||
ensurePermissions = {
|
||||
"testdb.*" = "ALL PRIVILEGES";
|
||||
};
|
||||
}];
|
||||
services.mysql.package = pkgs.mariadb;
|
||||
};
|
||||
|
||||
};
|
||||
|
||||
testScript = ''
|
||||
startAll;
|
||||
|
||||
$master->waitForUnit("mysql");
|
||||
$master->succeed("echo 'use testdb; select * from tests' | mysql -u root -N | grep 4");
|
||||
$mysql->waitForUnit("mysql");
|
||||
$mysql->succeed("echo 'use testdb; select * from tests' | mysql -u root -N | grep 4");
|
||||
|
||||
$mariadb->waitForUnit("mysql");
|
||||
$mariadb->succeed("echo 'use testdb; create table tests (test_id INT, PRIMARY KEY (test_id));' | sudo -u testuser mysql -u testuser");
|
||||
$mariadb->succeed("echo 'use testdb; insert into tests values (42);' | sudo -u testuser mysql -u testuser");
|
||||
$mariadb->succeed("echo 'use testdb; select test_id from tests' | sudo -u testuser mysql -u testuser -N | grep 42");
|
||||
'';
|
||||
})
|
||||
|
Loading…
Reference in New Issue
Block a user