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

[full-ci] Allow disabling the files_external app #39856

Merged
merged 10 commits into from
Mar 15, 2022

Conversation

jvillafanez
Copy link
Member

Description

Allow disabling the files_external app

Related Issue

https://github.com/owncloud/enterprise/issues/5036#issuecomment-1061743656

Motivation and Context

How Has This Been Tested?

  • test environment:
  • test case 1:
  • test case 2:
  • ...

Screenshots (if appropriate):

Types of changes

  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Database schema changes (next release will require increase of minor version instead of patch)
  • Breaking change (fix or feature that would cause existing functionality to change)
  • Technical debt
  • Tests only (no source changes)

Checklist:

  • Code changes
  • Unit tests added
  • Acceptance tests added
  • Documentation ticket raised:
  • Changelog item, see TEMPLATE

@update-docs
Copy link

update-docs bot commented Mar 8, 2022

Thanks for opening this pull request! The maintainers of this repository would appreciate it if you would create a changelog item based on your changes.

@jvillafanez jvillafanez force-pushed the allow_disable_files_external branch from f33bfbe to c62645d Compare March 8, 2022 14:29
@jvillafanez
Copy link
Member Author

It seems the problem with the CI is that the files_external app is disabled when the phpstan runs, which causes the classes from the app not to get loaded. Enabling the app before hand should solve the problem, but we want to run the tests without the files_external app being enabled.

@phil-davis not sure how we want to go through this issue:

  • Adding the failing files to the ignore list seems a bad idea.
  • Forcing the app to be always enabled would defeat the purpose of this PR because we want to run the tests without the files_external app being active.
  • Ignoring the whole files_external app might cause issues in the long run due to the lack of analysis.

I'm not sure if it's possible to use a different phpstan configuration depending on the state of the files_external app, or make it conditional somehow.

@jvillafanez
Copy link
Member Author

------ --------------------------------------------------------------------- 
  Line   lib/private/Files/External/Service/LegacyStoragesService.php         
 ------ --------------------------------------------------------------------- 
  169    Call to static method decryptPasswords() on an unknown class         
         OC_Mount_Config.                                                     
         💡 Learn more at https://phpstan.org/user-guide/discovering-symbols   
 ------ --------------------------------------------------------------------- 

 ------ --------------------------------------------------------------------- 
  Line   settings/Panels/Helper.php                                           
 ------ --------------------------------------------------------------------- 
  62     Call to static method dependencyMessage() on an unknown class        
         OC_Mount_Config.                                                     
         💡 Learn more at https://phpstan.org/user-guide/discovering-symbols   
 ------ --------------------------------------------------------------------- 

That's what I've found locally after running phpstan with files_external disabled. The second commit should fix those dependencies.

@phil-davis phil-davis force-pushed the allow_disable_files_external branch from bd70a6e to 2b99b30 Compare March 9, 2022 11:55
@ownclouders
Copy link
Contributor

💥 Acceptance tests pipeline apiAuthOcs-mariadb10.2-php7.4 failed. The build has been cancelled.

https://drone.owncloud.com/owncloud/core/34848/48/1

@phil-davis phil-davis changed the title Allow disabling the files_external app [full-ci] Allow disabling the files_external app Mar 9, 2022
@phil-davis phil-davis force-pushed the allow_disable_files_external branch from 2b99b30 to 3a73a79 Compare March 9, 2022 12:10
@phil-davis
Copy link
Contributor

I fixed the phpstan problem. See the c ommit "Enable files_external for phpstan in drone"

Now there are fails in acceptance tests, like:
https://drone.owncloud.com/owncloud/core/34848/48/13

 Scenario: using OCS with an app password of a normal user                            # /drone/src/tests/acceptance/features/apiAuthOcs/ocsGETAuth.feature:243
    Given a new browser session for "Alice" has been started                           # AuthContext::aNewBrowserSessionForHasBeenStarted()
    And the user has generated a new app password named "my-client"                    # AuthContext::aNewAppPasswordHasBeenGenerated()
    When the user requests these endpoints with "GET" using the generated app password # AuthContext::userRequestsEndpointsUsingTheGeneratedAppPassword()
      | endpoint                                                    |
      | /ocs/v1.php/apps/files_external/api/v1/mounts               |
      | /ocs/v1.php/apps/files_sharing/api/v1/remote_shares         |
      | /ocs/v1.php/apps/files_sharing/api/v1/remote_shares/pending |
      | /ocs/v1.php/apps/files_sharing/api/v1/shares                |
      | /ocs/v1.php/config                                          |
      | /ocs/v1.php/privatedata/getattribute                        |
    Then the HTTP status code of responses on all endpoints should be "200"            # FeatureContext::theHTTPStatusCodeOfResponsesOnAllEndpointsShouldBe()
    And the OCS status code of responses on all endpoints should be "100"              # FeatureContext::theOCSStatusCodeOfResponsesOnAllEndpointsShouldBe()
      Expected same but found different ocs status codes of last requested responses.Found status codes: 999,100,100,100,100,100 (Exception)

Test scenarios like this are doing "quick" tests of various endpoints, all in the same scenario, for performance reasons. We need to separate all the test steps that are testing files_external and put them in separate scenarios. Then tag those scenarios, and skip the scenarios.

@phil-davis
Copy link
Contributor

