コード例 #1
0
    def add_secret(self, key, value="hello world\n", force=False):
        """
        Add new secret using the --stdin option
        """
        args = [self.test_binary, "-systemTest"]
        if os.getenv("TEST_COVERAGE") == "true":
            args += [
                "-test.coverprofile",
                os.path.join(self.working_dir, "coverage.cov"),
            ]
        args += [
            "-c",
            os.path.join(self.working_dir, "mockbeat.yml"),
            "-e",
            "-v",
            "-d",
            "*",
            "keystore",
            "add",
            key,
            "--stdin",
        ]

        if force:
            args.append("--force")

        proc = Proc(args, os.path.join(self.working_dir, "mockbeat.log"))

        os.write(proc.stdin_write, value.encode("utf8"))
        os.close(proc.stdin_write)

        return proc.start().wait()
コード例 #2
0
    def start_packetbeat(self,
                         cmd=None,
                         config="packetbeat.yml",
                         output="packetbeat.log",
                         extra_args=[],
                         debug_selectors=[]):
        """
        Starts packetbeat and returns the process handle. The
        caller is responsible for stopping / waiting for the
        Proc instance.
        """
        if cmd is None:
            cmd = self.beat_path + "/packetbeat.test"

        args = [cmd,
                "-e",
                "-c", os.path.join(self.working_dir, config),
                "-systemTest",
                "-test.coverprofile", os.path.join(self.working_dir, "coverage.cov")
                ]

        if extra_args:
            args.extend(extra_args)

        if debug_selectors:
            args.extend(["-d", ",".join(debug_selectors)])

        proc = Proc(args, os.path.join(self.working_dir, output))
        proc.start()
        return proc
コード例 #3
0
ファイル: test_prospector.py プロジェクト: raboof/connbeat
    def test_stdin_eof(self):
        """
        Test that Filebeat works when stdin is closed.
        """
        self.render_config_template(
            input_type="stdin",
            close_eof="true",
        )

        args = [self.beat_path,
                "-systemTest",
                "-test.coverprofile",
                os.path.join(self.working_dir, "coverage.cov"),
                "-c", os.path.join(self.working_dir, "filebeat.yml"),
                "-e", "-v", "-d", "*",
                ]
        proc = Proc(args, os.path.join(self.working_dir, "filebeat.log"))
        os.write(proc.stdin_write, "Hello World\n")

        proc.start()
        self.wait_until(lambda: self.output_has(lines=1))

        # Continue writing after end was reached
        os.write(proc.stdin_write, "Hello World2\n")
        os.close(proc.stdin_write)

        self.wait_until(lambda: self.output_has(lines=2))

        proc.proc.terminate()
        proc.proc.wait()

        objs = self.read_output()
        assert objs[0]["message"] == "Hello World"
        assert objs[1]["message"] == "Hello World2"
コード例 #4
0
ファイル: packetbeat.py プロジェクト: Ingensi/beats
    def start_packetbeat(self,
                         cmd="../../packetbeat.test",
                         config="packetbeat.yml",
                         output="packetbeat.log",
                         extra_args=[],
                         debug_selectors=[]):
        """
        Starts packetbeat and returns the process handle. The
        caller is responsible for stopping / waiting for the
        Proc instance.
        """
        args = [cmd,
                "-e",
                "-c", os.path.join(self.working_dir, config),
                "-systemTest",
                "-test.coverprofile", os.path.join(self.working_dir, "coverage.cov")
                ]

        if extra_args:
            args.extend(extra_args)

        if debug_selectors:
            args.extend(["-d", ",".join(debug_selectors)])

        proc = Proc(args, os.path.join(self.working_dir, output))
        proc.start()
        return proc
