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!
Преглед изворни кода

Change bootstrap switch name --dry-run to --empty.

master
Stanislaw Adaszewski пре 4 година
родитељ
комит
404ffc9b62
6 измењених фајлова са 36 додато и 16 уклоњено
  1. +1
    -1
      focker/bootstrap.py
  2. +1
    -1
      focker/focker.py
  3. +22
    -2
      tests/test_bootstrap.py
  4. +2
    -2
      tests/test_compose.py
  5. +2
    -2
      tests/test_focker.py
  6. +8
    -8
      tests/test_image.py

+ 1
- 1
focker/bootstrap.py Прегледај датотеку

@@ -15,7 +15,7 @@ def command_bootstrap(args):
name = find_prefix(poolname + '/focker/images/', sha256)
subprocess.check_output(['zfs', 'create', '-o', 'focker:sha256=' + sha256, name])
zfs_tag(name, tags)
if not args.dry_run:
if not args.empty:
res = subprocess.run(['bsdinstall', 'jail', zfs_mountpoint(name)])
if res.returncode != 0:
zfs_run(['zfs', 'destroy', '-r', '-f', name])


+ 1
- 1
focker/focker.py Прегледај датотеку

@@ -79,7 +79,7 @@ def create_parser():
parser = ListForwarder([subparsers_top.add_parser(cmd) for cmd in ['bootstrap', 'boot', 'bs']])
parser.set_defaults(func=command_bootstrap)
parser.add_argument('--tags', '-t', type=str, nargs='+', default=None)
parser.add_argument('--dry-run', '-d', action='store_true')
parser.add_argument('--empty', '-e', action='store_true')
# image
subparsers = ListForwarder([ subparsers_top.add_parser(cmd).add_subparsers(dest='L2_command') \


+ 22
- 2
tests/test_bootstrap.py Прегледај датотеку

@@ -2,11 +2,31 @@ import subprocess
from focker.zfs import *
import re
import os
from focker.bootstrap import command_bootstrap
from focker.misc import focker_unlock
def test_bootstrap():
def test_bootstrap_01():
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', 'bootstrap', '--empty', '--tags', 'test-focker-bootstrap'])
name, sha256 = zfs_find('test-focker-bootstrap', focker_type='image')
basename = os.path.basename(name)
assert 7 <= len(basename) <= 64
assert re.search('[a-f]', basename[:7])
assert len(sha256) == 64
assert basename == sha256[:len(basename)]
assert zfs_exists_snapshot_sha256(sha256)
assert zfs_parse_output(['zfs', 'get', '-H', 'rdonly', name])[0][2] == 'on'
subprocess.check_output(['zfs', 'destroy', '-r', '-f', name])
def test_bootstrap_02():
subprocess.check_output(['focker', 'image', 'remove', '--force', 'test-focker-bootstrap'])
args = lambda: 0
args.empty = True
args.tags = ['test-focker-bootstrap']
command_bootstrap(args)
focker_unlock()
name, sha256 = zfs_find('test-focker-bootstrap', focker_type='image')
basename = os.path.basename(name)
assert 7 <= len(basename) <= 64


+ 2
- 2
tests/test_compose.py Прегледај датотеку

@@ -142,7 +142,7 @@ def test_build_volumes():
def test_build_images():
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', 'bootstrap', '--empty', '--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:
@@ -216,7 +216,7 @@ def test_build_jails():
subprocess.check_output(['focker', 'jail', 'remove', '--force', 'test-build-jails-A'])
subprocess.check_output(['focker', 'jail', 'remove', '--force', 'test-build-jails-B'])
subprocess.check_output(['focker', 'image', 'remove', '--force', '-R', 'test-focker-bootstrap'])
subprocess.check_output(['focker', 'bootstrap', '--dry-run', '-t', 'test-focker-bootstrap'])
subprocess.check_output(['focker', 'bootstrap', '--empty', '-t', 'test-focker-bootstrap'])
spec = {
'test-build-jails-A': {
'image': 'test-focker-bootstrap',


+ 2
- 2
tests/test_focker.py Прегледај датотеку

@@ -8,10 +8,10 @@ import pytest
def test_parser_bootstrap():
parser = create_parser()
args = parser.parse_args(['bootstrap', '--dry-run', '--tags', 'a', 'b', 'c'])
args = parser.parse_args(['bootstrap', '--empty', '--tags', 'a', 'b', 'c'])
assert args.func == command_bootstrap
assert args.tags == ['a', 'b', 'c']
assert args.dry_run
assert args.empty
def test_parser_image():


+ 8
- 8
tests/test_image.py Прегледај датотеку

@@ -47,7 +47,7 @@ def test_validate_spec_04():
def test_build_squeeze(monkeypatch):
focker_unlock()
subprocess.check_output(['focker', 'image', 'remove', '--force', '-R', 'test-build-squeeze-base'])
subprocess.check_output(['focker', 'bootstrap', '--dry-run', '-t', 'test-build-squeeze-base'])
subprocess.check_output(['focker', 'bootstrap', '--empty', '-t', 'test-build-squeeze-base'])
spec = dict(base='test-build-squeeze-base', steps=[
dict(copy=['/etc/localtime', '/etc/localtime']),
dict(copy=['/etc/hosts', '/etc/hosts'])
@@ -73,7 +73,7 @@ def test_build_squeeze(monkeypatch):
def test_build(monkeypatch):
focker_unlock()
subprocess.check_output(['focker', 'image', 'remove', '--force', '-R', 'test-build-squeeze-base'])
subprocess.check_output(['focker', 'bootstrap', '--dry-run', '-t', 'test-build-squeeze-base'])
subprocess.check_output(['focker', 'bootstrap', '--empty', '-t', 'test-build-squeeze-base'])
spec = dict(base='test-build-squeeze-base', steps=[
dict(copy=['/etc/localtime', '/etc/localtime']),
dict(copy=['/etc/hosts', '/etc/hosts'])
@@ -105,7 +105,7 @@ def test_build(monkeypatch):
def test_command_image_build():
focker_unlock()
subprocess.check_output(['focker', 'image', 'remove', '--force', '-R', 'test-command-image-build-base'])
subprocess.check_output(['focker', 'bootstrap', '--dry-run', '-t', 'test-command-image-build-base'])
subprocess.check_output(['focker', 'bootstrap', '--empty', '-t', 'test-command-image-build-base'])
with TemporaryDirectory() as d:
args = lambda: 0
@@ -132,7 +132,7 @@ def test_command_image_build():
def test_command_image_tag():
focker_unlock()
subprocess.check_output(['focker', 'image', 'remove', '--force', '-R', 'test-command-image-tag'])
subprocess.check_output(['focker', 'bootstrap', '--dry-run', '-t', 'test-command-image-tag'])
subprocess.check_output(['focker', 'bootstrap', '--empty', '-t', 'test-command-image-tag'])
name_1, sha256_1 = zfs_find('test-command-image-tag', focker_type='image')
args = lambda: 0
args.reference = sha256_1
@@ -153,7 +153,7 @@ def test_command_image_tag():
def test_command_image_untag():
focker_unlock()
subprocess.check_output(['focker', 'image', 'remove', '--force', '-R', 'test-command-image-untag'])
subprocess.check_output(['focker', 'bootstrap', '--dry-run', '-t', 'test-command-image-untag', 'test-command-image-untag-1', 'test-command-image-untag-2'])
subprocess.check_output(['focker', 'bootstrap', '--empty', '-t', 'test-command-image-untag', 'test-command-image-untag-1', 'test-command-image-untag-2'])
name, sha256 = zfs_find('test-command-image-untag', focker_type='image')
args = lambda: 0
args.tags = ['test-command-image-untag-1', 'test-command-image-untag-2']
@@ -171,7 +171,7 @@ def test_command_image_untag():
def test_command_image_list(monkeypatch):
focker_unlock()
subprocess.check_output(['focker', 'image', 'remove', '--force', '-R', 'test-command-image-list'])
subprocess.check_output(['focker', 'bootstrap', '--dry-run', '-t', 'test-command-image-list', 'test-command-image-list-1', 'test-command-image-list-2'])
subprocess.check_output(['focker', 'bootstrap', '--empty', '-t', 'test-command-image-list', 'test-command-image-list-1', 'test-command-image-list-2'])
name, sha256 = zfs_find('test-command-image-list', focker_type='image')
args = lambda: 0
args.tagged_only = True
@@ -199,7 +199,7 @@ def test_command_image_list(monkeypatch):
def test_command_image_prune():
focker_unlock()
subprocess.check_output(['focker', 'image', 'remove', '--force', '-R', 'test-command-image-prune'])
subprocess.check_output(['focker', 'bootstrap', '--dry-run', '-t', 'test-command-image-prune'])
subprocess.check_output(['focker', 'bootstrap', '--empty', '-t', 'test-command-image-prune'])
name, sha256 = zfs_find('test-command-image-prune', focker_type='image')
mountpoint = zfs_mountpoint(name)
subprocess.check_output(['focker', 'image', 'untag', 'test-command-image-prune'])
@@ -215,7 +215,7 @@ def test_command_image_prune():
def test_command_image_remove():
focker_unlock()
subprocess.check_output(['focker', 'image', 'remove', '--force', '-R', 'test-command-image-remove'])
subprocess.check_output(['focker', 'bootstrap', '--dry-run', '-t', 'test-command-image-remove'])
subprocess.check_output(['focker', 'bootstrap', '--empty', '-t', 'test-command-image-remove'])
name, sha256 = zfs_find('test-command-image-remove', focker_type='image')
mountpoint = zfs_mountpoint(name)
args = lambda: 0


Loading…
Откажи
Сачувај