From 708eab075a01a2e598a15a255abfa07e9fd7d2c4 Mon Sep 17 00:00:00 2001 From: Dipak Acharya Date: Thu, 3 Sep 2020 10:32:40 +0545 Subject: [PATCH] wip - setting up tests with eos on drone-ci --- docker-compose-eos-ci.yml | 179 ++++++++++++++++++ tests/config/drone/create-config.json.sh | 20 ++ .../drone/create-identifier-registration.sh | 15 ++ tests/config/drone/setup-eos.sh | 19 ++ tests/spwan_eos.sh | 28 +++ 5 files changed, 261 insertions(+) create mode 100644 docker-compose-eos-ci.yml create mode 100644 tests/config/drone/create-config.json.sh create mode 100644 tests/config/drone/create-identifier-registration.sh create mode 100644 tests/config/drone/setup-eos.sh create mode 100644 tests/spwan_eos.sh diff --git a/docker-compose-eos-ci.yml b/docker-compose-eos-ci.yml new file mode 100644 index 00000000000..ab5efdec465 --- /dev/null +++ b/docker-compose-eos-ci.yml @@ -0,0 +1,179 @@ +--- +version: '3.5' + +networks: + testnet: + name: testnet + +services: + ocis: + container_name: ocis + image: owncloud/eos-ocis-dev:latest + tty: true + privileged: true + stdin_open: true + ports: + - 9200:9200 + env_file: + - ./config/eos-docker.env + hostname: ocis + networks: + - testnet + volumes: + - .:/ocis + - ../ocis-reva:/ocis-reva + - ../reva:/reva + - ./tests/config/drone:/eos-config + environment: + # ocis log level will be used for all services + OCIS_LOG_LEVEL: debug + # domain setup + # TODO currently the below lines hardcode the port to 9200, use an OCIS_URL that includes protocol and port + OCIS_DOMAIN: ${OCIS_DOMAIN:-localhost} + PROXY_OIDC_ISSUER: https://${OCIS_DOMAIN:-localhost}:9200 + KONNECTD_ISS: https://${OCIS_DOMAIN:-localhost}:9200 + PHOENIX_OIDC_AUTHORITY: https://${OCIS_DOMAIN:-localhost}:9200 + PHOENIX_OIDC_METADATA_URL: https://${OCIS_DOMAIN:-localhost}:9200/.well-known/openid-configuration + PHOENIX_WEB_CONFIG_SERVER: https://${OCIS_DOMAIN:-localhost}:9200 + REVA_OIDC_ISSUER: https://${OCIS_DOMAIN:-localhost}:9200 + REVA_LDAP_IDP: https://${OCIS_DOMAIN:-localhost}:9200 + # TODO make id the default in ocis-reva + REVA_STORAGE_EOS_LAYOUT: "{{substr 0 1 .Id.OpaqueId}}/{{.Id.OpaqueId}}" + REVA_FRONTEND_URL: https://${OCIS_DOMAIN:-localhost}:9200 + REVA_DATAGATEWAY_URL: https://${OCIS_DOMAIN:-localhost}:9200/data + # common eos settings used for both drivers: eos and eoshome + REVA_STORAGE_EOS_MASTER_URL: ${EOS_MGM_URL:-root://mgm-master.testnet:1094} + REVA_STORAGE_EOS_SLAVE_URL: ${EOS_MGM_URL:-root://mgm-master.testnet:1094} + REVA_STORAGE_EOS_NAMESPACE: "/eos/dockertest/reva/users" + # the eos end xrdcopy binaries use this env var to find the eos mgm + EOS_MGM_URL: ${EOS_MGM_URL:-root://mgm-master.testnet:1094} + PHOENIX_WEB_CONFIG: /eos-config/config.json + KONNECTD_IDENTIFIER_REGISTRATION_CONF: /eos-config/identifier-registration.yml + + mgm-master: + container_name: mgm-master + image: owncloud/eos-mgm:4.6.5 + tty: true + privileged: true + stdin_open: true + env_file: + - ./config/eos-docker.env + hostname: mgm-master.testnet + networks: + - testnet + volumes: + - eos-mgm-master-log:/var/log/eos + - eos-mgm-master-config:/var/eos/config + - eos-mgm-master-ns-queue:/var/eos/ns-queue + # this volume kills mgm-master during startup + # - ./e/master/var/eos/md:/var/eos/md + environment: + EOS_SET_MASTER: 1 + + mq-master: + container_name: mq-master + image: owncloud/eos-mq:4.6.5 + tty: true + privileged: true + stdin_open: true + env_file: + - ./config/eos-docker.env + hostname: mq-master.testnet + networks: + - testnet + volumes: + - eos-mq-master-log:/var/log/eos + - eos-mq-master-config:/var/eos/config + - eos-mq-master-ns-queue:/var/eos/ns-queue + environment: + EOS_SET_MASTER: 1 + + fst: + container_name: fst + image: owncloud/eos-fst:4.6.5 + tty: true + privileged: true + stdin_open: true + env_file: + - ./config/eos-docker.env + hostname: fst.testnet + networks: + - testnet + volumes: + - eos-fst-log:/var/log/eos + - eos-fst-disks:/disks + environment: + EOS_MGM_URL: "root://mgm-master.testnet" + + quark-1: + container_name: quark-1 + image: owncloud/eos-qdb:4.6.5 + tty: true + privileged: true + stdin_open: true + env_file: + - ./config/eos-docker.env + hostname: quark-1.testnet + networks: + - testnet + volumes: + - eos-quarkdb1:/var/lib/quarkdb + environment: + EOS_QDB_DIR: "/var/lib/quarkdb/eosns" + EOS_QDB_PORT: "7777" + EOS_QDB_MODE: "raft" + EOS_QDB_CLUSTER_ID: "3d659c1a-e70f-43f0-bed4-941a2ca0765b" + EOS_QDB_NODES: "quark-1.testnet:7777,quark-2.testnet:7777,quark-3.testnet:7777" + + quark-2: + container_name: quark-2 + image: owncloud/eos-qdb:4.6.5 + tty: true + privileged: true + stdin_open: true + env_file: + - ./config/eos-docker.env + hostname: quark-2.testnet + networks: + - testnet + volumes: + - eos-quarkdb2:/var/lib/quarkdb + environment: + EOS_QDB_DIR: "/var/lib/quarkdb/eosns" + EOS_QDB_PORT: "7777" + EOS_QDB_MODE: "raft" + EOS_QDB_CLUSTER_ID: "3d659c1a-e70f-43f0-bed4-941a2ca0765b" + EOS_QDB_NODES: "quark-1.testnet:7777,quark-2.testnet:7777,quark-3.testnet:7777" + + quark-3: + container_name: quark-3 + image: owncloud/eos-qdb:4.6.5 + tty: true + privileged: true + stdin_open: true + env_file: + - ./config/eos-docker.env + hostname: quark-3.testnet + networks: + - testnet + volumes: + - eos-quarkdb3:/var/lib/quarkdb + environment: + EOS_QDB_DIR: "/var/lib/quarkdb/eosns" + EOS_QDB_PORT: "7777" + EOS_QDB_MODE: "raft" + EOS_QDB_CLUSTER_ID: "3d659c1a-e70f-43f0-bed4-941a2ca0765b" + EOS_QDB_NODES: "quark-1.testnet:7777,quark-2.testnet:7777,quark-3.testnet:7777" + +volumes: + eos-mgm-master-log: + eos-mgm-master-config: + eos-mgm-master-ns-queue: + eos-mq-master-log: + eos-mq-master-config: + eos-mq-master-ns-queue: + eos-fst-log: + eos-fst-disks: + eos-quarkdb1: + eos-quarkdb2: + eos-quarkdb3: diff --git a/tests/config/drone/create-config.json.sh b/tests/config/drone/create-config.json.sh new file mode 100644 index 00000000000..9c4a0d152ee --- /dev/null +++ b/tests/config/drone/create-config.json.sh @@ -0,0 +1,20 @@ +#!/bin/bash +echo "{ + \"server\":\"https://${OCIS_DOMAIN}:9200\", + \"theme\":\"owncloud\", + \"version\":\"0.1.0\", + \"openIdConnect\":{ + \"metadata_url\":\"https://${OCIS_DOMAIN}:9200/.well-known/openid-configuration\", + \"authority\":\"https://${OCIS_DOMAIN}:9200\", + \"client_id\":\"phoenix\", + \"response_type\":\"code\", + \"scope\":\"openid profile email\" + }, + \"apps\":[\"files\",\"draw-io\",\"pdf-viewer\",\"markdown-editor\",\"media-viewer\"], + \"external_apps\":[ + {\"id\":\"accounts\",\"path\":\"https://${OCIS_DOMAIN}:9200/accounts.js\"}, + {\"id\":\"settings\",\"path\":\"https://${OCIS_DOMAIN}:9200/settings.js\"} + ], + \"options\":{\"hideSearchBar\":true} +}" > $PWD/config.json + diff --git a/tests/config/drone/create-identifier-registration.sh b/tests/config/drone/create-identifier-registration.sh new file mode 100644 index 00000000000..5fb5870aeb7 --- /dev/null +++ b/tests/config/drone/create-identifier-registration.sh @@ -0,0 +1,15 @@ +#!/bin/bash +echo "--- +# OpenID Connect client registry. +clients: + - id: phoenix + name: OCIS + application_type: web + insecure: yes + trusted: yes + redirect_uris: + - https://${OCIS_DOMAIN}:9200/oidc-callback.html + - https://${OCIS_DOMAIN}:9200/ + origins: + - https://${OCIS_DOMAIN}:9200 +authorities:" > $PWD/identifier-registration.yml diff --git a/tests/config/drone/setup-eos.sh b/tests/config/drone/setup-eos.sh new file mode 100644 index 00000000000..8c655b231bf --- /dev/null +++ b/tests/config/drone/setup-eos.sh @@ -0,0 +1,19 @@ +#!/bin/bash + +# wait for ocis to start +until $(curl -k --output /dev/null --silent --head --fail https://localhost:9200); +do + printf '.' + sleep 2 +done + +docker-compose -f ./docker-compose-eos-ci.yml exec -d ocis /start-ldap +sleep 5 +docker-compose -f ./docker-compose-eos-ci.yml exec ocis id einstein +docker-compose -f ./docker-compose-eos-ci.yml exec ocis /ocis/bin/ocis kill reva-users +docker-compose -f ./docker-compose-eos-ci.yml exec ocis /ocis/bin/ocis run reva-users +docker-compose -f ./docker-compose-eos-ci.yml exec ocis /ocis/bin/ocis kill reva-storage-home +docker-compose -f ./docker-compose-eos-ci.yml exec -e REVA_STORAGE_HOME_DRIVER=eoshome -e REVA_STORAGE_HOME_MOUNT_ID=1284d238-aa92-42ce-bdc4-0b0000009158 ocis ./bin/ocis run reva-storage-home +docker-compose -f ./docker-compose-eos-ci.yml exec ocis /ocis/bin/ocis kill reva-storage-home-data +docker-compose -f ./docker-compose-eos-ci.yml exec -e REVA_STORAGE_HOME_DATA_DRIVER=eoshome ocis ./bin/ocis run reva-storage-home-data + diff --git a/tests/spwan_eos.sh b/tests/spwan_eos.sh new file mode 100644 index 00000000000..3cab62af06f --- /dev/null +++ b/tests/spwan_eos.sh @@ -0,0 +1,28 @@ +#!/bin/bash +ME=$DRONE_HCLOUD_USER +SERVER_NAME=droneci-eos-test-${DRONE_COMMIT_ID} + +# Create a new machine on hcloud for eos +hcloud server create --type cx21 --image ubuntu-20.04 --ssh-key $ME --name $SERVER_NAME --label owner=$ME --label for=test --label from=eos-compose + +IPADDR=$(hcloud server ip $SERVER_NAME) +OCIS_DOMAIN=$(hcloud server ip $SERVER_NAME) + +# timeout 180 while [[ \"$(curl -k -v -s -o /dev/null -w ''%{http_code}'' https://:9200)\" != \"200\" ]]; do sleep 2; done +# sleep 15 + +# Setup system and clone ocis +ssh -t root@$IPADDR apt-get update -y +ssh -t root@$IPADDR apt-get install -y git screen docker.io docker-compose ldap-utils +ssh -t root@$IPADDR git clone https://github.com/owncloud/ocis.git /ocis +ssh -t root@$IPADDR "cd /ocis && git checkout $DRONE_COMMIT_ID" + +# Create necessary files +ssh -t root@$IPADDR "cd /ocis/tests/config/drone && OCIS_DOMAIN=${IPADDR} bash /ocis/tests/config/drone/create-config.json.sh" +ssh -t root@$IPADDR "cd /ocis/tests/config/drone && OCIS_DOMAIN=${IPADDR} bash /ocis/tests/config/drone/create-identifier-registration.sh" + +# run ocis with eos +ssh -t root@$IPADDR "cd /ocis && OCIS_DOMAIN=${IPADDR} docker-compose -f ./docker-compose-eos-ci.yml up -d" + +# Some necessary configuration for eos +ssh -t root@$IPADDR "cd /ocis && bash /ocis/tests/config/drone/setup-eos.sh"