From 1d0568efe9153c64f738461b6baa0f548da56c13 Mon Sep 17 00:00:00 2001 From: Stephan Renatus Date: Tue, 20 Nov 2018 10:06:05 +0100 Subject: [PATCH 1/5] storage/sql: remove standup.sh Signed-off-by: Stephan Renatus --- storage/sql/standup.sh | 107 ----------------------------------------- 1 file changed, 107 deletions(-) delete mode 100755 storage/sql/standup.sh diff --git a/storage/sql/standup.sh b/storage/sql/standup.sh deleted file mode 100755 index a5d33118..00000000 --- a/storage/sql/standup.sh +++ /dev/null @@ -1,107 +0,0 @@ -#!/bin/bash - -if [ "$EUID" -ne 0 ] - then echo "Please run as root" - exit -fi - -function usage { - cat << EOF >> /dev/stderr -Usage: sudo ./standup.sh [create|destroy] [postgres] - -This is a script for standing up test databases. It uses systemd to daemonize -rkt containers running on a local loopback IP. - -The general workflow is to create a daemonized container, use the output to set -the test environment variables, run the tests, then destroy the container. - - sudo ./standup.sh create postgres - # Copy environment variables and run tests. - go test -v -i # always install test dependencies - go test -v - sudo ./standup.sh destroy postgres - -EOF - exit 2 -} - -function main { - if [ "$#" -ne 2 ]; then - usage - exit 2 - fi - - case "$1" in - "create") - case "$2" in - "postgres") - create_postgres;; - *) - usage - exit 2 - ;; - esac - ;; - "destroy") - case "$2" in - "postgres") - destroy_postgres;; - *) - usage - exit 2 - ;; - esac - ;; - *) - usage - exit 2 - ;; - esac -} - -function wait_for_file { - while [ ! -f $1 ]; do - sleep 1 - done -} - -function wait_for_container { - while [ -z "$( rkt list --full | grep $1 | grep running )" ]; do - sleep 1 - done -} - -function create_postgres { - UUID_FILE=/tmp/dex-postgres-uuid - if [ -f $UUID_FILE ]; then - echo "postgres database already exists, try ./standup.sh destroy postgres" - exit 2 - fi - - echo "Starting postgres. To view progress run:" - echo "" - echo " journalctl -fu dex-postgres" - echo "" - systemd-run --unit=dex-postgres \ - rkt run --uuid-file-save=$UUID_FILE --insecure-options=image docker://postgres:9.6 - - wait_for_file $UUID_FILE - - UUID=$( cat $UUID_FILE ) - wait_for_container $UUID - HOST=$( rkt list --full | grep "$UUID" | awk '{ print $NF }' | sed -e 's/default:ip4=//g' ) - echo "To run tests export the following environment variables:" - echo "" - echo " export DEX_POSTGRES_DATABASE=postgres; export DEX_POSTGRES_USER=postgres; export DEX_POSTGRES_PASSWORD=postgres; export DEX_POSTGRES_HOST=$HOST:5432" - echo "" -} - -function destroy_postgres { - UUID_FILE=/tmp/dex-postgres-uuid - systemctl stop dex-postgres - rkt rm --uuid-file=$UUID_FILE - rm $UUID_FILE -} - - -main $@ From cbcb1f61f3dcb46adf7bb9b1a3d247d86f6c00b7 Mon Sep 17 00:00:00 2001 From: Stephan Renatus Date: Tue, 20 Nov 2018 10:14:26 +0100 Subject: [PATCH 2/5] dev-integration-tests: update database steps (just use docker) Signed-off-by: Stephan Renatus --- Documentation/dev-integration-tests.md | 39 +++++++++----------------- 1 file changed, 14 insertions(+), 25 deletions(-) diff --git a/Documentation/dev-integration-tests.md b/Documentation/dev-integration-tests.md index a9ce1ad3..7e8e6683 100644 --- a/Documentation/dev-integration-tests.md +++ b/Documentation/dev-integration-tests.md @@ -18,39 +18,28 @@ $ ./scripts/test-k8s.sh ## Postgres -Running database tests locally require: +Running database tests locally requires: -* A systemd based Linux distro. -* A recent version of [rkt](https://github.com/coreos/rkt) installed. +* Docker -The `standup.sh` script in the SQL directory is used to run databases in containers with systemd daemonizing the process. +To run the database integration tests: -``` -$ sudo ./storage/sql/standup.sh create postgres -Starting postgres. To view progress run +- start a postgres container: - journalctl -fu dex-postgres + `docker run --name dex-postgres -e POSTGRES_USER=postgres -e POSTGRES_DB=dex -p 5432:5432 -d postgres:11` +- export the required environment variables: -Running as unit dex-postgres.service. -To run tests export the following environment variables: + `export DEX_POSTGRES_DATABASE=dex DEX_POSTGRES_USER=postgres DEX_POSTGRES_PASSWORD=postgres DEX_POSTGRES_HOST=127.0.0.1:5432` - export DEX_POSTGRES_DATABASE=postgres; export DEX_POSTGRES_USER=postgres; export DEX_POSTGRES_PASSWORD=postgres; export DEX_POSTGRES_HOST=172.16.28.3:5432 +- run the storage/sql tests: -``` + ``` + $ # sqlite3 takes forever to compile, be sure to install test dependencies + $ go test -v -i ./storage/sql + $ go test -v ./storage/sql + ``` -Exporting the variables will cause the database tests to be run, rather than skipped. - -``` -$ # sqlite3 takes forever to compile, be sure to install test dependencies -$ go test -v -i ./storage/sql -$ go test -v ./storage/sql -``` - -When you're done, tear down the unit using the `standup.sh` script. - -``` -$ sudo ./storage/sql/standup.sh destroy postgres -``` +- clean up the postgres container: `docker rm -f dex-postgres` ## LDAP From 0740c2370d8e3478169c5697dbaee815033c0319 Mon Sep 17 00:00:00 2001 From: Stephan Renatus Date: Tue, 20 Nov 2018 10:44:13 +0100 Subject: [PATCH 3/5] storage/etcd: remove standup.sh Signed-off-by: Stephan Renatus --- storage/etcd/standup.sh | 109 ---------------------------------------- 1 file changed, 109 deletions(-) delete mode 100755 storage/etcd/standup.sh diff --git a/storage/etcd/standup.sh b/storage/etcd/standup.sh deleted file mode 100755 index 1944b111..00000000 --- a/storage/etcd/standup.sh +++ /dev/null @@ -1,109 +0,0 @@ -#!/bin/bash - -if [ "$EUID" -ne 0 ] - then echo "Please run as root" - exit -fi - -function usage { - cat << EOF >> /dev/stderr -Usage: sudo ./standup.sh [create|destroy] [etcd] - -This is a script for standing up test databases. It uses systemd to daemonize -rkt containers running on a local loopback IP. - -The general workflow is to create a daemonized container, use the output to set -the test environment variables, run the tests, then destroy the container. - - sudo ./standup.sh create etcd - # Copy environment variables and run tests. - go test -v -i # always install test dependencies - go test -v - sudo ./standup.sh destroy etcd - -EOF - exit 2 -} - -function main { - if [ "$#" -ne 2 ]; then - usage - exit 2 - fi - - case "$1" in - "create") - case "$2" in - "etcd") - create_etcd;; - *) - usage - exit 2 - ;; - esac - ;; - "destroy") - case "$2" in - "etcd") - destroy_etcd;; - *) - usage - exit 2 - ;; - esac - ;; - *) - usage - exit 2 - ;; - esac -} - -function wait_for_file { - while [ ! -f $1 ]; do - sleep 1 - done -} - -function wait_for_container { - while [ -z "$( rkt list --full | grep $1 | grep running )" ]; do - sleep 1 - done -} - -function create_etcd { - UUID_FILE=/tmp/dex-etcd-uuid - if [ -f $UUID_FILE ]; then - echo "etcd database already exists, try ./standup.sh destroy etcd" - exit 2 - fi - - echo "Starting etcd . To view progress run:" - echo "" - echo " journalctl -fu dex-etcd" - echo "" - UNIFIED_CGROUP_HIERARCHY=no \ - systemd-run --unit=dex-etcd \ - rkt run --uuid-file-save=$UUID_FILE --insecure-options=image \ - --net=host \ - docker://quay.io/coreos/etcd:v3.2.9 - - wait_for_file $UUID_FILE - - UUID=$( cat $UUID_FILE ) - wait_for_container $UUID - echo "To run tests export the following environment variables:" - echo "" - echo " export DEX_ETCD_ENDPOINTS=http://localhost:2379" - echo "" -} - -function destroy_etcd { - UUID_FILE=/tmp/dex-etcd-uuid - systemctl stop dex-etcd - rkt rm --uuid-file=$UUID_FILE - rm $UUID_FILE -} - - -main $@ From 58b546a5be989f668e4fe6f02b4179debeccb0d8 Mon Sep 17 00:00:00 2001 From: Stephan Renatus Date: Tue, 20 Nov 2018 10:44:52 +0100 Subject: [PATCH 4/5] dev-integration-test: add etcd notes Signed-off-by: Stephan Renatus --- Documentation/dev-integration-tests.md | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) diff --git a/Documentation/dev-integration-tests.md b/Documentation/dev-integration-tests.md index 7e8e6683..c9c84d2d 100644 --- a/Documentation/dev-integration-tests.md +++ b/Documentation/dev-integration-tests.md @@ -41,6 +41,26 @@ To run the database integration tests: - clean up the postgres container: `docker rm -f dex-postgres` +## Etcd + +These tests can also be executed using docker: + +- start the container (where `NODE1` is set to the host IP address): + + ``` + $ export NODE1=0.0.0.0 + $ docker run --name dex-etcd -p 2379:2379 -p 2380:2380 gcr.io/etcd-development/etcd:v3.3.10 \ + /usr/local/bin/etcd --name node1 \ + --initial-advertise-peer-urls http://${NODE1}:2380 --listen-peer-urls http://${NODE1}:2380 \ + --advertise-client-urls http://${NODE1}:2379 --listen-client-urls http://${NODE1}:2379 \ + --initial-cluster node1=http://${NODE1}:2380 + ``` + +- run the tests, passing the correct endpoint for this etcd instance in `DEX_ETCD_ENDPOINTS`: + + `DEX_ETCD_ENDPOINTS=http://localhost:2379 go test -v ./storage/etcd` +- clean up the etcd container: `docker rm -f dex-etcd` + ## LDAP The LDAP integration tests require [OpenLDAP][openldap] installed on the host machine. To run them, use `go test`: From 6182f213ef5c0780bf2983eac8588ffea5049ada Mon Sep 17 00:00:00 2001 From: Stephan Renatus Date: Tue, 20 Nov 2018 11:45:07 +0100 Subject: [PATCH 5/5] storage/conformance: remove old build tags Signed-off-by: Stephan Renatus --- storage/conformance/conformance.go | 2 -- storage/conformance/transactions.go | 2 -- 2 files changed, 4 deletions(-) diff --git a/storage/conformance/conformance.go b/storage/conformance/conformance.go index 2f427971..a1399807 100644 --- a/storage/conformance/conformance.go +++ b/storage/conformance/conformance.go @@ -1,5 +1,3 @@ -// +build go1.7 - // Package conformance provides conformance tests for storage implementations. package conformance diff --git a/storage/conformance/transactions.go b/storage/conformance/transactions.go index 4b268e0f..dc1be1b6 100644 --- a/storage/conformance/transactions.go +++ b/storage/conformance/transactions.go @@ -1,5 +1,3 @@ -// +build go1.7 - package conformance import (