From 16e723d698e7d072dd962a79d2ab20354e19a1db Mon Sep 17 00:00:00 2001 From: shixinwu Date: Mon, 29 Jul 2024 10:39:59 -0400 Subject: [PATCH] Dockerfile refactoring changes --- classes/CCR/DB/MySQLHelper.php | 51 +++++++++++++++++-- classes/OpenXdmod/Setup/DatabaseSetup.php | 5 +- classes/OpenXdmod/Shared/DatabaseHelper.php | 49 +++++++++++++----- .../etl_tables.d/cloud_common/domains.json | 1 + .../etl/etl_tables.d/gateways/enduser.json | 4 +- .../etl/etl_tables.d/gateways/gateway.json | 4 +- .../etl_tables.d/gateways/job_metadata.json | 4 +- .../jobs/xdw/federation-instances.json | 4 +- .../xdb/report-template-charts.json | 4 +- .../db_model_baseline_table.json | 4 +- .../db_model_normalize_table_definitions.json | 8 +-- .../configuration/output/create_table.json | 8 +-- .../configuration/output/modify_table.json | 12 ++--- .../output/normalized_table_definition.json | 10 ++-- .../rename_and_reorder_table_column.json | 12 ++--- .../output/reorder_table_columns.json | 12 ++--- .../dbmodel/input/table_def_2-charset.json | 8 +-- .../dbmodel/output/alter_table-charset.sql | 6 +-- .../output/alter_table_manually-charset.sql | 8 +-- tests/ci/bootstrap.sh | 34 ++----------- tests/ci/scripts/xdmod-setup-start.tcl | 3 +- tests/unit/lib/ETL/DbModel/DbModelTest.php | 18 +++---- 22 files changed, 157 insertions(+), 112 deletions(-) diff --git a/classes/CCR/DB/MySQLHelper.php b/classes/CCR/DB/MySQLHelper.php index aa3379c8fe..ae829afee6 100644 --- a/classes/CCR/DB/MySQLHelper.php +++ b/classes/CCR/DB/MySQLHelper.php @@ -342,6 +342,47 @@ public static function databaseExists( throw new Exception($msg); } } + /* + * Checks for existence of user + */ + /** + * @throws Exception + */ + public static function userExists( + $host, + $port, + $dbusername, + $dbpassword, + $userName, + $xdmod_host + ) { + $stmt = "SELECT User, Host FROM mysql.user WHERE User = '$userName' AND Host = '$xdmod_host'"; + $output = static::staticExecuteStatement( + $host, + $port, + $dbusername, + $dbpassword, + null, + $stmt + ); + + $output = preg_replace('/\s+/', ' ', $output); + if (!isset($output[0])) { + return false; + } + $output = explode(' ', $output[0]); + if (count($output) == 0 || (count($output) == 1 && $output[0] == '')) { + return false; + } elseif (count($output) == 2 && $output[0] == $userName && $output[1]== $xdmod_host) { + return true; + } else { + $msg = 'Failed to check for existence of user: ' + . implode("\n", array_map(function($row) { + return $row[0] . ' ' . $row[1]; + }, $output)); + throw new Exception($msg); + } + } /** * Create a database. @@ -415,7 +456,7 @@ public static function grantAllPrivileges( $port, $username, $password, - $localHost, + $xdmodHost, $dbUsername, $dbPassword ) { @@ -429,8 +470,8 @@ public static function grantAllPrivileges( . " CREATE ROUTINE, ALTER ROUTINE, EVENT, RELOAD, FILE," . " CREATE TABLESPACE, PROCESS, REFERENCES," . " LOCK TABLES" - . " ON *.* TO '$dbUsername'@'$localHost'" - . " IDENTIFIED BY '$dbPassword';FLUSH PRIVILEGES;"; + . " ON *.* TO '$dbUsername'@'$xdmodHost';" + . " FLUSH PRIVILEGES;"; static::staticExecuteStatement( $host, @@ -460,11 +501,11 @@ public static function grantAllPrivilegesOnDatabase( $username, $password, $dbName, - $localHost, + $xdmodHost, $dbUsername, $dbPassword ) { - $stmt = "GRANT ALL ON $dbName.* TO '$dbUsername'@'$localHost'" + $stmt = "GRANT ALL ON $dbName.* TO '$dbUsername'@'$xdmodHost'" . " IDENTIFIED BY '$dbPassword'"; static::staticExecuteStatement( diff --git a/classes/OpenXdmod/Setup/DatabaseSetup.php b/classes/OpenXdmod/Setup/DatabaseSetup.php index 782b532a22..a28ed7d2b6 100644 --- a/classes/OpenXdmod/Setup/DatabaseSetup.php +++ b/classes/OpenXdmod/Setup/DatabaseSetup.php @@ -58,7 +58,10 @@ public function handle() 'DB Username:', $settings['database_user'] ); - + $settings['xdmod_host'] = $this->console->prompt( + 'XDMoD Server name:', + $settings['database_host'] + ); $settings['db_pass'] = $this->console->silentPrompt( 'DB Password:' ); diff --git a/classes/OpenXdmod/Shared/DatabaseHelper.php b/classes/OpenXdmod/Shared/DatabaseHelper.php index bcfa22b54e..429b82a6b0 100644 --- a/classes/OpenXdmod/Shared/DatabaseHelper.php +++ b/classes/OpenXdmod/Shared/DatabaseHelper.php @@ -2,6 +2,7 @@ namespace OpenXdmod\Shared; +use CCR\DB; use CCR\DB\MySQLHelper; use OpenXdmod\Setup\Console; @@ -24,6 +25,7 @@ class DatabaseHelper * @param Console $console (Optional) The console to use to prompt the user. * If not provided, one will be obtained. */ + public static function createDatabases( $username, $password, @@ -35,23 +37,50 @@ public static function createDatabases( $console = Console::factory(); } + $rows = MySQLHelper::userExists( + $settings['db_host'], + $settings['db_port'], + $username, + $password, + $settings['db_user'], + $settings['xdmod_host'] + ); $console->displayMessage( - 'Creating User ' . $settings['db_user'] + 'rows retuned' . $rows ); - // TODO: If db_host is not localhost, need to set $localHost to - // the correct hostname or IP address. - $localHost = $settings['db_host']; - + if ($rows == false) { + $console->displayMessage( + 'Creating User ' . $settings['db_user'] + ); + $console->displayMessage( + 'Creating User with ' . $settings['db_user'] . ' on host ' . $settings['xdmod_host'] . ' with password ' . $settings['db_pass'] + ); + MySQLHelper::staticExecuteStatement( + $settings['db_host'], + $settings['db_port'], + $username, + $password, + null, + sprintf( + "CREATE USER '%s'@'%s' IDENTIFIED BY '%s';", + $settings['db_user'], + $settings['xdmod_host'], + $settings['db_pass'], + ) + ); + $console->displayMessage( + 'Created User' + ); + } MySQLHelper::grantAllPrivileges( $settings['db_host'], $settings['db_port'], $username, $password, - $localHost, + $settings['xdmod_host'], $settings['db_user'], $settings['db_pass'] ); - foreach ($databases as $database) { $console->displayBlankLine(); @@ -97,10 +126,6 @@ public static function createDatabases( $database ); - // TODO: If db_host is not localhost, need to set $localHost to - // the correct hostname or IP address. - $localHost = $settings['db_host']; - $console->displayMessage( "Granting privileges on database `$database`." ); @@ -110,7 +135,7 @@ public static function createDatabases( $username, $password, $database, - $localHost, + $settings['xdmod_host'], $settings['db_user'], $settings['db_pass'] ); diff --git a/configuration/etl/etl_tables.d/cloud_common/domains.json b/configuration/etl/etl_tables.d/cloud_common/domains.json index 12f1495de4..f3127696cf 100644 --- a/configuration/etl/etl_tables.d/cloud_common/domains.json +++ b/configuration/etl/etl_tables.d/cloud_common/domains.json @@ -4,6 +4,7 @@ "name": "domains", "engine": "InnoDB", "charset": "utf8", + "collation": "utf8_unicode_ci", "comment": "Which domains are currently being tracked by the Cloud realm", "columns": [ { diff --git a/configuration/etl/etl_tables.d/gateways/enduser.json b/configuration/etl/etl_tables.d/gateways/enduser.json index 9e8edbea5d..1232f8aa4b 100644 --- a/configuration/etl/etl_tables.d/gateways/enduser.json +++ b/configuration/etl/etl_tables.d/gateways/enduser.json @@ -3,8 +3,8 @@ "name": "enduser", "comment": "Associate local gateway enduser names with the gateway on which they are registered", "engine": "myisam", - "charset": "utf8mb4", - "collation": "utf8mb4_general_ci", + "charset": "utf8", + "collation": "utf8_unicode_ci", "columns": [ { "type": "int(11)", diff --git a/configuration/etl/etl_tables.d/gateways/gateway.json b/configuration/etl/etl_tables.d/gateways/gateway.json index bfc574f82a..f9bc327108 100644 --- a/configuration/etl/etl_tables.d/gateways/gateway.json +++ b/configuration/etl/etl_tables.d/gateways/gateway.json @@ -3,8 +3,8 @@ "name": "gateway", "comment": "Listing of Science Gateways", "engine": "myisam", - "charset": "utf8mb4", - "collation": "utf8mb4_general_ci", + "charset": "utf8", + "collation": "utf8_unicode_ci", "columns": [ { "type": "int(11)", diff --git a/configuration/etl/etl_tables.d/gateways/job_metadata.json b/configuration/etl/etl_tables.d/gateways/job_metadata.json index ebe6741bb4..2b7115a110 100644 --- a/configuration/etl/etl_tables.d/gateways/job_metadata.json +++ b/configuration/etl/etl_tables.d/gateways/job_metadata.json @@ -3,8 +3,8 @@ "name": "job_metadata", "comment": "Metadata associated with gateways-submitted jobs", "engine": "myisam", - "charset": "utf8mb4", - "collation": "utf8mb4_general_ci", + "charset": "utf8", + "collation": "utf8_unicode_ci", "columns": [ { "type": "int(11)", diff --git a/configuration/etl/etl_tables.d/jobs/xdw/federation-instances.json b/configuration/etl/etl_tables.d/jobs/xdw/federation-instances.json index e028fdfc21..3013ebdce1 100644 --- a/configuration/etl/etl_tables.d/jobs/xdw/federation-instances.json +++ b/configuration/etl/etl_tables.d/jobs/xdw/federation-instances.json @@ -12,13 +12,13 @@ { "name": "prefix", "type": "varchar(191)", - "comment": "generally fqdn with . replaced by - 191 limit due to utf8mb4", + "comment": "generally fqdn with . replaced by - 191 limit due to utf8", "nullable": true }, { "name": "timezone", "type": "varchar(191)", - "comment": "Timezone of the instance - 191 limit due to utf8mb4", + "comment": "Timezone of the instance - 191 limit due to utf8", "nullable": true }, { diff --git a/configuration/etl/etl_tables.d/xdb/report-template-charts.json b/configuration/etl/etl_tables.d/xdb/report-template-charts.json index a473bc021e..c6e86ee328 100644 --- a/configuration/etl/etl_tables.d/xdb/report-template-charts.json +++ b/configuration/etl/etl_tables.d/xdb/report-template-charts.json @@ -2,8 +2,8 @@ "table_definition": { "name": "ReportTemplateCharts", "engine": "InnoDB", - "charset": "utf8mb4", - "collation": "utf8mb4_general_ci", + "charset": "utf8", + "collation": "utf8_unicode_ci", "columns": [ { "name": "template_id", diff --git a/tests/artifacts/xdmod/etlv2/configuration/input/etl_tables_8.0.0.d/db_model_baseline_table.json b/tests/artifacts/xdmod/etlv2/configuration/input/etl_tables_8.0.0.d/db_model_baseline_table.json index 4ddf72d2bc..9257af16a3 100644 --- a/tests/artifacts/xdmod/etlv2/configuration/input/etl_tables_8.0.0.d/db_model_baseline_table.json +++ b/tests/artifacts/xdmod/etlv2/configuration/input/etl_tables_8.0.0.d/db_model_baseline_table.json @@ -4,7 +4,7 @@ "name": "normalize_table_test", "engine": "MyISAM", "charset": "utf8", - "collation": "utf8_general_ci", + "collation": "utf8_unicode_ci", "columns": [ { "name": "resource_id", @@ -17,7 +17,7 @@ "type": "varchar(40)", "nullable": true, "charset": "utf8", - "collation": "utf8_general_ci", + "collation": "utf8_unicode_ci", "comment": "This is a comment" }, { diff --git a/tests/artifacts/xdmod/etlv2/configuration/input/etl_tables_8.0.0.d/db_model_normalize_table_definitions.json b/tests/artifacts/xdmod/etlv2/configuration/input/etl_tables_8.0.0.d/db_model_normalize_table_definitions.json index 36241f0518..aa1c25e720 100644 --- a/tests/artifacts/xdmod/etlv2/configuration/input/etl_tables_8.0.0.d/db_model_normalize_table_definitions.json +++ b/tests/artifacts/xdmod/etlv2/configuration/input/etl_tables_8.0.0.d/db_model_normalize_table_definitions.json @@ -3,8 +3,8 @@ "table_definition": { "name": "normalize_table_test", "engine": "myisam", - "charset": "UTF8", - "collation": "UTF8_GENERAL_CI", + "charset": "utf8", + "collation": "utf8_unicode_ci", "columns": [ { "name": "resource_id", @@ -16,8 +16,8 @@ "name": "RESOURCE", "type": "VARCHAR(40)", "nullable": true, - "charset": "UTF8", - "collation": "utf8_general_ci", + "charset": "utf8", + "collation": "utf8_unicode_ci", "comment": "This is a comment" }, { diff --git a/tests/artifacts/xdmod/etlv2/configuration/output/create_table.json b/tests/artifacts/xdmod/etlv2/configuration/output/create_table.json index d81e605cd2..838efd0e8c 100644 --- a/tests/artifacts/xdmod/etlv2/configuration/output/create_table.json +++ b/tests/artifacts/xdmod/etlv2/configuration/output/create_table.json @@ -1,13 +1,13 @@ { "comment": "", "engine": "myisam", - "charset": "latin1", - "collation": "latin1_swedish_ci", + "charset": "utf8", + "collation": "utf8_unicode_ci", "columns": [ { "type": "varchar(40)", - "charset": "latin1", - "collation": "latin1_swedish_ci", + "charset": "utf8", + "collation": "utf8_unicode_ci", "nullable": true, "default": null, "extra": null, diff --git a/tests/artifacts/xdmod/etlv2/configuration/output/modify_table.json b/tests/artifacts/xdmod/etlv2/configuration/output/modify_table.json index 5acc366bfe..e78a3f031d 100644 --- a/tests/artifacts/xdmod/etlv2/configuration/output/modify_table.json +++ b/tests/artifacts/xdmod/etlv2/configuration/output/modify_table.json @@ -1,13 +1,13 @@ { "comment": "", "engine": "myisam", - "charset": "latin1", - "collation": "latin1_swedish_ci", + "charset": "utf8", + "collation": "utf8_unicode_ci", "columns": [ { "type": "varchar(40)", - "charset": "latin1", - "collation": "latin1_swedish_ci", + "charset": "utf8", + "collation": "utf8_unicode_ci", "nullable": true, "default": null, "extra": null, @@ -17,8 +17,8 @@ }, { "type": "varchar(40)", - "charset": "latin1", - "collation": "latin1_swedish_ci", + "charset": "utf8", + "collation": "utf8_unicode_ci", "nullable": true, "default": null, "extra": null, diff --git a/tests/artifacts/xdmod/etlv2/configuration/output/normalized_table_definition.json b/tests/artifacts/xdmod/etlv2/configuration/output/normalized_table_definition.json index f88f656a30..d067ac07c4 100644 --- a/tests/artifacts/xdmod/etlv2/configuration/output/normalized_table_definition.json +++ b/tests/artifacts/xdmod/etlv2/configuration/output/normalized_table_definition.json @@ -2,7 +2,7 @@ "comment": "", "engine": "myisam", "charset": "utf8", - "collation": "utf8_general_ci", + "collation": "utf8_unicode_ci", "columns": [ { "type": "int(11) unsigned", @@ -18,7 +18,7 @@ { "type": "varchar(40)", "charset": "utf8", - "collation": "utf8_general_ci", + "collation": "utf8_unicode_ci", "nullable": true, "default": null, "extra": null, @@ -29,7 +29,7 @@ { "type": "varchar(16)", "charset": "utf8", - "collation": "utf8_general_ci", + "collation": "utf8_unicode_ci", "nullable": false, "default": "first name", "extra": null, @@ -40,7 +40,7 @@ { "type": "enum('Sample1','sample2')", "charset": "utf8", - "collation": "utf8_general_ci", + "collation": "utf8_unicode_ci", "nullable": true, "default": null, "extra": null, @@ -75,7 +75,7 @@ "event": "INSERT", "table": "normalize_table_test", "body": "BEGIN\nSET @resource = CONCAT(@resource, 'X');\nEND", - "definer": "xdmod@localhost", + "definer": "xdmod@xdmod.xdmod_default", "schema": "test", "name": "mytrigger" } diff --git a/tests/artifacts/xdmod/etlv2/configuration/output/rename_and_reorder_table_column.json b/tests/artifacts/xdmod/etlv2/configuration/output/rename_and_reorder_table_column.json index e460be8108..ce3c608683 100644 --- a/tests/artifacts/xdmod/etlv2/configuration/output/rename_and_reorder_table_column.json +++ b/tests/artifacts/xdmod/etlv2/configuration/output/rename_and_reorder_table_column.json @@ -1,13 +1,13 @@ { "comment": "", "engine": "myisam", - "charset": "latin1", - "collation": "latin1_swedish_ci", + "charset": "utf8", + "collation": "utf8_unicode_ci", "columns": [ { "type": "varchar(40)", - "charset": "latin1", - "collation": "latin1_swedish_ci", + "charset": "utf8", + "collation": "utf8_unicode_ci", "nullable": true, "default": null, "extra": null, @@ -17,8 +17,8 @@ }, { "type": "varchar(40)", - "charset": "latin1", - "collation": "latin1_swedish_ci", + "charset": "utf8", + "collation": "utf8_unicode_ci", "nullable": true, "default": null, "extra": null, diff --git a/tests/artifacts/xdmod/etlv2/configuration/output/reorder_table_columns.json b/tests/artifacts/xdmod/etlv2/configuration/output/reorder_table_columns.json index 6fe05fe4bc..fbb81facc7 100644 --- a/tests/artifacts/xdmod/etlv2/configuration/output/reorder_table_columns.json +++ b/tests/artifacts/xdmod/etlv2/configuration/output/reorder_table_columns.json @@ -1,13 +1,13 @@ { "comment": "", "engine": "myisam", - "charset": "latin1", - "collation": "latin1_swedish_ci", + "charset": "utf8", + "collation": "utf8_unicode_ci", "columns": [ { "type": "varchar(40)", - "charset": "latin1", - "collation": "latin1_swedish_ci", + "charset": "utf8", + "collation": "utf8_unicode_ci", "nullable": true, "default": null, "extra": null, @@ -17,8 +17,8 @@ }, { "type": "varchar(40)", - "charset": "latin1", - "collation": "latin1_swedish_ci", + "charset": "utf8", + "collation": "utf8_unicode_ci", "nullable": true, "default": null, "extra": null, diff --git a/tests/artifacts/xdmod/etlv2/dbmodel/input/table_def_2-charset.json b/tests/artifacts/xdmod/etlv2/dbmodel/input/table_def_2-charset.json index 62d8cd9387..0a1eb31619 100644 --- a/tests/artifacts/xdmod/etlv2/dbmodel/input/table_def_2-charset.json +++ b/tests/artifacts/xdmod/etlv2/dbmodel/input/table_def_2-charset.json @@ -3,8 +3,8 @@ "table_definition": { "name": "test_db_model", "engine": "InnoDB", - "charset": "utf8mb4", - "collation": "utf8mb4_general_ci", + "charset": "utf8", + "collation": "utf8_unicode_ci", "comment": "Events on an instance", "columns": [ { @@ -17,8 +17,8 @@ { "name": "col1", "type": "varchar(32)", - "charset": "utf8mb4", - "collation": "utf8mb4_general_ci", + "charset": "utf8", + "collation": "utf8_unicode_ci", "nullable": false, "default": "mydefault" }, diff --git a/tests/artifacts/xdmod/etlv2/dbmodel/output/alter_table-charset.sql b/tests/artifacts/xdmod/etlv2/dbmodel/output/alter_table-charset.sql index 33280a0ed1..ab731355ce 100644 --- a/tests/artifacts/xdmod/etlv2/dbmodel/output/alter_table-charset.sql +++ b/tests/artifacts/xdmod/etlv2/dbmodel/output/alter_table-charset.sql @@ -1,10 +1,10 @@ ALTER TABLE `test_db_model` -CHARSET = utf8mb4, -COLLATE = utf8mb4_general_ci, +CHARSET = utf8, +COLLATE = utf8_unicode_ci, DROP INDEX `fk_instance`, ADD INDEX `fk_instance` USING BTREE (`instance_id`, `inferred`); ALTER TABLE `test_db_model` -CHANGE COLUMN `col1` `col1` varchar(32) CHARSET utf8mb4 COLLATE utf8mb4_general_ci NOT NULL DEFAULT 'mydefault' , +CHANGE COLUMN `col1` `col1` varchar(32) CHARSET utf8 COLLATE utf8_unicode_ci NOT NULL DEFAULT 'mydefault' , CHANGE COLUMN `instance_id` `instance_id` int(11) NULL DEFAULT -1 ; ALTER TABLE `test_db_model` DROP FOREIGN KEY `con_col1`; diff --git a/tests/artifacts/xdmod/etlv2/dbmodel/output/alter_table_manually-charset.sql b/tests/artifacts/xdmod/etlv2/dbmodel/output/alter_table_manually-charset.sql index d79f891376..3495fc6ccb 100644 --- a/tests/artifacts/xdmod/etlv2/dbmodel/output/alter_table_manually-charset.sql +++ b/tests/artifacts/xdmod/etlv2/dbmodel/output/alter_table_manually-charset.sql @@ -1,14 +1,14 @@ ALTER TABLE `test_db_model` -CHARSET = utf8mb4, -COLLATE = utf8mb4_general_ci, +CHARSET = utf8, +COLLATE = utf8_unicode_ci, ADD COLUMN `new_column` boolean NOT NULL DEFAULT 0 AFTER `inferred`, -ADD COLUMN `new_column2` char(64) CHARSET utf8mb4 COLLATE utf8mb4_general_ci NULL AFTER `new_column`, +ADD COLUMN `new_column2` char(64) CHARSET utf8 COLLATE utf8_unicode_ci NULL AFTER `new_column`, ADD INDEX `index_new_column` (`new_column`), DROP INDEX `fk_instance`, ADD INDEX `fk_instance` USING BTREE (`instance_id`, `inferred`), ADD CONSTRAINT `fk_new_column` FOREIGN KEY (`new_column`) REFERENCES `other_table` (`other_column`); ALTER TABLE `test_db_model` -CHANGE COLUMN `col1` `col1` varchar(32) CHARSET utf8mb4 COLLATE utf8mb4_general_ci NOT NULL DEFAULT 'mydefault' , +CHANGE COLUMN `col1` `col1` varchar(32) CHARSET utf8 COLLATE utf8_unicode_ci NOT NULL DEFAULT 'mydefault' , CHANGE COLUMN `instance_id` `instance_id` int(11) NULL DEFAULT -1 ; ALTER TABLE `test_db_model` DROP FOREIGN KEY `con_col1`; diff --git a/tests/ci/bootstrap.sh b/tests/ci/bootstrap.sh index 96d4a367c0..61c139de50 100755 --- a/tests/ci/bootstrap.sh +++ b/tests/ci/bootstrap.sh @@ -3,7 +3,6 @@ # an existing one. This code is only designed to work inside the XDMoD test # docker instances. However, since it is designed to test a real install, the # set of commands that are run would work on a real production system. - BASEDIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )" REF_SOURCE=`realpath $BASEDIR/../artifacts/xdmod/referencedata` REPODIR=`realpath $BASEDIR/../../` @@ -52,36 +51,12 @@ then rpm -qa | grep ^xdmod | xargs yum -y remove || true rm -rf /etc/xdmod - rm -rf /var/lib/mysql - mkdir -p /var/lib/mysql - mkdir -p /var/log/mariadb - mkdir -p /var/run/mariadb - chown -R mysql:mysql /var/lib/mysql - chown -R mysql:mysql /var/log/mariadb - chown -R mysql:mysql /var/run/mariadb - dnf install -y ~/rpmbuild/RPMS/*/*.rpm - mysql_install_db --user mysql - - # Make sure that the db config file is setup correctly w/ `sql_mode=` - echo "# this is read by the standalone daemon and embedded servers - [server] - sql_mode= - # this is only for the mysqld standalone daemon - # Settings user and group are ignored when systemd is used. - # If you need to run mysqld under a different user or group, - # customize your systemd unit file for mysqld/mariadb according to the - # instructions in http://fedoraproject.org/wiki/Systemd - [mysqld] - datadir=/var/lib/mysql - socket=/var/lib/mysql/mysql.sock - log-error=/var/log/mariadb/mariadb.log - pid-file=/run/mariadb/mariadb.pid" > /etc/my.cnf.d/mariadb-server.cnf - copy_template_httpd_conf ~/bin/services start - mysql -e "CREATE USER 'root'@'gateway' IDENTIFIED BY ''; - GRANT ALL PRIVILEGES ON *.* TO 'root'@'gateway' WITH GRANT OPTION; + + mysql -h mariadb -e "CREATE USER 'root'@'xdmod' IDENTIFIED BY ''; + GRANT ALL PRIVILEGES ON *.* TO 'root'@'xdmod' WITH GRANT OPTION; FLUSH PRIVILEGES;" # TODO: Replace diff files with hard fixes @@ -155,8 +130,7 @@ fi if [ "$XDMOD_TEST_MODE" = "upgrade" ]; then - # Install the newly built RPM. - dnf -y install ~/rpmbuild/RPMS/*/*.rpm + yum -y install ~/rpmbuild/RPMS/*/*.rpm copy_template_httpd_conf sed -i 's#http://localhost:8080#https://localhost#' /etc/xdmod/portal_settings.ini diff --git a/tests/ci/scripts/xdmod-setup-start.tcl b/tests/ci/scripts/xdmod-setup-start.tcl index 239aa3f673..880cd52ef2 100644 --- a/tests/ci/scripts/xdmod-setup-start.tcl +++ b/tests/ci/scripts/xdmod-setup-start.tcl @@ -24,9 +24,10 @@ confirmFileWrite yes enterToContinue selectMenuOption 2 -answerQuestion {DB Hostname or IP} localhost +answerQuestion {DB Hostname or IP} mariadb answerQuestion {DB Port} 3306 answerQuestion {DB Username} xdmod +answerQuestion {XDMoD Server name} xdmod.xdmod_default providePassword {DB Password:} xdmod123 answerQuestion {DB Admin Username} root providePassword {DB Admin Password:} {} diff --git a/tests/unit/lib/ETL/DbModel/DbModelTest.php b/tests/unit/lib/ETL/DbModel/DbModelTest.php index bf4443f1a0..cb8cedb17b 100644 --- a/tests/unit/lib/ETL/DbModel/DbModelTest.php +++ b/tests/unit/lib/ETL/DbModel/DbModelTest.php @@ -91,8 +91,8 @@ public function testTableSchema() 'type' => 'varchar(16)', 'nullable' => false, 'default' => 'Test Column', - 'charset' => 'utf8mb4', - 'collation' => 'utf8mb4_general_ci', + 'charset' => 'utf8', + 'collation' => 'utf8_unicode_ci', 'comment' => 'No comment', ), ), @@ -107,7 +107,7 @@ public function testTableSchema() $generated = array_shift($generated); $expected = "CREATE TABLE IF NOT EXISTS `table_no_schema` ( `column1` int(11) NULL DEFAULT 0 COMMENT 'This is my comment', - `column2` varchar(16) CHARSET utf8mb4 COLLATE utf8mb4_general_ci NOT NULL DEFAULT 'Test Column' COMMENT 'No comment' + `column2` varchar(16) CHARSET utf8 COLLATE utf8_unicode_ci NOT NULL DEFAULT 'Test Column' COMMENT 'No comment' );"; $this->assertEquals($expected, $generated); @@ -116,7 +116,7 @@ public function testTableSchema() $generated = array_shift($generated); $expected = "CREATE TABLE IF NOT EXISTS `my_schema`.`table_no_schema` ( `column1` int(11) NULL DEFAULT 0 COMMENT 'This is my comment', - `column2` varchar(16) CHARSET utf8mb4 COLLATE utf8mb4_general_ci NOT NULL DEFAULT 'Test Column' COMMENT 'No comment' + `column2` varchar(16) CHARSET utf8 COLLATE utf8_unicode_ci NOT NULL DEFAULT 'Test Column' COMMENT 'No comment' );"; $this->assertEquals($expected, $generated); } @@ -201,14 +201,14 @@ public function testCreateSql() 'type' => 'varchar(16)', 'nullable' => false, 'default' => 'Test Column', - 'charset' => 'utf8mb4', - 'collation' => 'utf8mb4_general_ci', + 'charset' => 'utf8', + 'collation' => 'utf8_unicode_ci', 'comment' => 'No comment', ); $obj = new Column($config, '`', self::$logger); $generated = $obj->getSql(); - $expected = "`column2` varchar(16) CHARSET utf8mb4 COLLATE utf8mb4_general_ci NOT NULL DEFAULT 'Test Column' COMMENT 'No comment'"; + $expected = "`column2` varchar(16) CHARSET utf8 COLLATE utf8_unicode_ci NOT NULL DEFAULT 'Test Column' COMMENT 'No comment'"; $this->assertEquals($expected, $generated); $config = (object) array( @@ -312,8 +312,8 @@ public function testAlterTable() $config = (object) array( 'name' => 'new_column2', 'type' => 'char(64)', - 'charset' => 'utf8mb4', - 'collation' => 'utf8mb4_general_ci', + 'charset' => 'utf8', + 'collation' => 'utf8_unicode_ci', 'nullable' => true, ); $destTable->addColumn($config);