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 = {
|
nodes = {
|
||||||
master =
|
mysql =
|
||||||
{ pkgs, ... }:
|
{ pkgs, ... }:
|
||||||
|
|
||||||
{
|
{
|
||||||
@ -13,12 +13,34 @@ import ./make-test.nix ({ pkgs, ...} : {
|
|||||||
services.mysql.initialDatabases = [ { name = "testdb"; schema = ./testdb.sql; } ];
|
services.mysql.initialDatabases = [ { name = "testdb"; schema = ./testdb.sql; } ];
|
||||||
services.mysql.package = pkgs.mysql;
|
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 = ''
|
testScript = ''
|
||||||
startAll;
|
startAll;
|
||||||
|
|
||||||
$master->waitForUnit("mysql");
|
$mysql->waitForUnit("mysql");
|
||||||
$master->succeed("echo 'use testdb; select * from tests' | mysql -u root -N | grep 4");
|
$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…
x
Reference in New Issue
Block a user