Skip to content
Snippets Groups Projects
Commit c411e2f2 authored by Youri van Koppen's avatar Youri van Koppen
Browse files

Added test coverage for no concurrent imports when lock timeout exceeds.

parent d5531169
No related branches found
No related tags found
No related merge requests found
......@@ -141,6 +141,71 @@ class CronTest extends FeedsBrowserTestBase {
$this->assertNodeCount(9);
}
/**
* Tests that no concurrent imports can happen if lock timeout exceeds.
*/
public function testNoConcurrentImportsUponLockTimeout() {
// Install module that alters how many items can be processed per cron run.
$this->container->get('module_installer')->install([
'feeds_test_multiple_cron_runs',
]);
$this->rebuildContainer();
// Set the limit of processable items to 4, so three cron runs are needed
// to complete the import.
$this->container->get('config.factory')
->getEditable('feeds_test_multiple_cron_runs.settings')
->set('import_queue_time', 4)
->save();
// Set lock timeout to just two seconds.
$this->container->get('config.factory')
->getEditable('feeds.settings')
->set('lock_timeout', 2)
->save();
// Create a feed type. Do not set a column as unique.
// Set periodic import to run as often as possible.
$feed_type = $this->createFeedTypeForCsv([
'guid' => 'GUID',
'title' => 'Title',
], [
'mappings' => [
[
'target' => 'feeds_item',
'map' => ['guid' => 'guid'],
],
[
'target' => 'title',
'map' => ['value' => 'title'],
],
],
]);
$feed_type->setImportPeriod(FeedTypeInterface::SCHEDULE_CONTINUOUSLY);
$feed_type->save();
// Select a file that contains 9 items.
$feed = $this->createFeed($feed_type->id(), [
'source' => $this->resourcesPath() . '/csv/nodes.csv',
]);
// Run cron. Four nodes should be imported.
$this->cronRun();
$this->assertNodeCount(4);
// Run cron again. Another four nodes should be imported.
$this->cronRun();
$this->assertNodeCount(8);
// Finally, the last cron run should import the last node.
$this->cronRun();
$this->assertNodeCount(9);
// @todo assert that the import has only run once.
// Assert that the queue is empty.
$this->assertQueueItemCount(0, 'feeds_feed_refresh:' . $feed_type->id());
}
/**
* Tests that a cron run does not fail after deleting a feed type.
*
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment