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
8 changes: 8 additions & 0 deletions .github/workflows/integration-test-cron.yml
Original file line number Diff line number Diff line change
Expand Up @@ -217,6 +217,7 @@ jobs:
cp example.env .env
echo "NEXTCLOUD_URL=http://localhost:8080" >> .env
python3 -u ./main_em.py > em_backend_logs 2>&1 &
echo $! > ../em_pid.txt # Save the embedding server process ID (PID)
python3 -u ./main.py > backend_logs 2>&1 &
echo $! > ../pid.txt # Save the process ID (PID)
sleep 60 # Wait for the backend to get ready
Expand Down Expand Up @@ -359,6 +360,13 @@ jobs:
exit 1
fi

# Check if the embedding server is still alive
em_alive=$(ps -p $(cat em_pid.txt) -o cmd= | grep -c "main_em.py" || echo "0")
if [ "$em_alive" -eq 0 ]; then
echo "Error: Context Chat embedding server process is not running. Exiting."
exit 1
fi

sleep 10
done

Expand Down
8 changes: 8 additions & 0 deletions .github/workflows/integration-test-file-listener.yml
Original file line number Diff line number Diff line change
Expand Up @@ -205,6 +205,7 @@ jobs:
cp example.env .env
echo "NEXTCLOUD_URL=http://localhost:8080" >> .env
python3 -u ./main_em.py > em_backend_logs 2>&1 &
echo $! > ../em_pid.txt # Save the embedding server process ID (PID)
python3 -u ./main.py > backend_logs 2>&1 &
echo $! > ../pid.txt # Save the process ID (PID)
sleep 60 # Wait for the backend to get ready
Expand Down Expand Up @@ -350,6 +351,13 @@ jobs:
exit 1
fi

# Check if the embedding server is still alive
em_alive=$(ps -p $(cat em_pid.txt) -o cmd= | grep -c "main_em.py" || echo "0")
if [ "$em_alive" -eq 0 ]; then
echo "Error: Context Chat embedding server process is not running. Exiting."
exit 1
fi

sleep 10
done

Expand Down
1 change: 0 additions & 1 deletion lib/Controller/QueueController.php
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,6 @@
use OCA\ContextChat\Db\QueueFile;
use OCA\ContextChat\Db\QueueMapper;
use OCA\ContextChat\Service\ProviderConfigService;
use OCA\ContextChat\Service\StorageService;
use OCA\ContextChat\Type\Source;
use OCP\AppFramework\Http;
use OCP\AppFramework\Http\Attribute\ApiRoute;
Expand Down
30 changes: 19 additions & 11 deletions tests/integration/ContentManagerTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -24,11 +24,11 @@
use OCP\AppFramework\Services\IAppConfig;
use OCP\BackgroundJob\IJobList;
use OCP\EventDispatcher\IEventDispatcher;
use OCP\IServerContainer;
use OCP\Server;
use PHPUnit\Framework\Attributes\Group;
use PHPUnit\Framework\MockObject\MockObject;
use PHPUnit\Framework\TestCase;
use Psr\Container\ContainerInterface;
use Psr\Log\LoggerInterface;
use Symfony\Component\EventDispatcher\EventDispatcher as SymfonyDispatcher;

Expand All @@ -51,7 +51,7 @@ class ContentManagerTest extends TestCase {
private IJobList $jobList;
private IEventDispatcher $eventDispatcher;
private SymfonyDispatcher $dispatcher;
private IServerContainer $serverContainer;
private ContainerInterface $serverContainer;

// private bool $initCalled = false;
private static string $providerClass = 'OCA\ContextChat\Tests\ContentProvider';
Expand All @@ -67,7 +67,7 @@ public function setUp(): void {

// new dispatcher for each test
$this->dispatcher = new SymfonyDispatcher();
$this->serverContainer = Server::get(IServerContainer::class);
$this->serverContainer = Server::get(ContainerInterface::class);
$this->eventDispatcher = new \OC\EventDispatcher\EventDispatcher(
$this->dispatcher,
$this->serverContainer,
Expand All @@ -90,14 +90,24 @@ public function setUp(): void {
// $this->overwriteService(ProviderConfigService::class, $this->providerConfig);

// using this app's app id to pass the check that the app is enabled for the user
$providerObj = new ContentProvider(Application::APP_ID, 'test-provider', function () {
// $this->initCalled = true;
});
$providerObj = new ContentProvider(Application::APP_ID, 'test-provider');
$providerClass = get_class($providerObj);

\OC::$server->registerService($providerClass, function () use ($providerObj) {
return $providerObj;
});
// Register in the app container instead of the server container because since NC 36
// registering `OCA\...` services directly in the core container is no longer supported,
// see https://github.com/nextcloud/server/pull/64172
// A `\OC::$server->registerService()` here would never be seen by the `Server::get($providerClass)`
// lookup in registerContentProvider().
//
// That lookup then falls back to reflection, which cannot build this class because its constructor
// takes scalars the container has no way to resolve.
//
// On PHP >= 8.4 the failure stays hidden (lazy ghosts defer the constructor,
// and the resolved value is discarded anyway).
\OC::$server->getAppContainerForService($providerClass)
->registerService($providerClass, function () use ($providerObj) {
return $providerObj;
});

$this->contentManager = new ContentManager(
$this->jobList,
Expand Down Expand Up @@ -242,7 +252,6 @@ class ContentProvider implements IContentProvider {
public function __construct(
private string $appId,
private string $providerId,
private $callback,
) {
}

Expand All @@ -259,6 +268,5 @@ public function getItemUrl(string $id): string {
}

public function triggerInitialImport(): void {
($this->callback)();
}
}
Loading