def test_revert_03(self): write_probe('''#!/usr/bin/env bash echo hello world from probe! | tee bar mv eggs eggs2 ls -l foo/spam rm foo/spam''') pipeline = self.pipeline_loader.load_pipeline('run-probe-1') namespace = pmatic.Namespace() event_log = pmatic.EventLog(self.test_dir) event_log.read_log() self.assertFalse(event_log.event_data) pprint.pprint(vars(event_log)) scan1 = pmatic.scan_directory(self.test_dir) pprint.pprint(scan1) pipeline.run(namespace) scan2 = pmatic.scan_directory(self.test_dir) self.assertNotEqual(scan1, scan2) event_log = pmatic.EventLog(self.test_dir) event_log.read_log() self.assertTrue(event_log.event_data) pprint.pprint(vars(event_log)) os.chdir('..') event_log.revert_one() self.assertFalse(event_log.event_data) scan3 = pmatic.scan_directory(self.test_dir) self.assertEqual(scan1, scan3) pprint.pprint(scan3)
def test_revert_04(self): write_file('foo-input', 'hello\nworld') namespace = pmatic.Namespace() self.pipeline_loader.load_pipeline('bar-1').run(namespace) scan1 = pmatic.scan_directory(self.test_dir) pprint.pprint(scan1) self.pipeline_loader.load_pipeline('foo-1').run(namespace) os.chdir('..') scan2 = pmatic.scan_directory(self.test_dir) pprint.pprint(scan2) self.assertNotEqual(scan1, scan2) pmaticrevert.main((self.test_dir,)) scan3 = pmatic.scan_directory(self.test_dir) self.assertEqual(scan1, scan3) pprint.pprint(scan3)
def test_revert_04(self): write_file('foo-input', 'hello\nworld') namespace = pmatic.Namespace() self.pipeline_loader.load_pipeline('bar-1').run(namespace) scan1 = pmatic.scan_directory(self.test_dir) pprint.pprint(scan1) self.pipeline_loader.load_pipeline('foo-1').run(namespace) os.chdir('..') scan2 = pmatic.scan_directory(self.test_dir) pprint.pprint(scan2) self.assertNotEqual(scan1, scan2) pmaticrevert.main((self.test_dir, )) scan3 = pmatic.scan_directory(self.test_dir) self.assertEqual(scan1, scan3) pprint.pprint(scan3)
def test_revert_01(self): write_probe('''#!/usr/bin/env bash echo hello world from probe! | tee bar mv eggs eggs2 ls -l foo/spam rm foo/spam''') pipeline = self.pipeline_loader.load_pipeline('run-probe-1') namespace = pmatic.Namespace() scan1 = pmatic.scan_directory(self.test_dir) pipeline.run(namespace) scan2 = pmatic.scan_directory(self.test_dir) self.assertNotEqual(scan1, scan2) pprint.pprint(scan1) pprint.pprint(scan2) os.chdir('..') pmatic.restore_snapshot(scan1, self.test_dir) scan3 = pmatic.scan_directory(self.test_dir) pprint.pprint(scan3) self.maxDiff = None self.assertEqual(scan1, scan3)
def test_basic(self): write_probe('''#!/usr/bin/env bash echo hello world from probe!!! echo example error >&2''') pipeline = self.pipeline_loader.load_pipeline('run-probe-1') namespace = pmatic.Namespace() pipeline.run(namespace) scan = pmatic.scan_directory(self.test_dir) # For reproducibility, strip inode out of scan. result = {k: (f, m & 0777, int(s), l) for k, (f, m, s, i, l) in scan.iteritems()}
def test_basic(self): write_probe('''#!/usr/bin/env bash echo hello world from probe!!! echo example error >&2''') pipeline = self.pipeline_loader.load_pipeline('run-probe-1') namespace = pmatic.Namespace() pipeline.run(namespace) scan = pmatic.scan_directory(self.test_dir) # For reproducibility, strip inode out of scan. result = { k: (f, m & 0777, int(s), l) for k, (f, m, s, i, l) in scan.iteritems() }
def test_revert_02(self): write_probe( """#!/usr/bin/env bash echo hello world from probe! | tee bar mv eggs eggs2 mkdir -p new-foo echo new spam in new-foo| tee new-foo/spam ln -s new-foo/spam eggs """ ) pipeline = self.pipeline_loader.load_pipeline("run-probe-1") namespace = pmatic.Namespace() scan1 = pmatic.scan_directory(".") pipeline.run(namespace) scan2 = pmatic.scan_directory(".") self.assertNotEqual(scan1, scan2) pprint.pprint(scan1) pprint.pprint(scan2) pmatic.restore_snapshot(scan1, ".") scan3 = pmatic.scan_directory(".") pprint.pprint(scan3) self.maxDiff = None self.assertEqual(scan1, scan3)
def test_basic(self): write_probe( """#!/usr/bin/env bash echo hello world from probe!!! echo example error >&2""" ) pipeline = self.pipeline_loader.load_pipeline("run-probe-1") namespace = pmatic.Namespace() pipeline.run(namespace) scan = pmatic.scan_directory(".") # For reproducibility, strip inode out of scan. result = {k: (f, m, s, l) for k, (f, m, s, i, l) in scan.iteritems()} self.maxDiff = None self.assertEqual( result, # TODO: minor portability concerns... { "eggs": ("LNK", 0777, 8L, "foo/spam"), "foo": ("DIR", 0755, 0L, None), "foo/spam": ("REG", 0444, 15L, None), "probe": ("REG", 0544, 74L, None), "probe.err": ("REG", 0644, 14L, None), "probe.out": ("REG", 0644, 45L, None), }, )