def test_pipeline(self): build = osbuild.Pipeline("org.osbuild.test") build.add_stage("org.osbuild.test", {}, {"one": 1}) pipeline = osbuild.Pipeline("org.osbuild.test", build) pipeline.add_stage("org.osbuild.test", {}, {"one": 2}) pipeline.set_assembler("org.osbuild.test") self.assertEqual(pipeline.description(), { "build": { "pipeline": { "stages": [ { "name": "org.osbuild.test", "options": {"one": 1} } ] }, "runner": "org.osbuild.test" }, "stages": [ { "name": "org.osbuild.test", "options": {"one": 2} } ], "assembler": { "name": "org.osbuild.test" } })
def test_monitor_integration(self): # Checks the monitoring API is called properly from the pipeline runner = detect_host_runner() index = osbuild.meta.Index(os.curdir) pipeline = osbuild.Pipeline("pipeline", runner=runner) noop_info = index.get_module_info("Stage", "org.osbuild.noop") pipeline.add_stage(noop_info, { "isthisthereallife": False }) pipeline.add_stage(noop_info, { "isthisjustfantasy": True }) with tempfile.TemporaryDirectory() as tmpdir: storedir = os.path.join(tmpdir, "store") tape = TapeMonitor() with ObjectStore(storedir) as store: res = pipeline.run(store, tape, libdir=os.path.abspath(os.curdir)) assert res self.assertEqual(tape.counter["begin"], 1) self.assertEqual(tape.counter["finish"], 1) self.assertEqual(tape.counter["stages"], 2) self.assertEqual(tape.counter["stages"], 2) self.assertEqual(tape.counter["result"], 2) self.assertIn(pipeline.stages[0].id, tape.stages) self.assertIn("isthisthereallife", tape.output) self.assertIn("isthisjustfantasy", tape.output)
def test_log_monitor_vfuncs(self): # Checks the basic functioning of the LogMonitor index = osbuild.meta.Index(os.curdir) runner = detect_host_runner() pipeline = osbuild.Pipeline("pipeline", runner=runner) info = index.get_module_info("Stage", "org.osbuild.noop") pipeline.add_stage(info, { "isthisthereallife": False }) with tempfile.TemporaryDirectory() as tmpdir: storedir = os.path.join(tmpdir, "store") logfile = os.path.join(tmpdir, "log.txt") with open(logfile, "w") as log, ObjectStore(storedir) as store: monitor = LogMonitor(log.fileno()) res = pipeline.run(store, monitor, libdir=os.path.abspath(os.curdir)) with open(logfile) as f: log = f.read() assert res self.assertIn(pipeline.stages[0].id, log) self.assertIn("isthisthereallife", log)
def test_monitor_integration(self): # Checks the monitoring API is called properly from the pipeline runner = detect_host_runner() pipeline = osbuild.Pipeline(runner=runner) pipeline.add_stage("org.osbuild.noop", {}, { "isthisthereallife": False }) pipeline.add_stage("org.osbuild.noop", {}, { "isthisjustfantasy": True }) pipeline.set_assembler("org.osbuild.noop") with tempfile.TemporaryDirectory() as tmpdir: storedir = os.path.join(tmpdir, "store") outputdir = os.path.join(tmpdir, "output") tape = TapeMonitor() res = pipeline.run(storedir, tape, libdir=os.path.abspath(os.curdir), output_directory=outputdir) assert res self.assertEqual(tape.counter["begin"], 1) self.assertEqual(tape.counter["finish"], 1) self.assertEqual(tape.counter["stages"], 2) self.assertEqual(tape.counter["assembler"], 1) self.assertEqual(tape.counter["stages"], 2) self.assertEqual(tape.counter["result"], 3) self.assertIn(pipeline.stages[0].id, tape.stages) self.assertIn(pipeline.assembler.id, tape.asm) self.assertIn("isthisthereallife", tape.output) self.assertIn("isthisjustfantasy", tape.output)
def test_log_monitor_vfuncs(self): # Checks the basic functioning of the LogMonitor runner = detect_host_runner() pipeline = osbuild.Pipeline(runner=runner) pipeline.add_stage("org.osbuild.noop", {}, { "isthisthereallife": False }) pipeline.set_assembler("org.osbuild.noop") with tempfile.TemporaryDirectory() as tmpdir: storedir = os.path.join(tmpdir, "store") outputdir = os.path.join(tmpdir, "output") logfile = os.path.join(tmpdir, "log.txt") with open(logfile, "w") as log: monitor = LogMonitor(log.fileno()) res = pipeline.run(storedir, monitor, libdir=os.path.abspath(os.curdir), output_directory=outputdir) with open(logfile) as f: log = f.read() assert res self.assertIn(pipeline.stages[0].id, log) self.assertIn(pipeline.assembler.id, log) self.assertIn("isthisthereallife", log)