Merge pull request #1350 from srenatus/sr/storage/nuke-standup-scripts
storage: nuke standup scripts, adapt dev-integration-test docs
This commit is contained in:
commit
f7f7314fdb
@ -18,39 +18,48 @@ $ ./scripts/test-k8s.sh
|
|||||||
|
|
||||||
## Postgres
|
## Postgres
|
||||||
|
|
||||||
Running database tests locally require:
|
Running database tests locally requires:
|
||||||
|
|
||||||
* A systemd based Linux distro.
|
* Docker
|
||||||
* A recent version of [rkt](https://github.com/coreos/rkt) installed.
|
|
||||||
|
|
||||||
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:
|
||||||
|
|
||||||
```
|
- start a postgres container:
|
||||||
$ sudo ./storage/sql/standup.sh create postgres
|
|
||||||
Starting postgres. To view progress run
|
|
||||||
|
|
||||||
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.
|
`export DEX_POSTGRES_DATABASE=dex DEX_POSTGRES_USER=postgres DEX_POSTGRES_PASSWORD=postgres DEX_POSTGRES_HOST=127.0.0.1:5432`
|
||||||
To run tests export the following environment variables:
|
|
||||||
|
|
||||||
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.
|
- clean up the postgres container: `docker rm -f dex-postgres`
|
||||||
|
|
||||||
```
|
## Etcd
|
||||||
$ # 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.
|
These tests can also be executed using docker:
|
||||||
|
|
||||||
```
|
- start the container (where `NODE1` is set to the host IP address):
|
||||||
$ sudo ./storage/sql/standup.sh destroy postgres
|
|
||||||
```
|
```
|
||||||
|
$ 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
|
## LDAP
|
||||||
|
|
||||||
|
@ -1,5 +1,3 @@
|
|||||||
// +build go1.7
|
|
||||||
|
|
||||||
// Package conformance provides conformance tests for storage implementations.
|
// Package conformance provides conformance tests for storage implementations.
|
||||||
package conformance
|
package conformance
|
||||||
|
|
||||||
|
@ -1,5 +1,3 @@
|
|||||||
// +build go1.7
|
|
||||||
|
|
||||||
package conformance
|
package conformance
|
||||||
|
|
||||||
import (
|
import (
|
||||||
|
@ -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 $@
|
|
@ -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 $@
|
|
Reference in New Issue
Block a user