Support for Drupal 7 is ending on 5 January 2025—it’s time to migrate to Drupal 10! Learn about the many benefits of Drupal 10 and find migration tools in our resource center.
Within archiveDumpTest.php there is no test to verify that archive-dump works.
At Drupal Developer Days Barcelona, @jonhattan and me discussed on how to test archive-restore. @jonhattan suggested to do a diff -rq between the original codebase and the restored one to ensure that they are identical.
A patch is attached in the next comment where the resulting file structure is compared with the original one.
Comment | File | Size | Author |
---|---|---|---|
#6 | drush-test-archive-restore-1650426-5.patch | 2.99 KB | juampynr |
#5 | drush-test-archive-restore-1650426-5.patch | 0 bytes | juampynr |
#4 | drush-test-archive-restore-1650426-4.patch | 2.92 KB | juampynr |
#3 | 1650426-3-drush-test-archive-dump.patch | 951 bytes | juampynr |
#1 | drush-test-archive-restore-1650426-1.patch | 1.21 KB | juampynr |
Comments
Comment #1
juampynr CreditAttribution: juampynr commentedHere is the patch.
Comment #2
moshe weitzman CreditAttribution: moshe weitzman commentedThe diff command may not be available, especially on Windows. Maybe we should use a hash of the file listing just like the make tests do?
Comment #3
juampynr CreditAttribution: juampynr commentedHere is an alternative version of the patch, but this time using drush_dir_md5() of the original and restored codebase and then comparing the md5s. Unfortunately they do not match. Here is an output example:
Comment #4
juampynr CreditAttribution: juampynr commentedarchive-dump was not sites/example.sites.php to the archive and that is why the md5 hashes of the original and restored codebases did not match. There was also a missing exclamation mark to negate the condition that checks for the presence of sites/sites.php, which was also fixed.
The attached patch contains two commits: the first one adds the archive-restore test, while the second commit fixes the bug in the logic of archive-dump so the two files mentioned above are added to dump.tar.gz and consequently extracted afterwards, thus making md5 hashes match and the test pass.
Comment #5
juampynr CreditAttribution: juampynr commentedAfter reviewing the patch with @moshe weitzman, I realised that I was not fixing the logic of archive-dump properly and my patch at #4 was adding an empty sites/example.sites.php file.
Below is the updated code within the attached patch. The error was that the path of sites/sites.php was being given along with the $docroot, which finally evaluated as /tmp/drush-sandbox/web/web/sites/sites.php. That is the reason why sites/sites.php was never found and thus not added to the archive.
Instead I set the $docroot when the tar command is issued so now sites/example.sites.php and sites/sites.php are searched correctly, added to the archive and therefore the test passes.
Comment #6
juampynr CreditAttribution: juampynr commentedDoh! Submitted an empty patch. Here it is.
Comment #7
juampynr CreditAttribution: juampynr commentedChanging status to needs review.
Comment #8
moshe weitzman CreditAttribution: moshe weitzman commentedCommitted. Thanks.
Comment #9.0
(not verified) CreditAttribution: commentedAdded reasoning authorship.