diff --git a/.docker/Dockerfile b/.docker/Dockerfile new file mode 100644 index 0000000000000000000000000000000000000000..14ae750aa7f2f0c8262895c9b64a2a7f6e094d0f --- /dev/null +++ b/.docker/Dockerfile @@ -0,0 +1,3 @@ +FROM debian:stretch +RUN apt-get update && \ + apt-get install curl -y diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index 50d119aae3fbfa99bf3bf8c122b4aa14f4ae0b5d..98008035a95874d678df722819979393f5692f0c 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -1,9 +1,9 @@ # -# ** header v3.0 # This file is a part of the CaosDB Project. # # Copyright (C) 2018 Research Group Biomedical Physics, # Max-Planck-Institute for Dynamics and Self-Organization Göttingen +# Copyright (C) 2019 Henrik tom Wörden # # This program is free software: you can redistribute it and/or modify # it under the terms of the GNU Affero General Public License as @@ -18,139 +18,45 @@ # You should have received a copy of the GNU Affero General Public License # along with this program. If not, see <https://www.gnu.org/licenses/>. # -# ** end header -# -stages: - - configure - - test - - setup - - clean - -########################### -# configure -########################### - -configure:mysql55: - stage: configure - tags: [ mysql55 ] - artifacts: - paths: - - .config.mysql55 - script: - - printf "\n\n\n\n\n\n\n\n\n$MYSQL_USER_PASSWORD" > .user_input - - ./configure < .user_input - - test -f .config - - cp .config .config.mysql55 - -configure:mariadb10.1: - stage: configure - tags: [ maria10.1 ] - artifacts: - paths: - - .config.mariadb10.1 - script: - - printf "\n\n\n\n\ncaosdb-root\n\n\n\n$MYSQL_USER_PASSWORD" > .user_input - - ./configure < .user_input - - test -f .config - - cp .config .config.mariadb10.1 - -########################## -# test -########################## +variables: + CI_REGISTRY_IMAGE: $CI_REGISTRY/caosdb-mysqlbackend-testenv:latest + # When using dind, it's wise to use the overlayfs driver for + # improved performance. + DOCKER_DRIVER: overlay2 -# test the connection -test:test-connection:mysql55: - stage: test - tags: [ mysql55 ] - dependencies: - - configure:mysql55 - script: - - cp .config.mysql55 .config - - make test-connection - -test:test-connection:mariadb10.1: - stage: test - tags: [ maria10.1 ] - dependencies: - - configure:mariadb10.1 - script: - - cp .config.mariadb10.1 .config - - make test-connection +services: + - docker:19.03-dind -######################### -# setup -######################### - -# install without patches and drop -setup:install:mysql55: - stage: setup - tags: [ mysql55 ] - dependencies: - - configure:mysql55 - script: - - cp .config.mysql55 .config - - export $(sed -n '/DATABASE_NAME/p ' .config) - - make _install - - make drop-$DATABASE_NAME - -setup:install:mariadb10.1: - stage: setup - tags: [ maria10.1 ] - dependencies: - - configure:mariadb10.1 - script: - - cp .config.mariadb10.1 .config - - export $(sed -n '/DATABASE_NAME/p ' .config) - - make _install - - make drop-$DATABASE_NAME - -# upgrade database with patches and drop -setup:install_upgrade:mysql55: - stage: setup - tags: [ mysql55 ] - dependencies: - - configure:mysql55 - script: - - cp .config.mysql55 .config - - export $(sed -n '/DATABASE_NAME/p ' .config) - - make install - - make drop-$DATABASE_NAME - -setup:install_upgrade:mariadb10.1: - stage: setup - tags: [ maria10.1 ] - dependencies: - - configure:mariadb10.1 - script: - - cp .config.mariadb10.1 .config - - export $(sed -n '/DATABASE_NAME/p ' .config) - - make install - - make drop-$DATABASE_NAME - -############################### -# cleanup -############################### - -# drop database -clean:drop:mysql55: - stage: clean - when: always - tags: [ mysql55 ] - dependencies: - - configure:mysql55 - script: - - cp .config.mysql55 .config - - export $(sed -n '/DATABASE_NAME/p ' .config) - - if make _exists; then make drop-$DATABASE_NAME ; fi - -clean:drop:mariadb10.1: - stage: clean - when: always - tags: [ maria10.1 ] - dependencies: - - configure:mariadb10.1 - script: - - cp .config.mariadb10.1 .config - - export $(sed -n '/DATABASE_NAME/p ' .config) - - if make _exists; then make drop-$DATABASE_NAME ; fi \ No newline at end of file +image: $CI_REGISTRY_IMAGE +stages: + - setup + - deploy + +# Trigger building of server image and integration tests +trigger_build: + tags: [ docker ] + stage: deploy + script: + - /usr/bin/curl -X POST + -F token=8f29e5eeb7db2123d9c2bb84634da2 + -F "variables[MYSQLBACKEND]=$CI_COMMIT_REF_NAME" + -F "variables[TriggerdBy]=MYSQLBACKEND" + -F "variables[TriggerdByHash]=$CI_COMMIT_SHORT_SHA" + -F ref=master https://gitlab.indiscale.com/api/v4/projects/14/trigger/pipeline + +# Build a docker image in which tests for this repository can run +build-testenv: + tags: [ docker ] + image: docker:19.03 + stage: setup + script: + - cd .docker + - docker login -u testuser -p $CI_REGISTRY_PASSWORD $CI_REGISTRY + # use here general latest or specific branch latest... + - docker pull $CI_REGISTRY_IMAGE || true + - docker build + --pull + --cache-from $CI_REGISTRY_IMAGE + -t $CI_REGISTRY_IMAGE . + - docker push $CI_REGISTRY_IMAGE diff --git a/README.md b/README.md index 92c6a4004870e4a14e6a173fa8e02efe5e39ed36..10fe96d776335d87f870f40a7a98f7d87d98cb6a 100644 --- a/README.md +++ b/README.md @@ -14,7 +14,7 @@ setup this code. # Further Reading Please refer to the [official gitlab repository of the CaosDB -project](https://gitlab.gwdg.de/bmp-caosdb/caosdb) for more information. +project](https://gitlab.com/caosdb/caosdb) for more information. # License diff --git a/doc/multipurpose_subdomains.md b/doc/multipurpose_subdomains.md deleted file mode 100644 index 28001cc48c0c868bd490d0cc4504f2423cc11b62..0000000000000000000000000000000000000000 --- a/doc/multipurpose_subdomains.md +++ /dev/null @@ -1,22 +0,0 @@ -# Multipurpose subdomains # -Multipurpose subdomains are generically used to work with composite -properties. Currently implemented examples are: -- Properties with units (if multiple Properties exist) -- Lists -- Name overrides - -## Example ## -Let's have a look at this *Record* (simplified XML): - -```xml -<R1> - <P1 name="Comment">Hello World</P1> - <P2 name="voltage" unit="V"> - 23 - </P2> - <P3 comment="list of something"> - V1, V2, V3, V4, ... - </P3> -</R1> -``` - diff --git a/patches/patch20170825-2.0.30/test.sql b/patches/patch20170825-2.0.30/test.sql index d303b379fef8348c01d3c4c3ae9e28e601ddc6ab..3b0faefde3447a89f093436d8a9f5b1c2346d4a1 100644 --- a/patches/patch20170825-2.0.30/test.sql +++ b/patches/patch20170825-2.0.30/test.sql @@ -22,6 +22,21 @@ */ SET @@SESSION.max_sp_recursion_depth=25; +-- Inheritance: +-- +-- 0 +-- | +-- 1 +-- | +-- 2 +-- / \ +-- 3 4 +-- \ / +-- 5 +-- | +-- 6 +-- + SET FOREIGN_KEY_CHECKS = 0; delete from isa_cache; -- simple 1->0 @@ -203,7 +218,7 @@ call isSubtype(1,2); call isSubtype(0,2); call isSubtype(0,1); --- remove 2->1 +-- remove 2->1 CREATE TEMPORARY TABLE expected1 SELECT * from isa_cache; call deleteIsa(2); select "subtypes:"; @@ -253,7 +268,7 @@ call isSubtype(0,1); -- and add 2->1 again call insertIsa(2,1); -SELECT A.*, B.* FROM isa_cache AS A LEFT JOIN expected1 AS B ON (A.child = B.child AND A.parent=B.parent AND A.rpath=B.rpath) WHERE A.child IS NULL OR B.child IS NULL; +SELECT A.*, B.* FROM isa_cache AS A LEFT JOIN expected1 AS B ON (A.child = B.child AND A.parent=B.parent AND A.rpath=B.rpath) WHERE A.child IS NULL OR B.child IS NULL; SELECT A.*, B.* FROM isa_cache AS A RIGHT JOIN expected1 AS B ON (A.child = B.child AND A.parent=B.parent AND A.rpath=B.rpath) WHERE A.child IS NULL OR B.child IS NULL; -- remove 4->2 @@ -306,7 +321,7 @@ call isSubtype(5,6); -- and add 4->2 again call insertIsa(4,2); -SELECT A.*, B.* FROM isa_cache AS A LEFT JOIN expected1 AS B ON (A.child = B.child AND A.parent=B.parent AND A.rpath=B.rpath) WHERE A.child IS NULL OR B.child IS NULL; +SELECT A.*, B.* FROM isa_cache AS A LEFT JOIN expected1 AS B ON (A.child = B.child AND A.parent=B.parent AND A.rpath=B.rpath) WHERE A.child IS NULL OR B.child IS NULL; SELECT A.*, B.* FROM isa_cache AS A RIGHT JOIN expected1 AS B ON (A.child = B.child AND A.parent=B.parent AND A.rpath=B.rpath) WHERE A.child IS NULL OR B.child IS NULL; -- remove 5->4 and 5->3 @@ -407,7 +422,7 @@ call isSubtype(6,3); -- and add 5->3 again call insertIsa(5,3); -SELECT A.*, B.* FROM isa_cache AS A LEFT JOIN expected1 AS B ON (A.child = B.child AND A.parent=B.parent AND A.rpath=B.rpath) WHERE A.child IS NULL OR B.child IS NULL; +SELECT A.*, B.* FROM isa_cache AS A LEFT JOIN expected1 AS B ON (A.child = B.child AND A.parent=B.parent AND A.rpath=B.rpath) WHERE A.child IS NULL OR B.child IS NULL; SELECT A.*, B.* FROM isa_cache AS A RIGHT JOIN expected1 AS B ON (A.child = B.child AND A.parent=B.parent AND A.rpath=B.rpath) WHERE A.child IS NULL OR B.child IS NULL; -- add cycle 0->3 @@ -428,7 +443,7 @@ call isSubtype(3,2); -- remove cycle 0->3 call deleteIsa(0); -SELECT A.*, B.* FROM isa_cache AS A LEFT JOIN expected1 AS B ON (A.child = B.child AND A.parent=B.parent AND A.rpath=B.rpath) WHERE A.child IS NULL OR B.child IS NULL; +SELECT A.*, B.* FROM isa_cache AS A LEFT JOIN expected1 AS B ON (A.child = B.child AND A.parent=B.parent AND A.rpath=B.rpath) WHERE A.child IS NULL OR B.child IS NULL; SELECT A.*, B.* FROM isa_cache AS A RIGHT JOIN expected1 AS B ON (A.child = B.child AND A.parent=B.parent AND A.rpath=B.rpath) WHERE A.child IS NULL OR B.child IS NULL; call deleteIsa(1); diff --git a/procedures/insertIsaCache.sql b/procedures/insertIsaCache.sql index 4ff1a46ea6f1c1001cc99840c51b3911bc630323..735ba126a98ee3a050194525a0c437f72f547cdc 100644 --- a/procedures/insertIsaCache.sql +++ b/procedures/insertIsaCache.sql @@ -30,11 +30,33 @@ BEGIN -- foreach supertype of p -- INSERT (c, supertype, p); - INSERT IGNORE INTO isa_cache SELECT c AS child, i.parent AS parent, IF(p=i.rpath or i.rpath=parent, p, concat(p, ">", i.rpath)) AS rpath FROM isa_cache AS i WHERE i.child = p; + INSERT IGNORE INTO isa_cache SELECT + c + AS child, + i.parent + AS parent, + IF(p=i.rpath or i.rpath=parent, + p, + concat(p, ">", i.rpath)) + AS rpath + FROM isa_cache AS i WHERE i.child = p; -- foreach subtype of c insert each supertype of p - INSERT IGNORE INTO isa_cache SELECT l.child, r.parent, if(l.rpath=l.child and r.rpath=c, c, concat(if(l.rpath=l.child,c,concat(l.rpath, '>', c)), if(r.rpath=c,'',concat('>', r.rpath)))) AS rpath FROM isa_cache as l INNER JOIN isa_cache as r ON (l.parent = r.child AND l.parent=c); + INSERT IGNORE INTO isa_cache SELECT + l.child, + r.parent, + if(l.rpath=l.child and r.rpath=c, + c, + concat(if(l.rpath=l.child, + c, + concat(l.rpath, '>', c)), + if(r.rpath=c, + '', + concat('>', r.rpath)))) + AS rpath + FROM isa_cache as l + INNER JOIN isa_cache as r ON (l.parent = r.child AND l.parent=c);