Пример #1
0
    def _basic_directory_created(self):

        self._tst_local_host()

        (osf, outfile) = tempfile.mkstemp()
        os.close(osf)
        rc = cloudinitd.cli.boot.main(["-O", outfile, "boot",  "%s/localhost/top.conf" % (self.plan_basedir)])
        self._dump_output(outfile)
        self.assertEqual(rc, 0)

        n = "Starting up run"
        line = self._find_str(outfile, n)
        self.assertNotEqual(line, None)
        runname = line[len(n):].strip()
        print "run name is %s" % (runname)

        wd = get_remote_working_dir()
        rc = os.path.exists(wd)
        self.assertTrue(rc, "The directory %s should exist" % (wd))

        print "cleanup"
        rc = cloudinitd.cli.boot.main(["-O", outfile, "terminate",  "%s" % (runname)])
        self.assertEqual(rc, 0)

        rc = os.path.exists(wd)
        self.assertTrue(rc, "The directory %s should NOT exist" % (wd))
Пример #2
0
    def test_terminate_timeout(self):

        self._tst_local_host()

        (osf, outfile) = tempfile.mkstemp()
        os.close(osf)
        rc = cloudinitd.cli.boot.main(["-O", outfile, "boot",  "%s/localhost_to/terminate_to_top.conf" % (self.plan_basedir)])
        self._dump_output(outfile)
        self.assertEqual(rc, 0)

        n = "Starting up run"
        line = self._find_str(outfile, n)
        self.assertNotEqual(line, None)
        runname = line[len(n):].strip()
        print "run name is %s" % (runname)

        wd = get_remote_working_dir()
        rc = os.path.exists(wd)
        self.assertTrue(rc, "The directory %s should exist" % (wd))

        print "cleanup"
        start = datetime.now()
        rc = cloudinitd.cli.boot.main(["-O", outfile, "terminate",  "%s" % (runname)])
        end = datetime.now()
        self.assertNotEqual(rc, 0, "terminate now will return non 0 values")

        diff = end - start
        self.assertLess(diff.seconds, 50)