https://drone.owncloud.com/owncloud/core/34849/10/7

There were 195 errors

The unit tests will need to be looked through. If those 145 failing tests are all just tests that test something that includes files_external, then those tests will need minor adjustment so that they "skip" when files_external is not enabled.

@phil-davis
Copy link
Contributor

I added a commit that separates out and skips some acceptance tests that relate to files_external.

It will take some work to sort out all the unit and acceptance tests so that they "understand" what to do when running with files_external disabled. Do we want to continue with this?

@phil-davis
Copy link
Contributor

Acceptance tests pass - good.
Controlled skipping of PHP unit tests is needed. Do we want to do that?
(put in if files_external not enabled then $this->markTestSkipped() calls or something)

@jvillafanez
Copy link
Member Author

I'm still checking unit tests but I might need more eyes on this.

Controlled skipping of PHP unit tests is needed. Do we want to do that?

The problem is what tests we want to skip. I'm checking some sharing tests, and those shouldn't be crashing even if the files_external app is disabled. Moreover, running those tests isolated (just those tests) doesn't give any problem.

So far, it seems that at some point, the AppConfig service is replace by a mock, it isn't restored. This seems to cause a lot of errors since the share API is considered to be disabled (due to the mock object) while the tests assume the share API is enabled.
Suspects are "tests/lib/App/ManagerTest.php", "tests/lib/AppConfigTest.php" and "tests/lib/AppTest.php".

@jvillafanez
Copy link
Member Author

--- Expected
+++ Actual
@@ @@
         'canResetPassword' => true
         'resetPasswordLink' => null
         'alt_login' => Array ()
-        'rememberLoginAllowed' => false
+        'rememberLoginAllowed' => true
         'rememberLoginState' => 0
-        'strictLoginEnforced' => false
+        'strictLoginEnforced' => null
         'licenseMessage' => 'demo license valid'
     )
     'renderAs' => 'guest'

/drone/src/tests/Core/Controller/LoginControllerTest.php:262

PHP things: set the rememberLoginAllowed to true and the test passes even though the stricLoginEnforced was never set and was always null...

php > $a = ['a' => true, 'b' => false];
php > $b = ['a' => true, 'b' => null];
php > var_dump($a == $b);
bool(true)
php > $c = ['a' => false, 'b' => null];
php > var_dump($a == $c);
bool(false)

At least it seems we're getting closer. We still need to figure out a way to check whether the files_external app is enabled or not.
2e8faf4 assumes the files_external app is disabled, so the tests will fail otherwise. That's something we need to adjust.

@jvillafanez jvillafanez force-pushed the allow_disable_files_external branch from 0d153fc to 499168f Compare March 11, 2022 11:38
@jvillafanez jvillafanez force-pushed the allow_disable_files_external branch from 499168f to 7028dcc Compare March 11, 2022 13:00
@jvillafanez
Copy link
Member Author

This seems to go through now. There are a couple of things to be discussed here:

  • The way the checking of the availability of the files_external app doesn't seem good enough. However, I haven't found an easy way to check for the app without going through the appManager (which is what we're testing)
  • Having conditional expectations in some of the tests doesn't look good. I'd prefer to have 2 or more tests with clear expectations. However, for this case, it seems that for the 2 tests we'd need, we'd have to skip always one of them
  • Tagging and running different test suites, so for example, test1 would only run in the "files_external-is enabled" suite, while test2 would run in the "files_external-isn't-enabled" suite. This seems work I'm not sure we want to invest in now.

Other than that, I think the only thing left is to squash the commits a bit.

@phil-davis
Copy link
Contributor

I will add CI pipelines that enable files_external and:

  1. run the unit tests
  2. run the acceptance tests tagged local_storage or files_external-app-required

That will help ensure that future regressions in the files_external code will be caught by CI.

@jvillafanez jvillafanez marked this pull request as ready for review March 14, 2022 07:49
@jvillafanez
Copy link
Member Author

jvillafanez commented Mar 14, 2022

@phil-davis unless you have an idea for #39856 (comment) I think this is good to merge. I'm adding a changelog item now

@phil-davis
Copy link
Contributor

@phil-davis unless you have an idea for #39856 (comment) I think this is good to merge. I'm adding a changelog item now

It looks good to me. Please invite some dev(s) to review and it could be merged. I can make a separate issue to put back some "full" testing for files_external in CI.

Note: for the next core oC10 release we will need to check exactly what happens for:

  • new installs (is files_external enabled or not)
  • upgrades of existing systems (make sure that files_external does not accidentally get disabled)

@sonarqubecloud
Copy link

Kudos, SonarCloud Quality Gate passed!    Quality Gate passed

Bug A 0 Bugs
Vulnerability A 0 Vulnerabilities
Security Hotspot A 0 Security Hotspots
Code Smell A 0 Code Smells

0.0% 0.0% Coverage
0.0% 0.0% Duplication

Copy link
Contributor

@IljaN IljaN left a comment

Choose a reason for hiding this comment

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

LGTM but I guess @DeepDiver1975 should also have a look :)

@DeepDiver1975 DeepDiver1975 merged commit 116c261 into master Mar 15, 2022
@DeepDiver1975 DeepDiver1975 deleted the allow_disable_files_external branch March 15, 2022 08:38
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants