Skip to content
Snippets Groups Projects
Verified Commit eb5e1695 authored by Daniel Hornung's avatar Daniel Hornung
Browse files

WIP: Patch

parent ed7a4977
No related branches found
No related tags found
1 merge request!33Fix accent sensitivity
Pipeline #60560 canceled
...@@ -70,24 +70,24 @@ test-dump-update: ...@@ -70,24 +70,24 @@ test-dump-update:
script: script:
- make test-dump-update - make test-dump-update
# Run the unit tests with MySQL 5 # # Run the unit tests with MySQL 5
unittests-mysql-5: # unittests-mysql-5:
tags: [ docker ] # tags: [ docker ]
stage: test # stage: test
# Should not stop the pipeline from continuing. # # Should not stop the pipeline from continuing.
allow_failure: true # allow_failure: true
services: # services:
- name: mysql:5.7.36 # - name: mysql:5.7.36
command: ["--default-authentication-plugin=mysql_native_password"] # command: ["--default-authentication-plugin=mysql_native_password"]
#
script: # script:
# remove some lines from autotap because the checks of column default # # remove some lines from autotap because the checks of column default
# values don't work with mysql-5 # # values don't work with mysql-5
- sed -i "/col_default_is.*NULL/d" tests/test_autotap.sql # - sed -i "/col_default_is.*NULL/d" tests/test_autotap.sql
- sed -i "/col_default_is.*INACTIVE/d" tests/test_autotap.sql # - sed -i "/col_default_is.*INACTIVE/d" tests/test_autotap.sql
- sed -i "/col_default_is.*SHA/d" tests/test_autotap.sql # - sed -i "/col_default_is.*SHA/d" tests/test_autotap.sql
- sed -i "s/utf8mb3/utf8/" tests/test_autotap.sql # - sed -i "s/utf8mb3/utf8/" tests/test_autotap.sql
- make pipeline-test SQL_HOST=mysql # - make pipeline-test SQL_HOST=mysql
######## Deploy ######## ######## Deploy ########
......
...@@ -64,7 +64,7 @@ test-dump-update: ...@@ -64,7 +64,7 @@ test-dump-update:
test-docker: test-docker:
@docker kill caosdb-mysqlserver-test || true @docker kill caosdb-mysqlserver-test || true
@docker container rm -v caosdb-mysqlserver-test || true @docker container rm -v caosdb-mysqlserver-test || true
@docker run --name caosdb-mysqlserver-test -p "3306:3306" \ @docker run --name caosdb-mysqlserver-test -p "3307:3306" \
-e MYSQL_ROOT_PASSWORD="pass-for-test" -d mariadb:10.11 -e MYSQL_ROOT_PASSWORD="pass-for-test" -d mariadb:10.11
@sleep 10 @sleep 10
MAINPATH=$(realpath tests/docker_env) utils/make_db test --fresh MAINPATH=$(realpath tests/docker_env) utils/make_db test --fresh
......
...@@ -99,6 +99,20 @@ After the first start, you need to install the database: `make install`. ...@@ -99,6 +99,20 @@ After the first start, you need to install the database: `make install`.
Then, you can connect to it with `mariadb --protocol=TCP -u caosdb -prandom1234 Then, you can connect to it with `mariadb --protocol=TCP -u caosdb -prandom1234
caosdb`. caosdb`.
### Developing tests ###
To use the mytap framework:
```console
$ cd libs; unzip mytap-1.0.zip; cd mytap-1.0
# Use the necessary mariadb options for connecting to the server in the following commands
$ mariadb ... < mytap.sql # Set up the "tap" database and functions.
$ mariadb ... < scripts/autotap.sql # Insert the "autotap" function.
# Create autotap file (for comparison with current state)
$ mariadb ... --raw -B --skip-column-names -e "call tap.autotap('_caosdb_schema_unit_tests')" > test_autotap.current.sql
# Run the autotap tests (may fail unfortunately with current MariaDB):
$ mariadb ... < test_autotap.current.sql
```
### Troubleshooting ### Troubleshooting
......
...@@ -35,7 +35,12 @@ fi ...@@ -35,7 +35,12 @@ fi
check_version $OLD_VERSION check_version $OLD_VERSION
mysql_execute 'DELETE FROM `entities` WHERE id=6; ALTER TABLE `entities` MODIFY COLUMN `role` ENUM("RECORDTYPE","RECORD","FILE","DOMAIN","PROPERTY","DATATYPE","ROLE","QUERYTEMPLATE") NOT NULL; INSERT INTO entities (id, name, description, role, acl) VALUES (8,"QUERYTEMPLATE","The QueryTemplate role.","ROLE",0); UPDATE `entities` SET role="ROLE" WHERE id<100 and name=role; CREATE TABLE `query_template_def` (id INT UNSIGNED PRIMARY KEY, definition MEDIUMTEXT NOT NULL, CONSTRAINT `query_template_def_ibfk_1` FOREIGN KEY (`id`) REFERENCES `entities` (`id`));' mysql_execute '
DELETE FROM `entities` WHERE id=6;
ALTER TABLE `entities` MODIFY COLUMN `role` ENUM("RECORDTYPE","RECORD","FILE","DOMAIN","PROPERTY","DATATYPE","ROLE","QUERYTEMPLATE") NOT NULL;
INSERT INTO entities (id, name, description, role, acl) VALUES (8,"QUERYTEMPLATE","The QueryTemplate role.","ROLE",0);
UPDATE `entities` SET role="ROLE" WHERE id<100 and name=role;
CREATE TABLE `query_template_def` (id INT UNSIGNED PRIMARY KEY, definition MEDIUMTEXT NOT NULL, CONSTRAINT `query_template_def_ibfk_1` FOREIGN KEY (`id`) REFERENCES `entities` (`id`));'
update_version $NEW_VERSION update_version $NEW_VERSION
......
...@@ -36,6 +36,17 @@ check_version $OLD_VERSION ...@@ -36,6 +36,17 @@ check_version $OLD_VERSION
# Update charsets and collations. # Update charsets and collations.
# Change database default.
mysql_execute "ALTER DATABASE \`$DATABASE_NAME\` COLLATE = 'uca1400_as_ci';"
# Some columns should be changed manually to prevent text length changes.
mysql_execute "ALTER TABLE desc_overrides MODIFY description TEXT CHARACTER SET utf8mb4;"
mysql_execute "ALTER TABLE entities MODIFY description TEXT CHARACTER SET utf8mb4;"
mysql_execute "ALTER TABLE permissions MODIFY permissions MEDIUMTEXT CHARACTER SET utf8mb4 NOT NULL;"
mysql_execute "ALTER TABLE query_template_def MODIFY definition MEDIUMTEXT CHARACTER SET utf8mb4 NOT NULL;"
mysql_execute "ALTER TABLE roles MODIFY description MEDIUMTEXT CHARACTER SET utf8mb4;"
mysql_execute "ALTER TABLE text_data MODIFY value TEXT CHARACTER SET utf8mb4 NOT NULL;"
# Remove some constraints first. # Remove some constraints first.
mysql_execute 'ALTER TABLE user_info DROP FOREIGN KEY `subjects_ibfk_2`;' mysql_execute 'ALTER TABLE user_info DROP FOREIGN KEY `subjects_ibfk_2`;'
...@@ -49,11 +60,18 @@ done ...@@ -49,11 +60,18 @@ done
mysql_execute 'ALTER TABLE user_info MODIFY COLUMN `entity` VARCHAR(255) COLLATE utf8mb4_bin DEFAULT NULL;' mysql_execute 'ALTER TABLE user_info MODIFY COLUMN `entity` VARCHAR(255) COLLATE utf8mb4_bin DEFAULT NULL;'
mysql_execute 'ALTER TABLE user_info ADD CONSTRAINT `subjects_ibfk_2` FOREIGN KEY (`entity`) REFERENCES `entity_ids` (`id`);' mysql_execute 'ALTER TABLE user_info ADD CONSTRAINT `subjects_ibfk_2` FOREIGN KEY (`entity`) REFERENCES `entity_ids` (`id`);'
# Set custom collations for columns
mysql_execute "ALTER TABLE transaction_log MODIFY entity_id VARCHAR(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_bin NOT NULL;"
### Finished ###
update_version $NEW_VERSION
success
# mysql_execute "UPDATE data_type SET datatype=17 WHERE datatype=3"
##### Useful commands #####
# cd git/caosdb-mysqlbackend/ # cd git/caosdb-mysqlbackend/
# UTILSPATH=utils # UTILSPATH=utils
...@@ -79,7 +97,3 @@ mysql_execute 'ALTER TABLE user_info ADD CONSTRAINT `subjects_ibfk_2` FOREIGN KE ...@@ -79,7 +97,3 @@ mysql_execute 'ALTER TABLE user_info ADD CONSTRAINT `subjects_ibfk_2` FOREIGN KE
# mariadb -h sqldb -u caosdb -prandom1234 --default-character-set=utf8mb4 caosdb # mariadb -h sqldb -u caosdb -prandom1234 --default-character-set=utf8mb4 caosdb
update_version $NEW_VERSION
success
This diff is collapsed.
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment