Exemplo n.º 1
0
 def new_machine(self, image=None, forward={}, **kwargs):
     import testvm
     machine_class = self.machine_class
     if image is None:
         image = self.image
     if opts.address:
         if machine_class or forward:
             raise unittest.SkipTest(
                 "Cannot run this test when specific machine address is specified"
             )
         machine = testvm.Machine(address=opts.address,
                                  image=image,
                                  verbose=opts.trace,
                                  browser=opts.browser)
         self.addCleanup(lambda: machine.disconnect())
     else:
         if not machine_class:
             machine_class = testvm.VirtMachine
         if not self.network:
             network = testvm.VirtNetwork()
             self.addCleanup(lambda: network.kill())
             self.network = network
         networking = self.network.host(restrict=True, forward=forward)
         machine = machine_class(verbose=opts.trace,
                                 networking=networking,
                                 image=image,
                                 **kwargs)
         if opts.fetch and not os.path.exists(machine.image_file):
             machine.pull(machine.image_file)
         self.addCleanup(lambda: machine.kill())
     return machine
Exemplo n.º 2
0
    def setUp(self):
        self.network = testvm.VirtNetwork(0)
        self.machine = testvm.VirtMachine(self.image,
                                          networking=self.network.host(),
                                          memory_mb=2048)

        print("Starting virtual machine '{}'".format(self.image))
        self.machine.start()
        self.machine.wait_boot()

        # run a command to force starting the SSH master
        self.machine.execute("uptime")

        self.ssh_command = [
            "ssh", "-o", "ControlPath=" + self.machine.ssh_master, "-p",
            self.machine.ssh_port,
            self.machine.ssh_user + "@" + self.machine.ssh_address
        ]

        print("Machine is up. Connect to it via:")
        print(" ".join(self.ssh_command))
        print()

        print("Waiting for lorax-composer to become ready...")
        curl_command = [
            "curl", "--max-time", "360", "--silent", "--unix-socket",
            "/run/weldr/api.socket", "http://localhost/api/status"
        ]
        r = subprocess.run(self.ssh_command + curl_command,
                           stdout=subprocess.DEVNULL)
        self.assertEqual(r.returncode, 0)
Exemplo n.º 3
0
    def setUpTestMachine(self, image=testvm.DEFAULT_IMAGE, identity_file=None):
        self.network = testvm.VirtNetwork(0)
        # default overlay directory is not big enough to hold the large composed trees; thus put overlay into /var/tmp/
        self.machine = testvm.VirtMachine(image,
                                          networking=self.network.host(),
                                          cpus=2,
                                          memory_mb=2048,
                                          overlay_dir="/var/tmp",
                                          identity_file=identity_file)

        print("Starting virtual machine '{}'".format(image))
        self.machine.start()

        # Modified wait_boot that doesn't check for /run/nologin
        self.wait_boot()

        # run a command to force starting the SSH master
        self.machine.execute("uptime")

        self.ssh_command = [
            "ssh", "-o", "ControlPath=" + self.machine.ssh_master, "-p",
            self.machine.ssh_port,
            self.machine.ssh_user + "@" + self.machine.ssh_address
        ]

        print("Machine is up. Connect to it via:")
        print(" ".join(self.ssh_command))
        print()
Exemplo n.º 4
0
    def setUpTestMachine(self, image=testvm.DEFAULT_IMAGE, identity_file=None):
        self.network = testvm.VirtNetwork(0)
        if identity_file:
            self.machine = testvm.VirtMachine(image, networking=self.network.host(), cpus=2, memory_mb=2048, identity_file=identity_file)
        else:
            self.machine = testvm.VirtMachine(image, networking=self.network.host(), cpus=2, memory_mb=2048)

        print("Starting virtual machine '{}'".format(image))
        self.machine.start()

        # Modified wait_boot that doesn't check for /run/nologin
        self.wait_boot()

        # run a command to force starting the SSH master
        self.machine.execute("uptime")

        self.ssh_command = ["ssh", "-o", "ControlPath=" + self.machine.ssh_master,
                                   "-p", self.machine.ssh_port,
                                   self.machine.ssh_user + "@" + self.machine.ssh_address]

        print("Machine is up. Connect to it via:")
        print(" ".join(self.ssh_command))
        print()