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

Feature/TR-5854/Detect delivery concurrency #2420

Conversation

jsconan
Copy link
Contributor

@jsconan jsconan commented Nov 24, 2023

Related to: https://oat-sa.atlassian.net/browse/TR-5854

Requires:

Summary

Add a mechanism for detecting concurrent delivery sessions.

Details

Install the preventConcurrency plugin.

When the test runner initializes, a sequence number is stored in the browser's storage. Each time the duration is updated, the sequence number is read from the storage and compared with the value created at the beginning. If a discrepancy is discovered this means another test runner started meanwhile and updated the storage. A dialog message is presented to the user and the test runner is stopped.

How to test

The feature flag FEATURE_FLAG_PAUSE_CONCURRENT_SESSIONS needs to be set.

php index.php 'oat\tao\scripts\tools\FeatureFlag\FeatureFlagTool' -s FEATURE_FLAG_PAUSE_CONCURRENT_SESSIONS -v true
  • checkout the branch feature/TR-5858/detect-delivery-concurrency
  • make sure the frontend is up to date: cd taoQtiTest/views && npm ci
  • run taoUpdate
  • launch a delivery
  • duplicate the tab or launch another delivery
  • the first tab should show a message and stop the test

Comment on lines 26 to 27
$registry = PluginRegistry::getRegistry();
if (!$registry->isRegistered('taoQtiTest/runner/plugins/controls/session/preventConcurrency')) {
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
$registry = PluginRegistry::getRegistry();
if (!$registry->isRegistered('taoQtiTest/runner/plugins/controls/session/preventConcurrency')) {
$registry = PluginRegistry::getRegistry();
if (!$registry->isRegistered('taoQtiTest/runner/plugins/controls/session/preventConcurrency')) {

Comment on lines 43 to 44
$registry = PluginRegistry::getRegistry();
if ($registry->isRegistered('taoQtiTest/runner/plugins/controls/session/preventConcurrency')) {
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
$registry = PluginRegistry::getRegistry();
if ($registry->isRegistered('taoQtiTest/runner/plugins/controls/session/preventConcurrency')) {
$registry = PluginRegistry::getRegistry();
if ($registry->isRegistered('taoQtiTest/runner/plugins/controls/session/preventConcurrency')) {

public function up(Schema $schema): void
{
$registry = PluginRegistry::getRegistry();
if (!$registry->isRegistered('taoQtiTest/runner/plugins/controls/session/preventConcurrency')) {
Copy link
Contributor

Choose a reason for hiding this comment

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

We can store 'taoQtiTest/runner/plugins/controls/session/preventConcurrency' in a separate class variable to avoid duplications 🙂
But not critical

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Done!

'bundle' => 'taoQtiTest/loader/testPlugins.min',
'description' => 'Detect concurrent deliveries launched from the same user session',
'category' => 'controls',
'active' => true,
Copy link
Contributor

@gabrielfs7 gabrielfs7 Nov 27, 2023

Choose a reason for hiding this comment

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

We discussed this will not be activated by default, right? Maybe we should set it to false?

*Even if it will be handled by feature flag later, maybe to be on the safe side, still worth to make it disabled by default to be consistent. Wdyt?

cc: @jsconan

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Actually, the feature is conditioned by a feature flag. We can install the plugin and have it always active, then set the feature flag FEATURE_FLAG_PAUSE_CONCURRENT_SESSIONS when needed. This ways it will work all together with the backend feature.

@@ -9,6 +9,6 @@
"license": "GPL-2.0",
"dependencies": {
"@oat-sa/tao-test-runner": "^1.0.0",
"@oat-sa/tao-test-runner-qti": "^4.0.0"
"@oat-sa/tao-test-runner-qti": "https://github.com/oat-sa/tao-test-runner-qti-fe#feature/TR-5858/detect-delivery-concurrency"
Copy link
Contributor

Choose a reason for hiding this comment

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

  • Please do not forget to update with proper version before merge

public function up(Schema $schema): void
{
$registry = PluginRegistry::getRegistry();
if (!$registry->isRegistered('taoQtiTest/runner/plugins/controls/session/preventConcurrency')) {
Copy link
Contributor

@gabrielfs7 gabrielfs7 Nov 27, 2023

Choose a reason for hiding this comment

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

Would not be easier to keep the plugin declaration configs on RegisterTestRunnerPlugins and only get it here? Example (does not need to be the same)

$registry->register(TestPlugin::fromArray(RegisterTestRunnerPlugins::getPlugin('preventConcurrency')));

Copy link
Contributor Author

Choose a reason for hiding this comment

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

We could, but we would need to refactor the class RegisterTestRunnerPlugins.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Suggestion applied

Copy link
Contributor

Choose a reason for hiding this comment

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

Thanks!

Copy link
Contributor

@gabrielfs7 gabrielfs7 left a comment

Choose a reason for hiding this comment

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

Thanks @jsconan !

  • New code is covered by tests (if applicable)
  • Tests are running successfully (old and new ones) on my local machine (if applicable)
  • New code is respecting code style rules
  • New code is respecting best practices
  • New code is not subject to concurrency issues (if applicable)
  • Feature is working correctly on my local machine (if applicable)
  • Acceptance criteria are respected
  • Pull request title and description are meaningful

Co-authored-by: Gabriel Felipe Soares <gabrielfs7@gmail.com>
Signed-off-by: Jean-Sébastien CONAN <jsconan@gmail.com>
Co-authored-by: Héctor Arroyo <hector.arroyo@taotesting.com>
Signed-off-by: Jean-Sébastien CONAN <jsconan@gmail.com>
@jsconan jsconan merged commit 721c2f4 into feat/RFE-748-integration-branch Nov 27, 2023
1 check failed
@jsconan jsconan deleted the feature/TR-5858/detect-delivery-concurrency branch November 27, 2023 12:14
@jsconan jsconan changed the title Feature/TR-5858/Detect delivery concurrency Feature/TR-5854/Detect delivery concurrency Nov 27, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants