Browse Source

Merge "Generate symlinks during tests"

changes/02/553702/1
Zuul 3 years ago
committed by Gerrit Code Review
parent
commit
cb4b10f517
  1. 21
      tests/base.py
  2. 1
      tests/fixtures/config/remote-action-modules/git/org_project/playbooks/roles/assemble-test/files/dir-symlink/one
  3. 1
      tests/fixtures/config/remote-action-modules/git/org_project/playbooks/roles/assemble-test/files/dir-symlink/one
  4. 1
      tests/fixtures/config/remote-action-modules/git/org_project/playbooks/roles/assemble-test/files/symlink
  5. 1
      tests/fixtures/config/remote-action-modules/git/org_project/playbooks/roles/assemble-test/files/symlink
  6. 1
      tests/fixtures/config/remote-action-modules/git/org_project/playbooks/roles/copy-test/files/dir-symlink/symlink
  7. 1
      tests/fixtures/config/remote-action-modules/git/org_project/playbooks/roles/copy-test/files/dir-symlink/symlink
  8. 1
      tests/fixtures/config/remote-action-modules/git/org_project/playbooks/roles/copy-test/files/symlink
  9. 1
      tests/fixtures/config/remote-action-modules/git/org_project/playbooks/roles/copy-test/files/symlink
  10. 1
      tests/fixtures/config/remote-action-modules/git/org_project/playbooks/roles/includevars-test/vars/symlink.yaml
  11. 1
      tests/fixtures/config/remote-action-modules/git/org_project/playbooks/roles/includevars-test/vars/symlink.yaml
  12. 1
      tests/fixtures/config/remote-action-modules/git/org_project/playbooks/roles/includevarsdir-test/vars/dir-double-symlink/double-symlink-sidekick
  13. 1
      tests/fixtures/config/remote-action-modules/git/org_project/playbooks/roles/includevarsdir-test/vars/dir-double-symlink/double-symlink-sidekick
  14. 1
      tests/fixtures/config/remote-action-modules/git/org_project/playbooks/roles/includevarsdir-test/vars/dir-symlink/two.yaml
  15. 1
      tests/fixtures/config/remote-action-modules/git/org_project/playbooks/roles/includevarsdir-test/vars/dir-symlink/two.yaml
  16. 1
      tests/fixtures/config/remote-action-modules/git/org_project/playbooks/roles/includevarsdir-test/vars/dir/sub/recursive-link
  17. 1
      tests/fixtures/config/remote-action-modules/git/org_project/playbooks/roles/includevarsdir-test/vars/dir/sub/recursive-link
  18. 1
      tests/fixtures/config/remote-action-modules/git/org_project/playbooks/roles/includevarsdir-test/vars/double-symlink-sidekick/vars.yaml
  19. 1
      tests/fixtures/config/remote-action-modules/git/org_project/playbooks/roles/includevarsdir-test/vars/double-symlink-sidekick/vars.yaml
  20. 1
      tests/fixtures/config/remote-action-modules/git/org_project/playbooks/roles/includevarsdir-test/vars/symlink
  21. 1
      tests/fixtures/config/remote-action-modules/git/org_project/playbooks/roles/includevarsdir-test/vars/symlink
  22. 1
      tests/fixtures/config/remote-action-modules/git/org_project/playbooks/roles/patch-test/files/symlink
  23. 1
      tests/fixtures/config/remote-action-modules/git/org_project/playbooks/roles/patch-test/files/symlink
  24. 1
      tests/fixtures/config/remote-action-modules/git/org_project/playbooks/roles/script-test/files/symlink
  25. 1
      tests/fixtures/config/remote-action-modules/git/org_project/playbooks/roles/script-test/files/symlink
  26. 1
      tests/fixtures/config/remote-action-modules/git/org_project/playbooks/roles/template-test/templates/symlink
  27. 1
      tests/fixtures/config/remote-action-modules/git/org_project/playbooks/roles/template-test/templates/symlink
  28. 1
      tests/fixtures/config/remote-action-modules/git/org_project/playbooks/roles/unarchive-test/files/symlink
  29. 1
      tests/fixtures/config/remote-action-modules/git/org_project/playbooks/roles/unarchive-test/files/symlink

21
tests/base.py

@ -2407,24 +2407,19 @@ class ZuulTestCase(BaseTestCase):
files = {}
for (dirpath, dirnames, filenames) in os.walk(source_path):
# Note: In case a symlink points to an already existing directory
# os.walk includes that in the dirnames list. In order to properly
# copy these links, just add them to the filenames list.
for dirname in dirnames:
test_tree_filepath = os.path.join(dirpath, dirname)
if os.path.islink(test_tree_filepath):
filenames.append(dirname)
for filename in filenames:
test_tree_filepath = os.path.join(dirpath, filename)
common_path = os.path.commonprefix([test_tree_filepath,
source_path])
relative_filepath = test_tree_filepath[len(common_path) + 1:]
if os.path.islink(test_tree_filepath):
content = SymLink(os.readlink(test_tree_filepath))
else:
with open(test_tree_filepath, 'rb') as f:
content = f.read()
with open(test_tree_filepath, 'rb') as f:
content = f.read()
# dynamically create symlinks if the content is of the form
# symlink: <target>
match = re.match(b'symlink: ([^\s]+)', content)
if match:
content = SymLink(match.group(1))
files[relative_filepath] = content
self.addCommitToRepo(project, 'add content from fixture',
files, branch='master', tag='init')

1
tests/fixtures/config/remote-action-modules/git/org_project/playbooks/roles/assemble-test/files/dir-symlink/one

@ -1 +0,0 @@
/opt/file

1
tests/fixtures/config/remote-action-modules/git/org_project/playbooks/roles/assemble-test/files/dir-symlink/one

@ -0,0 +1 @@
symlink: /opt/file

1
tests/fixtures/config/remote-action-modules/git/org_project/playbooks/roles/assemble-test/files/symlink

@ -1 +0,0 @@
/opt/assemble

1
tests/fixtures/config/remote-action-modules/git/org_project/playbooks/roles/assemble-test/files/symlink

@ -0,0 +1 @@
symlink: /opt/assemble

1
tests/fixtures/config/remote-action-modules/git/org_project/playbooks/roles/copy-test/files/dir-symlink/symlink

@ -1 +0,0 @@
/opt/dir

1
tests/fixtures/config/remote-action-modules/git/org_project/playbooks/roles/copy-test/files/dir-symlink/symlink

@ -0,0 +1 @@
symlink: /opt/dir

1
tests/fixtures/config/remote-action-modules/git/org_project/playbooks/roles/copy-test/files/symlink

@ -1 +0,0 @@
/opt/file

1
tests/fixtures/config/remote-action-modules/git/org_project/playbooks/roles/copy-test/files/symlink

@ -0,0 +1 @@
symlink: /opt/file

1
tests/fixtures/config/remote-action-modules/git/org_project/playbooks/roles/includevars-test/vars/symlink.yaml

@ -1 +0,0 @@
/opt/vars.yaml

1
tests/fixtures/config/remote-action-modules/git/org_project/playbooks/roles/includevars-test/vars/symlink.yaml

@ -0,0 +1 @@
symlink: /opt/vars.yaml

1
tests/fixtures/config/remote-action-modules/git/org_project/playbooks/roles/includevarsdir-test/vars/dir-double-symlink/double-symlink-sidekick

@ -1 +0,0 @@
../double-symlink-sidekick

1
tests/fixtures/config/remote-action-modules/git/org_project/playbooks/roles/includevarsdir-test/vars/dir-double-symlink/double-symlink-sidekick

@ -0,0 +1 @@
symlink: ../double-symlink-sidekick

1
tests/fixtures/config/remote-action-modules/git/org_project/playbooks/roles/includevarsdir-test/vars/dir-symlink/two.yaml

@ -1 +0,0 @@
/opt/vars.yaml

1
tests/fixtures/config/remote-action-modules/git/org_project/playbooks/roles/includevarsdir-test/vars/dir-symlink/two.yaml

@ -0,0 +1 @@
symlink: /opt/vars.yaml

1
tests/fixtures/config/remote-action-modules/git/org_project/playbooks/roles/includevarsdir-test/vars/dir/sub/recursive-link

@ -1 +0,0 @@
..

1
tests/fixtures/config/remote-action-modules/git/org_project/playbooks/roles/includevarsdir-test/vars/dir/sub/recursive-link

@ -0,0 +1 @@
symlink: ..

1
tests/fixtures/config/remote-action-modules/git/org_project/playbooks/roles/includevarsdir-test/vars/double-symlink-sidekick/vars.yaml

@ -1 +0,0 @@
/opt/vars.yaml

1
tests/fixtures/config/remote-action-modules/git/org_project/playbooks/roles/includevarsdir-test/vars/double-symlink-sidekick/vars.yaml

@ -0,0 +1 @@
symlink: /opt/vars.yaml

1
tests/fixtures/config/remote-action-modules/git/org_project/playbooks/roles/includevarsdir-test/vars/symlink

@ -1 +0,0 @@
/opt/vars

1
tests/fixtures/config/remote-action-modules/git/org_project/playbooks/roles/includevarsdir-test/vars/symlink

@ -0,0 +1 @@
symlink: /opt/vars

1
tests/fixtures/config/remote-action-modules/git/org_project/playbooks/roles/patch-test/files/symlink

@ -1 +0,0 @@
/opt/patch

1
tests/fixtures/config/remote-action-modules/git/org_project/playbooks/roles/patch-test/files/symlink

@ -0,0 +1 @@
symlink: /opt/patch

1
tests/fixtures/config/remote-action-modules/git/org_project/playbooks/roles/script-test/files/symlink

@ -1 +0,0 @@
/opt/script.sh

1
tests/fixtures/config/remote-action-modules/git/org_project/playbooks/roles/script-test/files/symlink

@ -0,0 +1 @@
symlink: /opt/script.sh

1
tests/fixtures/config/remote-action-modules/git/org_project/playbooks/roles/template-test/templates/symlink

@ -1 +0,0 @@
/opt/file

1
tests/fixtures/config/remote-action-modules/git/org_project/playbooks/roles/template-test/templates/symlink

@ -0,0 +1 @@
symlink: /opt/file

1
tests/fixtures/config/remote-action-modules/git/org_project/playbooks/roles/unarchive-test/files/symlink

@ -1 +0,0 @@
/opt/archive.tar

1
tests/fixtures/config/remote-action-modules/git/org_project/playbooks/roles/unarchive-test/files/symlink

@ -0,0 +1 @@
symlink: /opt/archive.tar
Loading…
Cancel
Save