Skip to content

Integration Tests: Check that the most recent app version is loaded - #27989

Closed
VicDeo wants to merge 3 commits into
masterfrom
fix-e2018
Closed

VicDeo wants to merge 3 commits into
masterfrom
fix-e2018

Conversation

@VicDeo

@VicDeo VicDeo commented May 23, 2017 •

Copy link
Copy Markdown
Contributor

Attention:

The fix was merged into 10.0.2 #28002
This PR contains integration test to detect future regressions

Description

App version was loaded incorrectly

Motivation and Context

When there are several app directories the app is always loaded from the very first due to the bug in logic

How Has This Been Tested?

config.php

  "apps_paths" =>  [
    0 => 
   [
      'path' => '/1001/apps/',
      'url' => '/apps',
      'writable' => false,
   ],
    1 => 
   [
      'path' => '/1001/apps2/',
      'url' => '/apps2',
      'writable' => true,
    ],
  ],
  1. Put the same app into /1001/apps/ and /1001/apps2/
  2. Increase version of the app in /1001/apps2/

Expected: the change is detected and the app is updated
Actual: it's not

  1. Apply patch - everything works as expected
  2. Keep the patch and increase version of the app in /1001/apps/ just to be sure it doesn't break anything

Expected & Actual: the change is detected and the app is updated

Types of changes

  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to change)

Checklist:

  • My code follows the code style of this project.
  • My change requires a change to the documentation.
  • I have updated the documentation accordingly.
  • I have read the CONTRIBUTING document.
  • I have added tests to cover my changes.
  • All new and existing tests passed.

P.S. Writing a test for this piece of code is quite painful

