Skip to content
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
11 changes: 11 additions & 0 deletions .drone.yml
Original file line number Diff line number Diff line change
Expand Up @@ -596,6 +596,7 @@ pipeline:
image: nextcloudci/php7.0:php7.0-19
commands:
- phpenmod xdebug
- ./tests/drone-wait-objectstore.sh
- TEST_SELECTION=PRIMARY-${OBJECT_STORE} ./autotest.sh sqlite
- wget https://codecov.io/bash -O codecov.sh
- sh -c "if [ '$DRONE_BUILD_EVENT' = 'pull_request' ]; then bash codecov.sh -B $DRONE_BRANCH -C $DRONE_COMMIT -P $DRONE_PULL_REQUEST -t 117641e2-a9e8-4b7b-984b-ae872d9b05f5 -f tests/autotest-clover-sqlite.xml; fi"
Expand Down Expand Up @@ -743,6 +744,8 @@ matrix:
- TESTS: carddavtester-old-endpoint
- TESTS: object-store
OBJECT_STORE: s3
- TESTS: object-store
OBJECT_STORE: swift
- TESTS: sqlite-php7.0-samba-native
- TESTS: sqlite-php7.0-samba-non-native
- TEST: memcache-memcached
Expand Down Expand Up @@ -838,6 +841,14 @@ services:
when:
matrix:
OBJECT_STORE: s3
dockswift:
image: icewind1991/dockswift
environment:
- INITIALIZE=yes
- IPADDRESS=dockswift
when:
matrix:
OBJECT_STORE: swift
selenium:
image: selenium/standalone-firefox:2.53.1-beryllium
environment:
Expand Down
3 changes: 3 additions & 0 deletions autotest.sh
Original file line number Diff line number Diff line change
Expand Up @@ -369,6 +369,9 @@ function execute_tests {
if [ "$TEST_SELECTION" == "PRIMARY-s3" ]; then
GROUP='--group PRIMARY-s3'
fi
if [ "$TEST_SELECTION" == "PRIMARY-swift" ]; then
GROUP='--group PRIMARY-swift'
fi

COVER=''
if [ -z "$NOCOVERAGE" ]; then
Expand Down
3 changes: 2 additions & 1 deletion lib/private/Files/Mount/ObjectHomeMountProvider.php
Original file line number Diff line number Diff line change
Expand Up @@ -84,10 +84,11 @@ private function getSingleBucketObjectStoreConfig(IUser $user) {
if (!isset($config['arguments'])) {
$config['arguments'] = [];
}
$config['arguments']['user'] = $user;
// instantiate object store implementation
$config['arguments']['objectstore'] = new $config['class']($config['arguments']);

$config['arguments']['user'] = $user;

return $config;
}

Expand Down
2 changes: 1 addition & 1 deletion lib/private/Files/ObjectStore/ObjectStoreStorage.php
Original file line number Diff line number Diff line change
Expand Up @@ -369,7 +369,7 @@ public function touch($path, $mtime = null) {
'app' => 'objectstore',
'message' => 'Could not create object for ' . $path,
]);
return false;
throw $ex;
}
}
return true;
Expand Down
17 changes: 16 additions & 1 deletion lib/private/Files/ObjectStore/Swift.php
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@
namespace OC\Files\ObjectStore;

use Guzzle\Http\Exception\ClientErrorResponseException;
use Guzzle\Http\Exception\CurlException;
use Icewind\Streams\RetryWrapper;
use OCP\Files\ObjectStore\IObjectStore;
use OCP\Files\StorageAuthException;
Expand Down Expand Up @@ -87,6 +88,9 @@ public function __construct($params) {
$this->params = $params;
}

/**
* @suppress PhanNonClassMethodCall
*/
protected function init() {
if ($this->container) {
return;
Expand Down Expand Up @@ -117,6 +121,10 @@ protected function init() {
/** @var Catalog $catalog */
$catalog = $this->client->getCatalog();

if (count($catalog->getItems()) === 0) {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Phan complains about this 🤔

lib/private/Files/ObjectStore/Swift.php:121 PhanNonClassMethodCall Call to method getItems on non-class type array

@rullzer Any idea?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Let me try something. Because it seems phan takes preference over the getCatalog phpdoc. Which is lying: https://github.com/nextcloud/3rdparty/blob/master/rackspace/php-opencloud/lib/OpenCloud/OpenStack.php#L259-L267

throw new StorageAuthException('Keystone did not provide a valid catalog, verify the credentials');
}

if (isset($this->params['serviceName'])) {
$serviceName = $this->params['serviceName'];
} else {
Expand Down Expand Up @@ -153,6 +161,13 @@ protected function init() {
} else {
throw $ex;
}
} catch (CurlException $e) {
if ($e->getErrorNo() === 7) {
$host = $e->getCurlHandle()->getUrl()->getHost() . ':' . $e->getCurlHandle()->getUrl()->getPort();
\OC::$server->getLogger()->error("Can't connect to object storage server at $host");
throw new StorageNotAvailableException("Can't connect to object storage server at $host", StorageNotAvailableException::STATUS_ERROR, $e);
}
throw $e;
}
}

Expand All @@ -176,7 +191,7 @@ private function importToken() {
$itemClass = new \stdClass();
$itemClass->name = $item['name'];
$itemClass->endpoints = array_map(function (array $endpoint) {
return (object) $endpoint;
return (object)$endpoint;
}, $item['endpoints']);
$itemClass->type = $item['type'];

Expand Down
10 changes: 10 additions & 0 deletions tests/drone-wait-objectstore.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
#!/bin/bash

if [ "$OBJECT_STORE" == "swift" ]; then
echo "waiting for swift"
until curl -I http://dockswift:5000/v3
do
sleep 2
done
sleep 60
fi
3 changes: 3 additions & 0 deletions tests/lib/Files/ObjectStore/SwiftTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,9 @@

use OC\Files\ObjectStore\Swift;

/**
* @group PRIMARY-swift
*/
class SwiftTest extends ObjectStoreTest {
/**
* @return \OCP\Files\ObjectStore\IObjectStore
Expand Down
16 changes: 16 additions & 0 deletions tests/preseed-config.php
Original file line number Diff line number Diff line change
Expand Up @@ -34,3 +34,19 @@
)
];
}
if (getenv('OBJECT_STORE') === 'swift') {
$swiftHost = getenv('DRONE') === 'true' ? 'dockswift' : 'localhost';
$CONFIG['objectstore'] = [
'class' => 'OC\\Files\\ObjectStore\\Swift',
'arguments' => array(
'autocreate' => true,
'username' => 'swift',
'tenantName' => 'service',
'password' => 'swift',
'serviceName' => 'swift',
'region' => 'regionOne',
'url' => "http://$swiftHost:5000/v2.0",
'bucket' => 'nextcloud'
)
];
}