def setUp(self):
        plugins_dir = os.getenv("PLUGINS_DIR", "/etc/snap/plugins")
        snap_dir = os.getenv("SNAP_DIR", "/usr/local/bin")

        snapd_url = "http://snap.ci.snap-telemetry.io/snap/master/latest/snapd"
        snapctl_url = "http://snap.ci.snap-telemetry.io/snap/master/latest/snapctl"
        meminfo_url = "http://snap.ci.snap-telemetry.io/plugins/snap-plugin-collector-meminfo/latest_build/linux/x86_64/snap-plugin-collector-meminfo"
        mockfile_url = "http://snap.ci.snap-telemetry.io/snap/master/latest/snap-plugin-publisher-mock-file"

        # set and download required binaries (snapd, snapctl, plugins)
        self.binaries = bins.Binaries()
        self.binaries.snapd = bins.Snapd(snapd_url, snap_dir)
        self.binaries.snapctl = bins.Snapctl(snapctl_url, snap_dir)
        self.binaries.collector = bins.Plugin(meminfo_url, plugins_dir, "collector", 3)
        self.binaries.publisher = bins.Plugin(mockfile_url, plugins_dir, "publisher", -1)

        utils.download_binaries(self.binaries)

        self.task_file = "{}/examples/tasks/task-mem.json".format(os.getenv("PROJECT_DIR", "snap-plugin-collector-meminfo"))

        log.info("starting snapd")
        self.binaries.snapd.start()
        if not self.binaries.snapd.isAlive():
            self.fail("snapd thread died")

        log.debug("Waiting for snapd to finish starting")
        if not self.binaries.snapd.wait():
            log.error("snapd errors: {}".format(self.binaries.snapd.errors))
            self.binaries.snapd.kill()
            self.fail("snapd not ready, timeout!")
    def setUp(self):
        plugins_dir = "/etc/snap/plugins"
        snap_dir = "/usr/local/bin"

        snapd_url = "http://snap.ci.snap-telemetry.io/snap/master/latest/snapd"
        snapctl_url = "http://snap.ci.snap-telemetry.io/snap/master/latest/snapctl"
        psutil_url = "http://snap.ci.snap-telemetry.io/plugin/build/latest/snap-plugin-collector-psutil"
        passthru_url = "http://snap.ci.snap-telemetry.io/snap/master/latest/snap-plugin-processor-passthru"
        mockfile_url = "http://snap.ci.snap-telemetry.io/snap/master/latest/snap-plugin-publisher-mock-file"

        # set and download required binaries (snapd, snapctl, plugins)
        self.binaries = bins.Binaries()
        self.binaries.snapd = bins.Snapd(snapd_url, snap_dir)
        self.binaries.snapctl = bins.Snapctl(snapctl_url, snap_dir)
        self.binaries.collector = bins.Plugin(psutil_url, plugins_dir,
                                              "collector", 6)
        self.binaries.processor = bins.Plugin(passthru_url, plugins_dir,
                                              "processor", -1)
        self.binaries.publisher = bins.Plugin(mockfile_url, plugins_dir,
                                              "publisher", -1)

        utils.download_binaries(self.binaries)

        self.task_file = "/snap-plugin-collector-psutil/examples/tasks/task-psutil.json"

        log.info("starting snapd")
        self.binaries.snapd.start()
        if not self.binaries.snapd.isAlive():
            self.fail("snapd thread died")

        log.debug("Waiting for snapd to finish starting")
        if not self.binaries.snapd.wait():
            log.error("snapd errors: {}".format(self.binaries.snapd.errors))
            self.binaries.snapd.kill()
            self.fail("snapd not ready, timeout!")
    def setUp(self):
        plugins_dir = "/etc/snap/plugins"
        snap_dir = "/usr/local/bin"

        snapd_url = "http://snap.ci.snap-telemetry.io/snap/master/latest/snapd"
        snapctl_url = "http://snap.ci.snap-telemetry.io/snap/master/latest/snapctl"
        psutil_url = "http://snap.ci.snap-telemetry.io/plugin/build/latest/snap-plugin-collector-psutil"
        passthru_url = "http://snap.ci.snap-telemetry.io/snap/master/latest/snap-plugin-processor-passthru"
        mockfile_url = "http://snap.ci.snap-telemetry.io/snap/master/latest/snap-plugin-publisher-mock-file"

        # set and download required binaries (snapd, snapctl, plugins)
        self.binaries = bins.Binaries()
        self.binaries.snapd = bins.Snapd(snapd_url, snap_dir)
        self.binaries.snapctl = bins.Snapctl(snapctl_url, snap_dir)
        self.binaries.collector = bins.Plugin(psutil_url, plugins_dir, "collector", 6)
        self.binaries.processor = bins.Plugin(passthru_url, plugins_dir, "processor", -1)
        self.binaries.publisher = bins.Plugin(mockfile_url, plugins_dir, "publisher", -1)

        utils.download_binaries(self.binaries)

        self.task_file = "/snap-plugin-collector-psutil/examples/tasks/task-psutil.json"

        log.info("starting snapd")
        self.binaries.snapd.start()
        if not self.binaries.snapd.isAlive():
            self.fail("snapd thread died")

        log.debug("Waiting for snapd to finish starting")
        if not self.binaries.snapd.wait():
            log.error("snapd errors: {}".format(self.binaries.snapd.errors))
            self.binaries.snapd.kill()
            self.fail("snapd not ready, timeout!")