@VicDeo VicDeo added this to the 10.0.2 milestone May 23, 2017
$versionToLoad = [];
foreach ($possibleApps as $possibleApp) {
$version = self::getAppVersionByPath($possibleApp['path']);
$version = self::getAppVersionByPath($possibleApp['path'] . '/' . $appId);

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

ooooooohhhhhhhh, really

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

ok got it... so $possibleApps only contains all app roots... what an unfortunately choice of variable name

$version = self::getAppVersionByPath($possibleApp['path'] . '/' . $appId);
if (empty($versionToLoad) || version_compare($version, $versionToLoad['version'], '>')) {
$versionToLoad = [
'dir' => $possibleApp,

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

shouldn't $appId be appended here too ? or is "dir" supposed to be the app root only ?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

@PVince81 no, it's appended in another place

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

public static function getAppPath($appId) {

@PVince81

Copy link
Copy Markdown
Contributor

@tboerger can you test this patch on docker ?

@PVince81

Copy link
Copy Markdown
Contributor

@VicDeo still "2 - developing" ? What's missing ?

@PVince81

Copy link
Copy Markdown
Contributor

unit tests maybe ?

@VicDeo

VicDeo commented May 24, 2017

Copy link
Copy Markdown
Contributor Author

@PVince81 exactly. not sure, how to test ;(

@PVince81

Copy link
Copy Markdown
Contributor

@VicDeo figure it out... maybe integration tests would be easier to setup than unit tests against static classes ? Worst case just write down a test plan that covers all possible cases touched by this scenario

@VicDeo
VicDeo force-pushed the fix-e2018 branch 2 times, most recently from fd1853e to cc7ba3c Compare May 24, 2017 13:27
@VicDeo

VicDeo commented May 24, 2017

Copy link
Copy Markdown
Contributor Author

@PVince81 writing behat tests from scratch isn't my best skill
still fighting :/

@PVince81

Copy link
Copy Markdown
Contributor

Jenkins crapped on the first commit too, too bad. I could have pushed it directly.

I'll make a separate PR with only the fix so we can merge it quickly.

@PVince81

Copy link
Copy Markdown
Contributor

@SergioBertolinSG please assist @VicDeo for the integration tests.

@PVince81

Copy link
Copy Markdown
Contributor

separate PR for the fix without the integration test: #28002


Background:
Given apps are in two directories "apps" and "apps2"
@eee

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Why this tag? the name is not enough descriptive.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

@SergioBertolinSG just for development, in order not to run all tests

@PVince81 PVince81 modified the milestones: 10.0.2, 10.0.3 May 26, 2017
@VicDeo

VicDeo commented May 29, 2017 •

Copy link
Copy Markdown
Contributor Author

In other words.
having multiple app directories is an OC feature.

  1. Let's assume that we have two app directories: apps and apps2
    apps isn't allowed to change by the webserver user
    and apps2 is allowed to change by the webserver user

to notify oC about that we add the following lines into the config.php:

  "apps_paths" =>  [
    0 => 
   [
      'path' => '/path/to/owncloud/apps/',
      'url' => '/apps',
      'writable' => false,
   ],
    1 => 
   [
      'path' => '/path/to/owncloud/apps2/',
      'url' => '/apps2',
      'writable' => true,
    ],
  ],

where /path/to/owncloud is a full path to oC instance
as documented in config.sample.php : https://github.com/owncloud/core/blob/master/config/config.sample.php#L724

  1. Now we copy the same app code both into /path/to/owncloud/apps/ and /path/to/owncloud/apps2/
    and enable it
    e.g. via CLI command: php occ app:enable appid

  2. Now we increase version for this app by changing /path/to/owncloud/apps2/appid/appinfo/info.xml

  3. We expect that oC will detect that our app needs an upgrade. But it is not.

if there are several instances of the same app oC always loads this app from the very first app directory instead of searching the most recent version across all copies of the app.
That''s the bug.

@felixboehm

Copy link
Copy Markdown
Contributor

Next steps? @VicDeo your description above is correct, could you fix the behavior meanwhile, or still some open parts?

@VicDeo

VicDeo commented Jun 9, 2017

Copy link
Copy Markdown
Contributor Author

@felixboehm fixed in 10.0.2. Next step is backport

@VicDeo

VicDeo commented Jun 9, 2017

Copy link
Copy Markdown
Contributor Author

@felixboehm ah. The fix was merged separately, this PR contains integration test only.

@VicDeo VicDeo changed the title Always load most recent app from multiple dirs Integration Tests: Check that the most recent app version is loaded Jun 9, 2017
@VicDeo

VicDeo commented Jun 12, 2017

Copy link
Copy Markdown
Contributor Author

Ready to review

1 => ['pipe', 'w'],
2 => ['pipe', 'w'],
];
$process = proc_open('php console.php ' . $args, $descriptor, $pipes, \OC::$SERVERROOT);

@PVince81 PVince81 Jun 19, 2017 •

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

use CommandLine trait functions instead ? See runOcc()

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

@PVince81 ...and get an error from Behat that you are not allowed to declare these methods twice . It's not possible ;)

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

I had the same issue as in https://stackoverflow.com/questions/39607911/behat-error-step-is-already-defined and I can't remove my context from behat.xml as advised by this link.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Did you try using the method without importing the trait ? It might work through behat magic as all contexts are loaded...

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

@PVince81

When App "testapp" is loaded                                  # AppManagementContext::loadApp()
      Fatal error: Call to undefined method AppManagementContext::runOcc() (Behat\Testwork\Call\Exception\FatalThrowableError)

@PVince81

Copy link
Copy Markdown
Contributor

Test\InstallerTest.testUpdateApp failed

@VicDeo

VicDeo commented Jun 30, 2017 •

Copy link
Copy Markdown
Contributor Author

@PVince81 It seems that I bloated the environment with early implementations.
Tests are passed locally.
Cherry-picked into #28271
Closing

@lock

lock Bot commented Aug 3, 2019

Copy link
Copy Markdown

This thread has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs.

@lock lock Bot locked as resolved and limited conversation to collaborators Aug 3, 2019
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants