test: remove redundant tests and Vagrant integration

The tests from the integration_tests directory, were superseded
by the new stage tests.

The Vagrant integration seems not to have been working since
ea68bb0c26, as a test-setup.py was
dropped there, which it relies on. Remove it for now. If we want
that back, we should consider that in a separate PR.

Signed-off-by: Tom Gundersen <teg@jklm.no>
This commit is contained in:
Tom Gundersen 2019-10-12 23:45:00 +02:00 committed by Lars Karlitski
parent 21df63ba31
commit d15bbaa05d
12 changed files with 0 additions and 341 deletions

View file

@ -26,15 +26,6 @@ jobs:
- name: f30-boot
before_install: sudo apt-get install -y systemd-container yum qemu-kvm
script: sudo env "PATH=$PATH" "OSBUILD_TEST_BUILD_PIPELINE=samples/build-from-yum.json" python3 -m unittest -v test.test_boot
- name: timezone
before_install: sudo apt-get install -y systemd-container yum tar
script: sudo env "PATH=$PATH" python3 -m test --case timezone --build-pipeline samples/build-from-yum.json
- name: firewall
before_install: sudo apt-get install -y systemd-container yum tar
script: sudo env "PATH=$PATH" python3 -m test --case firewall --build-pipeline samples/build-from-yum.json
- name: locale
before_install: sudo apt-get install -y systemd-container yum tar
script: sudo env "PATH=$PATH" python3 -m test --case locale --build-pipeline samples/build-from-yum.json
- name: assemblers
before_install: sudo apt-get install -y systemd-container yum tar qemu-utils
script: sudo env "PATH=$PATH" "OSBUILD_TEST_BUILD_PIPELINE=samples/build-from-yum.json" python3 -m unittest -v test.test_assemblers

View file

@ -1,11 +0,0 @@
up:
vagrant up
destroy:
vagrant destroy -f
install-deps:
vagrant provision
run-tests-remotely:
vagrant ssh -c 'pushd /vagrant; sudo python3 run-tests.py'

17
test/Vagrantfile vendored
View file

@ -1,17 +0,0 @@
# -*- mode: ruby -*-
# vi: set ft=ruby :
$script = <<-SCRIPT
packages=$(find /vagrant/testing-rpms -name '*.noarch.rpm')
sudo dnf remove -y $(basename -a ${packages[@]} | sed 's/-[0-9].*.rpm$//') || true
sudo dnf install qemu-system-x86 /vagrant/testing-rpms/*.noarch.rpm -y
SCRIPT
Vagrant.configure("2") do |config|
config.vm.box = "fedora/30-cloud-base"
config.vm.box_version = "30.20190425.0"
config.vm.provider "libvirt" do |v|
v.memory = 4096
end
config.vm.provision "shell", inline: $script
end

View file

@ -1,86 +0,0 @@
import argparse
import logging
import subprocess
import os
from test.integration_tests.test_case import IntegrationTestCase, IntegrationTestType
from test.integration_tests.config import *
logging.basicConfig(level=logging.getLevelName(os.environ.get("TESTS_LOGLEVEL", "INFO")))
def test_is_system_running(result):
assert result.strip() == "running"
def test_timezone(extract_dir):
link = os.readlink(f"{extract_dir}/etc/localtime")
assert "Europe/Prague" in link
def test_firewall(extract_dir):
with open(f"{extract_dir}/etc/firewalld/zones/public.xml") as f:
content = f.read()
assert 'service name="http"' in content
assert 'service name="ftp"' in content
assert 'service name="telnet"' not in content
assert 'port port="53" protocol="tcp"' in content
assert 'port port="88" protocol="udp"' in content
def test_locale(extract_dir):
with open(f"{extract_dir}/etc/locale.conf") as f:
content = f.read()
assert 'LANG=nn_NO.utf8' in content
if __name__ == '__main__':
parser = argparse.ArgumentParser(description='Run integration tests')
parser.add_argument('--list', dest='list', action='store_true', help='list test cases')
parser.add_argument('--build-pipeline', dest='build_pipeline', metavar='PIPELINE',
type=os.path.abspath, help='the build pipeline to run tests in')
parser.add_argument('--case', dest='specific_case', metavar='TEST_CASE', help='run single test case')
args = parser.parse_args()
logging.info(f"Using {OBJECTS} for objects storage.")
logging.info(f"Using {OSBUILD} for building images.")
timezone = IntegrationTestCase(
name="timezone",
pipeline="timezone.json",
build_pipeline=args.build_pipeline,
output_image="timezone.tar",
test_cases=[test_timezone],
type=IntegrationTestType.EXTRACT
)
firewall = IntegrationTestCase(
name="firewall",
pipeline="firewall.json",
build_pipeline=args.build_pipeline,
output_image="firewall.tar",
test_cases=[test_firewall],
type=IntegrationTestType.EXTRACT
)
locale = IntegrationTestCase(
name="locale",
pipeline="locale.json",
build_pipeline=args.build_pipeline,
output_image="locale.tar",
test_cases=[test_locale],
type=IntegrationTestType.EXTRACT
)
cases = [timezone, firewall, locale]
if args.list:
print("Available test cases:")
for case in cases:
print(f" - {case.name}")
else:
if not args.specific_case:
for case in cases:
case.run()
else:
for case in cases:
if case.name == args.specific_case:
case.run()

View file

@ -1,17 +0,0 @@
from .config import *
def evaluate_test(test, arg=None, name=None):
try:
if arg:
test(arg)
else:
test()
print(f"{RESET}{BOLD}{name or test.__name__}: Success{RESET}")
except AssertionError as e:
print(f"{RESET}{BOLD}{name or test.__name__}: {RESET}{RED}Fail{RESET}")
print(e)
def rel_path(fname: str) -> str:
return os.path.join(os.path.dirname(os.path.dirname(__file__)), fname)

View file

@ -1,28 +0,0 @@
import json
import logging
import subprocess
import sys
from .config import *
def run_osbuild(pipeline: str, build_pipeline: str):
cmd = OSBUILD + ["--json", "--store", OBJECTS, pipeline]
if build_pipeline:
cmd += ["--build-pipeline", build_pipeline]
logging.info(f"Running osbuild: {cmd}")
osbuild = subprocess.run(cmd, capture_output=True)
if osbuild.returncode != 0:
logging.error(f"{RED}osbuild failed!{RESET}")
print(f"{BOLD}STDERR{RESET}")
print(osbuild.stderr.decode())
print(f"{BOLD}STDOUT{RESET}")
print(osbuild.stdout.decode())
sys.exit(1)
result = json.loads(osbuild.stdout.decode())
return result["tree_id"], result.get("output_id")
def build_testing_image(pipeline_full_path, build_pipeline_full_path):
run_osbuild(pipeline_full_path, build_pipeline_full_path)

View file

@ -1,10 +0,0 @@
import tempfile
import os
EXPECTED_TIME_TO_BOOT = 60 # seconds
RESET = "\033[0m"
BOLD = "\033[1m"
RED = "\033[31m"
OBJECTS = os.environ.get("OBJECTS", ".osbuild-test")
OSBUILD = os.environ.get("OSBUILD", "python3 -m osbuild --libdir .").split(' ')

View file

@ -1,28 +0,0 @@
import contextlib
import logging
import subprocess
from os import path
from .config import *
def run_image(file_name: str):
acceleration = ["-accel", "kvm:hvf:tcg"]
silence = ["-nographic", "-monitor", "none", "-serial", "none"]
serial = ["-chardev", "stdio,id=stdio", "-device", "virtio-serial", "-device", "virtserialport,chardev=stdio"]
cmd = ["qemu-system-x86_64", "-m", "1024", "-snapshot"] + \
acceleration + silence + serial + [file_name]
logging.info(f"Booting image: {cmd}")
return subprocess.run(cmd, capture_output=True, timeout=EXPECTED_TIME_TO_BOOT, encoding="utf-8", check=True)
@contextlib.contextmanager
def extract_image(file_name: str):
extract_dir = tempfile.mkdtemp(prefix="osbuild-")
archive = path.join(os.getcwd(), file_name)
subprocess.run(["tar", "xf", archive], cwd=extract_dir, check=True)
try:
yield extract_dir
finally:
# Clean up?
pass

View file

@ -1,40 +0,0 @@
from dataclasses import dataclass
from enum import Enum
from typing import List, Callable, Any
from . import evaluate_test, rel_path
from .build import run_osbuild
from .run import run_image, extract_image
from test.integration_tests.config import *
class IntegrationTestType(Enum):
EXTRACT=0
BOOT_WITH_QEMU=1
@dataclass
class IntegrationTestCase:
name: str
pipeline: str
build_pipeline: str
output_image: str
test_cases: List[Callable[[Any], None]]
type: IntegrationTestType
def run(self):
tree_id, output_id = run_osbuild(rel_path(f"pipelines/{self.pipeline}"), self.build_pipeline)
if self.type == IntegrationTestType.BOOT_WITH_QEMU:
self.run_and_test(output_id)
else:
self.extract_and_test(output_id)
def run_and_test(self, output_id):
r = run_image(f"{OBJECTS}/refs/{output_id}/{self.output_image}")
for test in self.test_cases:
evaluate_test(test, r.stdout)
def extract_and_test(self, output_id):
with extract_image(f"{OBJECTS}/refs/{output_id}/{self.output_image}") as fstree:
for test in self.test_cases:
evaluate_test(lambda: test(fstree), name=test.__name__)

View file

@ -1,33 +0,0 @@
{
"stages": [
{
"name": "org.osbuild.dnf",
"options": {
"releasever": "30",
"basearch": "x86_64",
"repos": [
{
"metalink": "https://mirrors.fedoraproject.org/metalink?repo=fedora-$releasever&arch=$basearch",
"checksum": "sha256:9f596e18f585bee30ac41c11fb11a83ed6b11d5b341c1cb56ca4015d7717cb97",
"gpgkey": "-----BEGIN PGP PUBLIC KEY BLOCK-----\n\nmQINBFturGcBEACv0xBo91V2n0uEC2vh69ywCiSyvUgN/AQH8EZpCVtM7NyjKgKm\n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MHVFXakOH8QtMCUglbwfTfIpO5YRq5imxlWbqsYWVQy1WGJFyW6hWC0+RcJ\nOx5zGtOfi4/dN+xJ+ibnbyvy/il7Qm+vyFhCYqIPyS5m2UVJUuao3eApE38k78/o\n8aQOTnFQZ+U1Sw+6woFTxjqRQBXlQm2+7Bt3bqGATg4sXXWPbmwdL87Ic+mxn/ml\nSMfQux/5k6iAu1kQhwkO2YJn9eII6HIPkW+2m5N1JsUyJQe4cbtZE5Yh3TRA0dm7\n+zoBRfCXkOW4krchbgww/ptVmzMMP7GINJdROrJnsGl5FVeid9qHzV7aZycWSma7\nCxBYB1J8HCbty5NjtD6XMYRrMLxXugvX6Q4NPPH+2NKjzX4SIDejS6JjgrP3KA3O\npMuo7ZHMfveBngv8yP+ZD/1sS6l+dfExvdaJdOdgFCnp4p3gPbw5+Lv70HrMjA==\n=BfZ/\n-----END PGP PUBLIC KEY BLOCK-----\n"
}
],
"packages": ["@Core", "firewalld"]
}
},
{
"name": "org.osbuild.firewall",
"options": {
"ports": ["53:tcp", "88:udp"],
"enabled_services": ["http", "ftp"],
"disabled_services": ["telnet"]
}
}
],
"assembler": {
"name": "org.osbuild.tar",
"options": {
"filename": "firewall.tar"
}
}
}

View file

@ -1,31 +0,0 @@
{
"stages": [
{
"name": "org.osbuild.dnf",
"options": {
"releasever": "30",
"basearch": "x86_64",
"repos": [
{
"metalink": "https://mirrors.fedoraproject.org/metalink?repo=fedora-$releasever&arch=$basearch",
"checksum": "sha256:9f596e18f585bee30ac41c11fb11a83ed6b11d5b341c1cb56ca4015d7717cb97",
"gpgkey": "-----BEGIN PGP PUBLIC KEY BLOCK-----\n\nmQINBFturGcBEACv0xBo91V2n0uEC2vh69ywCiSyvUgN/AQH8EZpCVtM7NyjKgKm\nbbY4G3R0M3ir1xXmvUDvK0493/qOiFrjkplvzXFTGpPTi0ypqGgxc5d0ohRA1M75\nL+0AIlXoOgHQ358/c4uO8X0JAA1NYxCkAW1KSJgFJ3RjukrfqSHWthS1d4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/o\n8aQOTnFQZ+U1Sw+6woFTxjqRQBXlQm2+7Bt3bqGATg4sXXWPbmwdL87Ic+mxn/ml\nSMfQux/5k6iAu1kQhwkO2YJn9eII6HIPkW+2m5N1JsUyJQe4cbtZE5Yh3TRA0dm7\n+zoBRfCXkOW4krchbgww/ptVmzMMP7GINJdROrJnsGl5FVeid9qHzV7aZycWSma7\nCxBYB1J8HCbty5NjtD6XMYRrMLxXugvX6Q4NPPH+2NKjzX4SIDejS6JjgrP3KA3O\npMuo7ZHMfveBngv8yP+ZD/1sS6l+dfExvdaJdOdgFCnp4p3gPbw5+Lv70HrMjA==\n=BfZ/\n-----END PGP PUBLIC KEY BLOCK-----\n"
}
],
"packages": ["@Core"]
}
},
{
"name": "org.osbuild.locale",
"options": {
"language": "nn_NO.utf8"
}
}
],
"assembler": {
"name": "org.osbuild.tar",
"options": {
"filename": "locale.tar"
}
}
}

View file

@ -1,31 +0,0 @@
{
"stages": [
{
"name": "org.osbuild.dnf",
"options": {
"releasever": "30",
"basearch": "x86_64",
"repos": [
{
"metalink": "https://mirrors.fedoraproject.org/metalink?repo=fedora-$releasever&arch=$basearch",
"checksum": "sha256:9f596e18f585bee30ac41c11fb11a83ed6b11d5b341c1cb56ca4015d7717cb97",
"gpgkey": "-----BEGIN PGP PUBLIC KEY BLOCK-----\n\nmQINBFturGcBEACv0xBo91V2n0uEC2vh69ywCiSyvUgN/AQH8EZpCVtM7NyjKgKm\nbbY4G3R0M3ir1xXmvUDvK0493/qOiFrjkplvzXFTGpPTi0ypqGgxc5d0ohRA1M75\nL+0AIlXoOgHQ358/c4uO8X0JAA1NYxCkAW1KSJgFJ3RjukrfqSHWthS1d4o8fhHy\nKJKEnirE5hHqB50dafXrBfgZdaOs3C6ppRIePFe2o4vUEapMTCHFw0woQR8Ah4/R\nn7Z9G9Ln+0Cinmy0nbIDiZJ+pgLAXCOWBfDUzcOjDGKvcpoZharA07c0q1/5ojzO\n4F0Fh4g/BUmtrASwHfcIbjHyCSr1j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INJdROrJnsGl5FVeid9qHzV7aZycWSma7\nCxBYB1J8HCbty5NjtD6XMYRrMLxXugvX6Q4NPPH+2NKjzX4SIDejS6JjgrP3KA3O\npMuo7ZHMfveBngv8yP+ZD/1sS6l+dfExvdaJdOdgFCnp4p3gPbw5+Lv70HrMjA==\n=BfZ/\n-----END PGP PUBLIC KEY BLOCK-----\n"
}
],
"packages": ["@Core"]
}
},
{
"name": "org.osbuild.timezone",
"options": {
"zone": "Europe/Prague"
}
}
],
"assembler": {
"name": "org.osbuild.tar",
"options": {
"filename": "timezone.tar"
}
}
}