How to use the testinfra.HOSTNAME function in testinfra

To help you get started, we’ve selected a few testinfra examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github cockpit-project / cockpit / test / common / testimagetask.py View on Github external
def start_publishing(self, host, github):
        if self.pull:
            identifier = self.name + "-" + self.pull['head']['sha']
        else:
            identifier = self.name + "-" + time.strftime("%Y-%m-%d")

        requests = [ ]

        body_text = ("Image creation for %s in process on %s.\nLog: :link"
                     % (self.image, testinfra.HOSTNAME))

        # Update the body for an existing issue
        if self.issue:
            requests += [
                # Get issue
                { "method": "GET",
                  "resource": github.qualify("issues/" + str(self.issue['number'])),
                  "result": "issue"
                },
                # Update the issue
                { "method": "POST",
                    "resource": ":issue.url",
                  "data": {
                      "body": body_text,
                      "labels": [ "bot", "image/" + self.image ]
                  }
github cockpit-project / cockpit / test / common / testpulltask.py View on Github external
def start_publishing(self, host, github):
        identifier = self.name + "-" + self.revision[0:8] + "-" + self.context.replace("/", "-")
        description = "{0} [{1}]".format(testinfra.TESTING, testinfra.HOSTNAME)

        self.github_status_data = {
            "state": "pending",
            "context": self.context,
            "description": description,
            "target_url": ":link"
        }

        status = {
            "github": {
                "token": github.token,
                "requests": [
                    # Set status to pending
                    { "method": "POST",
                      "resource": github.qualify("statuses/" + self.revision),
                      "data": self.github_status_data
github cockpit-project / cockpit / test / common / testpulltask.py View on Github external
os.environ["TEST_NAME"] = self.name
        os.environ["TEST_REVISION"] = self.revision

        if prefix in [ 'selenium' ]:
            os.environ["TEST_OS"] = 'fedora-24'
        elif prefix in [ 'container' ]:
            os.environ["TEST_OS"] = 'fedora-25'
        else:
            os.environ["TEST_OS"] = value

        if opts.publish:
            self.start_publishing(opts.publish, github)
            os.environ["TEST_ATTACHMENTS"] = self.sink.attachments

        msg = "Testing {0} for {1} with {2} on {3}...\n".format(self.revision, self.name,
                                                                self.context, testinfra.HOSTNAME)
        sys.stderr.write(msg)

        ret = None
        # Figure out what to do next
        if prefix == "verify":
            cmd = [ "timeout", "120m", "./verify/run-tests", "--install", "--jobs", str(opts.jobs) ]
        elif prefix == "avocado":
            cmd = [ "timeout", "60m", "./avocado/run-tests", "--install", "--quick", "--tests" ]
        elif prefix == "koji":
            cmd = [ "timeout", "120m", "./koji/run-build" ]
        elif prefix == "selenium":
            if value not in ['firefox', 'chrome']:
                ret = "Unknown browser for selenium test"
            cmd = [ "timeout", "60m", "./avocado/run-tests", "--install", "--quick", "--selenium-tests", "--browser", value]
        elif prefix == "image" or prefix == "container":
            cmd = [ "timeout", "90m", "./containers/run-tests", "--install", "--container", value]