Merge pull request #14077 from owncloud/autotest-external-swift

[files_external] swift tests
This commit is contained in:
Thomas Müller 2015-11-20 13:57:54 +01:00
commit 308aaf89cd
10 changed files with 270 additions and 68 deletions

View File

@ -32,18 +32,18 @@ class Swift extends Storage {
protected function setUp() {
parent::setUp();
$this->config = include('files_external/tests/config.php');
if (!is_array($this->config) or !isset($this->config['swift'])
or !$this->config['swift']['run']) {
$this->config = include('files_external/tests/config.swift.php');
if (!is_array($this->config) or !$this->config['run']) {
$this->markTestSkipped('OpenStack Object Storage backend not configured');
}
$this->instance = new \OC\Files\Storage\Swift($this->config['swift']);
$this->instance = new \OC\Files\Storage\Swift($this->config);
}
protected function tearDown() {
if ($this->instance) {
try {
$connection = $this->instance->getConnection();
$container = $connection->getContainer($this->config['swift']['bucket']);
$container = $connection->getContainer($this->config['bucket']);
$objects = $container->objectList();
while($object = $objects->next()) {
@ -52,8 +52,15 @@ class Swift extends Storage {
}
$container->delete();
} catch (\Guzzle\Http\Exception\ClientErrorResponseException $e) {
// container didn't exist, so we don't need to delete it
}
}
parent::tearDown();
}
public function testStat() {
$this->markTestSkipped('Swift doesn\'t update the parents folder mtime');
}
}

View File

@ -49,9 +49,21 @@ echo "${docker_image} container: $container"
# put container IDs into a file to drop them after the test run (keep in mind that multiple tests run in parallel on the same host)
echo $container >> $thisFolder/dockerContainerCeph.$EXECUTOR_NUMBER.amazons3
# TODO find a way to determine the successful initialization inside the docker container
echo "Waiting 20 seconds for ceph initialization ... "
sleep 20
echo -n "Waiting for ceph initialization"
starttime=$(date +%s)
# support for GNU netcat and BSD netcat
while ! (nc -c -w 1 ${host} ${port} </dev/null >&/dev/null \
|| nc -w 1 ${host} ${port} </dev/null >&/dev/null); do
sleep 1
echo -n '.'
if (( $(date +%s) > starttime + 60 )); then
echo
echo "[ERROR] Waited 60 seconds, no response" >&2
exit 1
fi
done
echo
sleep 1
echo "Create ceph user"
docker exec $container radosgw-admin user create \

View File

@ -54,12 +54,25 @@ echo "ftp container: $container"
# put container IDs into a file to drop them after the test run (keep in mind that multiple tests run in parallel on the same host)
echo $container >> $thisFolder/dockerContainerMorrisJobke.$EXECUTOR_NUMBER.ftp
echo -n "Waiting for ftp initialization"
starttime=$(date +%s)
# support for GNU netcat and BSD netcat
while ! (nc -c -w 1 ${host} 21 </dev/null >&/dev/null \
|| nc -w 1 ${host} 21 </dev/null >&/dev/null); do
sleep 1
echo -n '.'
if (( $(date +%s) > starttime + 60 )); then
echo
echo "[ERROR] Waited 60 seconds, no response" >&2
exit 1
fi
done
echo
sleep 1
if [ -n "$DEBUG" ]; then
cat $thisFolder/config.ftp.php
cat $thisFolder/dockerContainerMorrisJobke.$EXECUTOR_NUMBER.ftp
fi
# TODO find a way to determine the successful initialization inside the docker container
echo "Waiting 5 seconds for ftp initialization ... "
sleep 5

View File

@ -54,15 +54,27 @@ echo "sftp container: $container"
# put container IDs into a file to drop them after the test run (keep in mind that multiple tests run in parallel on the same host)
echo $container >> $thisFolder/dockerContainerAtmoz.$EXECUTOR_NUMBER.sftp
echo -n "Waiting for sftp initialization"
starttime=$(date +%s)
# support for GNU netcat and BSD netcat
while ! (nc -c -w 1 ${host} 22 </dev/null >&/dev/null \
|| nc -w 1 ${host} 22 </dev/null >&/dev/null); do
sleep 1
echo -n '.'
if (( $(date +%s) > starttime + 60 )); then
echo
echo "[ERROR] Waited 60 seconds, no response" >&2
exit 1
fi
done
echo
sleep 1
if [ -n "$DEBUG" ]; then
cat $thisFolder/config.sftp.php
cat $thisFolder/dockerContainerAtmoz.$EXECUTOR_NUMBER.sftp
fi
# TODO find a way to determine the successful initialization inside the docker container
echo "Waiting 5 seconds for sftp initialization ... "
sleep 5
# create folder "upload" with correct permissions
docker exec $container bash -c "mkdir /home/$user/upload && chown $user:users /home/$user/upload"

View File

@ -52,12 +52,25 @@ echo "samba container: $container"
# put container IDs into a file to drop them after the test run (keep in mind that multiple tests run in parallel on the same host)
echo $container >> $thisFolder/dockerContainerSilvershell.$EXECUTOR_NUMBER.smb
echo -n "Waiting for samba initialization"
starttime=$(date +%s)
# support for GNU netcat and BSD netcat
while ! (nc -c -w 1 ${host} 445 </dev/null >&/dev/null \
|| nc -w 1 ${host} 445 </dev/null >&/dev/null); do
sleep 1
echo -n '.'
if (( $(date +%s) > starttime + 60 )); then
echo
echo "[ERROR] Waited 60 seconds, no response" >&2
exit 1
fi
done
echo
sleep 1
if [ -n "$DEBUG" ]; then
cat $thisFolder/config.smb.php
cat $thisFolder/dockerContainerSilvershell.$EXECUTOR_NUMBER.smb
fi
# TODO find a way to determine the successful initialization inside the docker container
echo "Waiting 5 seconds for smbd initialization ... "
sleep 5

View File

@ -19,6 +19,12 @@ user=smb-test
password=!owncloud123
host=WIN-9GTFAS08C15
if ! (nc -c -w 1 ${host} 445 </dev/null >&/dev/null \
|| nc -w 1 ${host} 445 </dev/null >&/dev/null); then
echo "[ERROR] Server not reachable" >&2
exit 1
fi
cat > $thisFolder/config.smb.php <<DELIM
<?php

View File

@ -0,0 +1,94 @@
#!/bin/bash
#
# ownCloud
#
# This script start a docker container to test the files_external tests
# against. It will also change the files_external config to use the docker
# container as testing environment. This is reverted in the stop step.W
#
# Set environment variable DEBUG to print config file
#
# @author Morris Jobke
# @author Robin McCorkell
# @copyright 2015 ownCloud
if ! command -v docker >/dev/null 2>&1; then
echo "No docker executable found - skipped docker setup"
exit 0;
fi
echo "Docker executable found - setup docker"
docker_image=xenopathic/ceph-keystone
echo "Fetch recent ${docker_image} docker image"
docker pull ${docker_image}
# retrieve current folder to place the config in the parent folder
thisFolder=`echo $0 | replace "env/start-swift-ceph.sh" ""`
if [ -z "$thisFolder" ]; then
thisFolder="."
fi;
port=5001
user=test
pass=testing
tenant=testenant
region=testregion
service=testceph
container=`docker run -d \
-e KEYSTONE_PUBLIC_PORT=${port} \
-e KEYSTONE_ADMIN_USER=${user} \
-e KEYSTONE_ADMIN_PASS=${pass} \
-e KEYSTONE_ADMIN_TENANT=${tenant} \
-e KEYSTONE_ENDPOINT_REGION=${region} \
-e KEYSTONE_SERVICE=${service} \
${docker_image}`
host=`docker inspect --format="{{.NetworkSettings.IPAddress}}" $container`
echo "${docker_image} container: $container"
# put container IDs into a file to drop them after the test run (keep in mind that multiple tests run in parallel on the same host)
echo $container >> $thisFolder/dockerContainerCeph.$EXECUTOR_NUMBER.swift
echo -n "Waiting for ceph initialization"
starttime=$(date +%s)
# support for GNU netcat and BSD netcat
while ! (nc -c -w 1 ${host} 80 </dev/null >&/dev/null \
|| nc -w 1 ${host} 80 </dev/null >&/dev/null); do
sleep 1
echo -n '.'
if (( $(date +%s) > starttime + 60 )); then
echo
echo "[ERROR] Waited 60 seconds, no response" >&2
exit 1
fi
done
echo
sleep 1
cat > $thisFolder/config.swift.php <<DELIM
<?php
return array(
'run'=>true,
'url'=>'http://$host:$port/v2.0',
'user'=>'$user',
'tenant'=>'$tenant',
'password'=>'$pass',
'service_name'=>'$service',
'bucket'=>'swift',
'region' => '$region',
);
DELIM
if [ -n "$DEBUG" ]; then
cat $thisFolder/config.swift.php
cat $thisFolder/dockerContainerCeph.$EXECUTOR_NUMBER.swift
fi

View File

@ -46,20 +46,30 @@ fi
container=`docker run -P $parameter -d -e ADMINLOGIN=test -e ADMINPWD=test morrisjobke/owncloud`
# TODO find a way to determine the successful initialization inside the docker container
echo "Waiting 30 seconds for ownCloud initialization ... "
sleep 30
# get mapped port on host for internal port 80 - output is IP:PORT - we need to extract the port with 'cut'
port=`docker port $container 80 | cut -f 2 -d :`
host=`docker inspect $container | grep IPAddress | cut -d '"' -f 4`
echo -n "Waiting for ownCloud initialization"
starttime=$(date +%s)
# support for GNU netcat and BSD netcat
while ! (nc -c -w 1 ${host} 80 </dev/null >&/dev/null \
|| nc -w 1 ${host} 80 </dev/null >&/dev/null); do
sleep 1
echo -n '.'
if (( $(date +%s) > starttime + 60 )); then
echo
echo "[ERROR] Waited 60 seconds, no response" >&2
exit 1
fi
done
echo
sleep 1
cat > $thisFolder/config.webdav.php <<DELIM
<?php
return array(
'run'=>true,
'host'=>'localhost:$port/owncloud/remote.php/webdav/',
'host'=>'${host}:80/owncloud/remote.php/webdav/',
'user'=>'test',
'password'=>'test',
'root'=>'',

View File

@ -0,0 +1,36 @@
#!/bin/bash
#
# ownCloud
#
# This script stops the docker container the files_external tests were run
# against. It will also revert the config changes done in start step.
#
# @author Morris Jobke
# @author Robin McCorkell
# @copyright 2015 ownCloud
if ! command -v docker >/dev/null 2>&1; then
echo "No docker executable found - skipped docker stop"
exit 0;
fi
echo "Docker executable found - stop and remove docker containers"
# retrieve current folder to remove the config from the parent folder
thisFolder=`echo $0 | replace "env/stop-swift-ceph.sh" ""`
if [ -z "$thisFolder" ]; then
thisFolder="."
fi;
# stopping and removing docker containers
for container in `cat $thisFolder/dockerContainerCeph.$EXECUTOR_NUMBER.swift`; do
echo "Stopping and removing docker container $container"
# kills running container and removes it
docker rm -f $container
done;
# cleanup
rm $thisFolder/config.swift.php
rm $thisFolder/dockerContainerCeph.$EXECUTOR_NUMBER.swift

View File

@ -193,8 +193,7 @@ EOF
echo "name: $name"
# execute start file
./$FILES_EXTERNAL_BACKEND_ENV_PATH/$startFile
if ./$FILES_EXTERNAL_BACKEND_ENV_PATH/$startFile; then
# getting backend to test from filename
# it's the part between the dots startSomething.TestToRun.sh
testToRun=`echo $startFile | cut -d '-' -f 2`
@ -210,6 +209,7 @@ EOF
"$PHPUNIT" --configuration phpunit-autotest-external.xml --log-junit "autotest-external-results-$1-$name.xml" "$FILES_EXTERNAL_BACKEND_PATH/$testToRun.php"
RESULT=$?
fi
fi
# calculate stop file
stopFile=`echo "$startFile" | sed 's/start/stop/'`
@ -224,8 +224,7 @@ EOF
#
# start test execution
#
if [ -z "$1" ]
then
if [ -z "$1" ]; then
# run all known database configs
for DBCONFIG in $DBCONFIGS; do
execute_tests $DBCONFIG "$2"