Skip to content
Closed
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Add integration test for getting folder size when APCu is enabled
Signed-off-by: Daniel Calviño Sánchez <[email protected]>
  • Loading branch information
danxuliu committed Aug 8, 2022
commit 3f2300fde9f4fcc7f0cdc9fcf0cc02cfe6e22135
10 changes: 8 additions & 2 deletions build/integration/features/bootstrap/CommandLine.php
Original file line number Diff line number Diff line change
Expand Up @@ -42,21 +42,27 @@ trait CommandLine {
* Invokes an OCC command
*
* @param []string $args OCC command, the part behind "occ". For example: "files:transfer-ownership"
* @param []string $phpArgs optional PHP command arguments. For example: "--define apc.enable_cli=1"
* @return int exit code
*/
public function runOcc($args = []) {
public function runOcc($args = [], $phpArgs = []) {
$args = array_map(function ($arg) {
return escapeshellarg($arg);
}, $args);
$args[] = '--no-ansi';
$args = implode(' ', $args);

$phpArgs = array_map(function ($phpArg) {
return escapeshellarg($phpArg);
}, $phpArgs);
$phpArgs = implode(' ', $phpArgs);

$descriptor = [
0 => ['pipe', 'r'],
1 => ['pipe', 'w'],
2 => ['pipe', 'w'],
];
$process = proc_open('php console.php ' . $args, $descriptor, $pipes, $this->ocPath);
$process = proc_open('php ' . $phpArgs . ' console.php ' . $args, $descriptor, $pipes, $this->ocPath);
$this->lastStdOut = stream_get_contents($pipes[1]);
$this->lastStdErr = stream_get_contents($pipes[2]);
$this->lastCode = proc_close($process);
Expand Down
15 changes: 15 additions & 0 deletions build/integration/features/bootstrap/Files.php
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,21 @@ trait Files {

// BasicStructure trait is expected to be used in the class that uses this
// trait.
// CommandLineContext is expected to be loaded in the Behat suite where this
// trait is used.

/**
* @AfterScenario
*/
public function disableMemcacheLocal(AfterScenarioScope $scope) {
$environment = $scope->getEnvironment();
$commandLineContext = $environment->getContext('CommandLineContext');

// If APCu was set APC needs to be enabled for the CLI when running OCC;
// otherwise OC\Memcache\APCu is not available and OCC command fails,
// even if it is just trying to disable the memcache.
$commandLineContext->runOcc(['config:system:delete', 'memcache.local'], ['--define', 'apc.enable_cli=1']);
}

/**
* @When logged in user gets storage stats of folder :folder
Expand Down
11 changes: 11 additions & 0 deletions build/integration/features/files.feature
Original file line number Diff line number Diff line change
Expand Up @@ -91,3 +91,14 @@ Feature: files
| used | 0 |

# End of counterpart scenarios

Scenario: Retrieving storage stats after a file was uploaded when using APCu
Given using old dav path
And invoking occ with "config:system:set memcache.local --value \OC\Memcache\APCu --type string"
And As an "admin"
And user "user0" exists
And user "user0" adds a file of 108 bytes to "/test.txt"
When Logging in using web as "user0"
And logged in user gets storage stats of folder "/"
Then the storage stats match with
| used | 447 |