Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[files_external] swift tests #14077

Merged
merged 7 commits into from
Nov 20, 2015
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
31 changes: 19 additions & 12 deletions apps/files_external/tests/backends/swift.php
Original file line number Diff line number Diff line change
Expand Up @@ -32,28 +32,35 @@ 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) {
$connection = $this->instance->getConnection();
$container = $connection->getContainer($this->config['swift']['bucket']);
try {
$connection = $this->instance->getConnection();
$container = $connection->getContainer($this->config['bucket']);

$objects = $container->objectList();
while($object = $objects->next()) {
$object->setName(str_replace('#','%23',$object->getName()));
$object->delete();
}
$objects = $container->objectList();
while($object = $objects->next()) {
$object->setName(str_replace('#','%23',$object->getName()));
$object->delete();
}

$container->delete();
$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');
}
}
18 changes: 15 additions & 3 deletions apps/files_external/tests/env/start-amazons3-ceph.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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 \
Expand Down
19 changes: 16 additions & 3 deletions apps/files_external/tests/env/start-ftp-morrisjobke.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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

20 changes: 16 additions & 4 deletions apps/files_external/tests/env/start-sftp-atmoz.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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"

19 changes: 16 additions & 3 deletions apps/files_external/tests/env/start-smb-silvershell.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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

6 changes: 6 additions & 0 deletions apps/files_external/tests/env/start-smb-windows.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
94 changes: 94 additions & 0 deletions apps/files_external/tests/env/start-swift-ceph.sh
Original file line number Diff line number Diff line change
@@ -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
26 changes: 18 additions & 8 deletions apps/files_external/tests/env/start-webdav-ownCloud.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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'=>'',
Expand Down
36 changes: 36 additions & 0 deletions apps/files_external/tests/env/stop-swift-ceph.sh
Original file line number Diff line number Diff line change
@@ -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

Loading