IF YOU WOULD LIKE TO GET AN ACCOUNT, please write an email to s dot adaszewski at gmail dot com. User accounts are meant only to report issues and/or generate pull requests. This is a purpose-specific Git hosting for ADARED projects. Thank you for your understanding!
Quellcode durchsuchen

Improve test_build_image and add options to copy step as a by-product.

master
Stanislaw Adaszewski vor 4 Jahren
Ursprung
Commit
665070088b
3 geänderte Dateien mit 21 neuen und 3 gelöschten Zeilen
  1. +2
    -0
      focker/jail.py
  2. +6
    -1
      focker/steps.py
  3. +13
    -2
      tests/test_compose.py

+ 2
- 0
focker/jail.py Datei anzeigen

@@ -160,6 +160,8 @@ def jail_run(path, command, mounts=[]):
print('Running:', ' '.join(command))
try:
do_mounts(path, mounts)
os.makedirs(os.path.join(path, 'etc'), exist_ok=True)
os.makedirs(os.path.join(path, 'dev'), exist_ok=True)
shutil.copyfile('/etc/resolv.conf', os.path.join(path, 'etc/resolv.conf'))
res = subprocess.run(command)
finally:


+ 6
- 1
focker/steps.py Datei anzeigen

@@ -67,10 +67,15 @@ class CopyStep(object):
lst = [ self.spec ] \
if not isinstance(self.spec[0], list) \
else self.spec
for (source, target) in lst:
for entry in lst:
(source, target) = entry[:2]
options = entry[2] if len(entry) > 2 else {}
target = target.strip('/')
os.makedirs(os.path.split(os.path.join(path, target))[0], exist_ok=True)
shutil.copyfile(os.path.join(kwargs['args'].focker_dir, source),
os.path.join(path, target))
if 'chmod' in options:
os.chmod(os.path.join(path, target), options['chmod'])
def create_step(spec):


+ 13
- 2
tests/test_compose.py Datei anzeigen

@@ -134,13 +134,22 @@ def test_build_volumes():
def test_build_images():
# focker_unlock()
subprocess.check_output(['focker', 'image', 'remove', '--force', 'test-focker-bootstrap'])
subprocess.check_output(['focker', 'bootstrap', '--dry-run', '--tags', 'test-focker-bootstrap'])
subprocess.check_output(['focker', 'image', 'remove', '--force', 'test-build-images'])
with TemporaryDirectory() as d:
with open(os.path.join(d, 'Fockerfile'), 'w') as f:
yaml.dump({
'base': 'freebsd-latest',
'base': 'test-focker-bootstrap',
'steps': [
{ 'copy': [
[ '/bin/sh', '/bin/sh', { 'chmod': 0o777 } ],
[ '/lib/libedit.so.7', '/lib/libedit.so.7' ],
[ '/lib/libncursesw.so.8', '/lib/libncursesw.so.8' ],
[ '/lib/libc.so.7', '/lib/libc.so.7' ],
[ '/usr/bin/touch', '/usr/bin/touch', { 'chmod': 0o777 } ],
[ '/libexec/ld-elf.so.1', '/libexec/ld-elf.so.1', { 'chmod': 0o555 } ]
] },
{ 'run': 'touch /test-build-images' }
]
}, f)
@@ -153,3 +162,5 @@ def test_build_images():
name, _ = zfs_find('test-build-images', focker_type='image')
assert os.path.exists(os.path.join(zfs_mountpoint(name), 'test-build-images'))
subprocess.check_output(['focker', 'image', 'remove', '--force', 'test-build-images'])
subprocess.check_output(['focker', 'image', 'prune'])
subprocess.check_output(['focker', 'image', 'remove', '--force', 'test-focker-bootstrap'])

Laden…
Abbrechen
Speichern