コード例 #5
0
    def test_stdin_eof(self):
        """
        Test that Filebeat works when stdin is closed.
        """
        self.render_config_template(
            type="stdin",
            close_eof="true",
        )

        args = [self.test_binary, "-systemTest"]
        if os.getenv("TEST_COVERAGE") == "true":
            args += ["-test.coverprofile",
                     os.path.join(self.working_dir, "coverage.cov")]
        args += ["-c", os.path.join(self.working_dir, "filebeat.yml"), "-e",
                 "-v", "-d", "*"]
        proc = Proc(args, os.path.join(self.working_dir, "filebeat.log"))
        os.write(proc.stdin_write, b"Hello World\n")

        proc.start()
        self.wait_until(lambda: self.output_has(lines=1))

        # Continue writing after end was reached
        os.write(proc.stdin_write, b"Hello World2\n")
        os.close(proc.stdin_write)

        self.wait_until(lambda: self.output_has(lines=2))

        proc.proc.terminate()
        proc.proc.wait()

        objs = self.read_output()
        assert objs[0]["message"] == "Hello World"
        assert objs[1]["message"] == "Hello World2"
コード例 #6
0
    def add_secret(self, key, value="hello world\n", force=False):
        """
        Add new secret using the --stdin option
        """
        args = [
            self.test_binary,
            "-systemTest",
            "-c",
            os.path.join(self.working_dir, self.beat_name + ".yml"),
            "-e",
            "-v",
            "-d",
            "*",
            "keystore",
            "add",
            key,
            "--stdin",
        ]

        if force:
            args.append("--force")

        proc = Proc(args,
                    os.path.join(self.working_dir, self.beat_name + ".log"))

        os.write(proc.stdin_write, value)
        os.close(proc.stdin_write)

        return proc.start().wait()
コード例 #7
0
    def test_stdin_eof(self):
        """
        Test that Filebeat works when stdin is closed.
        """
        self.render_config_template(input_type="stdin")

        args = [
            self.beat_path,
            "-systemTest",
            "-test.coverprofile",
            os.path.join(self.working_dir, "coverage.cov"),
            "-c",
            os.path.join(self.working_dir, "filebeat.yml"),
            "-e",
            "-v",
            "-d",
            "*",
        ]
        proc = Proc(args, os.path.join(self.working_dir, "filebeat.log"))
        os.write(proc.stdin_write, "Hello World\n")
        os.close(proc.stdin_write)

        proc.start()
        self.wait_until(lambda: self.output_has(lines=1))

        proc.proc.terminate()
        proc.proc.wait()

        objs = self.read_output()
        assert objs[0]["message"] == "Hello World"
コード例 #8
0
ファイル: packetbeat.py プロジェクト: 7AC/beats
    def start_packetbeat(self,
                         cmd=None,
                         config="packetbeat.yml",
                         output="packetbeat.log",
                         extra_args=[],
                         debug_selectors=[]):
        """
        Starts packetbeat and returns the process handle. The
        caller is responsible for stopping / waiting for the
        Proc instance.
        """
        if cmd is None:
            cmd = self.beat_path + "/packetbeat.test"

        args = [cmd,
                "-e",
                "-c", os.path.join(self.working_dir, config),
                "-systemTest",
                ]
        if os.getenv("TEST_COVERAGE") == "true":
            args += [
                "-test.coverprofile", os.path.join(self.working_dir, "coverage.cov"),
            ]

        if extra_args:
            args.extend(extra_args)

        if debug_selectors:
            args.extend(["-d", ",".join(debug_selectors)])

        proc = Proc(args, os.path.join(self.working_dir, output))
        proc.start()
        return proc
コード例 #9
0
ファイル: test_keystore.py プロジェクト: 7AC/beats
    def add_secret(self, key, value="hello world\n", force=False):
        """
        Add new secret using the --stdin option
        """
        args = [self.test_binary,
                "-systemTest",
                "-c", os.path.join(self.working_dir, self.beat_name + ".yml"),
                "-e", "-v", "-d", "*",
                "keystore", "add", key, "--stdin",
                ]

        if force:
            args.append("--force")

        proc = Proc(args, os.path.join(self.working_dir, self.beat_name + ".log"))

        os.write(proc.stdin_write, value)
        os.close(proc.stdin_write)

        return proc.start().wait()