Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
F
feeds-3332987
Manage
Activity
Members
Labels
Plan
Custom issue tracker
Code
Merge requests
0
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Locked files
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Model registry
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Code review analytics
Insights
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Terms and privacy
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Issue forks
feeds-3332987
Commits
c411e2f2
Commit
c411e2f2
authored
2 years ago
by
Youri van Koppen
Browse files
Options
Downloads
Patches
Plain Diff
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
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
tests/src/Functional/CronTest.php
+65
-0
65 additions, 0 deletions
tests/src/Functional/CronTest.php
with
65 additions
and
0 deletions
tests/src/Functional/CronTest.php
+
65
−
0
View file @
c411e2f2
...
...
@@ -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.
*
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment