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

Adds FerretDB to docker-compose.yml #274

Draft
wants to merge 10 commits into
base: main
Choose a base branch
from
Draft
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
2 changes: 1 addition & 1 deletion .github/workflows/tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -98,5 +98,5 @@ jobs:
sleep 10

- name: Run ${{matrix.service}} Tests
run: docker compose exec -T tests vendor/bin/phpunit /usr/src/code/tests/e2e/Adapter/${{matrix.adapter}}Test.php --debug || true
run: docker compose exec -T tests vendor/bin/phpunit /usr/src/code/tests/e2e/Adapter/${{matrix.adapter}}Test.php

14 changes: 14 additions & 0 deletions bin/tasks/index.php
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
use Utopia\Database\Database;
use Utopia\Database\Adapter\Mongo;
use Utopia\Database\Adapter\MariaDB;
use Utopia\Database\Adapter\Ferret;
use Utopia\Validator\Text;

/**
Expand Down Expand Up @@ -44,6 +45,19 @@
$database = new Database(new Mongo($client), $cache);
break;

case 'ferretdb':
$client = new Client(
$name,
'ferretdb',
27017,
'',
'',
false
);

$database = new Database(new Ferret($client), $cache);
break;

case 'mariadb':
$dbHost = 'mariadb';
$dbPort = '3306';
Expand Down
41 changes: 41 additions & 0 deletions bin/tasks/load.php
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@
use Utopia\Database\Document;
use Utopia\Database\Adapter\Mongo;
use Utopia\Database\Adapter\MariaDB;
use Utopia\Database\Adapter\Ferret;
use Utopia\Validator\Numeric;
use Utopia\Validator\Text;

Expand Down Expand Up @@ -207,6 +208,46 @@
});
break;

case 'ferretdb':
Co\run(function () use (&$start, $limit, $name, $namespace, $cache) {
$client = new Client(
$name,
'mongo',
27017,
'',
'',
false
);

$database = new Database(new Ferret($client), $cache);
$database->setDefaultDatabase($name);
$database->setNamespace($namespace);

// Outline collection schema
createSchema($database);

// Fill DB
$faker = Factory::create();

$start = microtime(true);

for ($i = 0; $i < $limit / 1000; $i++) {
go(function () use ($client, $faker, $name, $namespace, $cache) {
$database = new Database(new Mongo($client), $cache);
$database->setDefaultDatabase($name);
$database->setNamespace($namespace);

// Each coroutine loads 1000 documents
for ($i = 0; $i < 1000; $i++) {
addArticle($database, $faker);
}

$database = null;
});
}
});
break;

default:
echo 'Adapter not supported';
return;
Expand Down
16 changes: 16 additions & 0 deletions bin/tasks/query.php
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
use Utopia\Database\Query;
use Utopia\Database\Adapter\Mongo;
use Utopia\Database\Adapter\MariaDB;
use Utopia\Database\Adapter\Ferret;
use Utopia\Database\Validator\Authorization;
use Utopia\Validator\Numeric;
use Utopia\Validator\Text;
Expand Down Expand Up @@ -49,6 +50,21 @@
$database->setNamespace($namespace);
break;

case 'ferretdb':
$client = new Client(
$name,
'ferret',
27017,
'',
'',
false
);

$database = new Database(new Ferret($client), $cache);
$database->setDefaultDatabase($name);
$database->setNamespace($namespace);
break;

case 'mariadb':
$dbHost = 'mariadb';
$dbPort = '3306';
Expand Down
6 changes: 6 additions & 0 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,12 @@
"check": "./vendor/bin/phpstan analyse --level 7 src tests --memory-limit 512M",
"coverage": "./vendor/bin/coverage-check ./tmp/clover.xml 90"
},
"repositories": [
{
"type": "git",
"url": "https://github.com/utopia-php/mongo.git"
}
],
"require": {
"ext-pdo": "*",
"ext-mbstring": "*",
Expand Down
Loading
Loading