コード例 #1
0
ファイル: test_plugin.py プロジェクト: ClusterHQ/dvol
 def test_docker_run_dvol_container_show_up_in_list_output(self):
     container = "fancy"
     def cleanup():
         cmds = [
             ["docker", "rm", "-f", container],
             ["docker", "volume", "rm", "memorydiskserver"],
             [DVOL, "rm", "-f", "memorydiskserver"],
         ]
         for cmd in cmds:
             try:
                 run(cmd)
             except:
                 pass
     cleanup()
     self.addCleanup(cleanup)
     run([
         "docker", "run", "--name", container, "-d",
         "-v", "memorydiskserver:/data", "--volume-driver", "dvol",
         "clusterhq/memorydiskserver"
     ])
     def dvol_list_includes_container_name():
         result = dvol(["list"])
         if "/" + container not in result:
             raise Exception("container never showed up in result %s" % (result,))
     try_until(dvol_list_includes_container_name)
コード例 #2
0
ファイル: test_plugin.py プロジェクト: mohamedhagag/dvol
 def try_set_memorydiskserver_value(self, value):
     """
     Set a memorydiskserver value and wait for it to complete.
     """
     try_until(lambda: get(
         "http://%s:8080/set?value=%s" % (docker_host(), value,)
     ))
コード例 #3
0
ファイル: test_plugin.py プロジェクト: mohamedhagag/dvol
 def test_docker_run_dvol_multiple_containers_shows_up_in_list_output(self):
     container1 = "fancy"
     container2 = "fancier"
     def cleanup():
         run(["docker", "rm", "-f", container1])
         run(["docker", "rm", "-f", container2])
         run([DVOL, "rm", "-f", "memorydiskserver"])
     try:
         cleanup()
     except:
         pass
     run([
         "docker", "run", "--name", container1, "-d",
         "-v", "memorydiskserver:/data", "--volume-driver", "dvol",
         "clusterhq/memorydiskserver"
     ])
     run([
         "docker", "run", "--name", container2, "-d",
         "-v", "memorydiskserver:/data", "--volume-driver", "dvol",
         "clusterhq/memorydiskserver"
     ])
     def dvol_list_includes_container_names():
         result = run([DVOL, "list"])
         # Either way round is OK
         if (("/" + container1 + ",/" + container2 not in result) and
             ("/" + container2 + ",/" + container1 not in result)):
             raise Exception(
                     "containers never showed up in result %s" % (result,)
             )
     try_until(dvol_list_includes_container_names)
     cleanup()
コード例 #4
0
ファイル: test_plugin.py プロジェクト: cameronbraid/dvol
    def test_docker_run_dvol_container_show_up_in_list_output(self):
        container = "fancy"

        def cleanup():
            cmds = [
                ["docker", "rm", "-f", container],
                ["docker", "volume", "rm", "memorydiskserver"],
                [DVOL, "rm", "-f", "memorydiskserver"],
            ]
            for cmd in cmds:
                try:
                    run(cmd)
                except:
                    pass

        cleanup()
        self.addCleanup(cleanup)
        run([
            "docker", "run", "--name", container, "-d", "-v",
            "memorydiskserver:/data", "--volume-driver", "dvol",
            "clusterhq/memorydiskserver"
        ])

        def dvol_list_includes_container_name():
            result = dvol(["list"])
            if "/" + container not in result:
                raise Exception("container never showed up in result %s" %
                                (result, ))

        try_until(dvol_list_includes_container_name)
コード例 #5
0
ファイル: test_plugin.py プロジェクト: cameronbraid/dvol
 def try_set_memorydiskserver_value(self, value):
     """
     Set a memorydiskserver value and wait for it to complete.
     """
     try_until(lambda: get("http://%s:8080/set?value=%s" % (
         docker_host(),
         value,
     )))
コード例 #6
0
ファイル: test_plugin.py プロジェクト: mohamedhagag/dvol
    def test_docker_run_dvol_creates_volumes(self):
        self.cleanup_memorydiskserver()
        self.start_memorydiskserver()

        def dvol_list_includes_memorydiskserver():
            result = run([DVOL, "list"])
            if "memorydiskserver" not in result:
                raise Exception("volume never showed up in result %s" % (result,))
        try_until(dvol_list_includes_memorydiskserver)
コード例 #7
0
ファイル: test_plugin.py プロジェクト: cameronbraid/dvol
    def test_docker_run_dvol_creates_volumes(self):
        self.cleanup_memorydiskserver()
        self.start_memorydiskserver()

        def dvol_list_includes_memorydiskserver():
            result = dvol(["list"])
            if "memorydiskserver" not in result:
                raise Exception("volume never showed up in result %s" %
                                (result, ))

        try_until(dvol_list_includes_memorydiskserver)
コード例 #8
0
ファイル: test_plugin.py プロジェクト: cameronbraid/dvol
    def test_docker_run_roundtrip_value(self):
        self.cleanup_memorydiskserver()
        self.start_memorydiskserver()

        for value in ("10", "20"):
            # Running test with multiple values forces container to persist it
            # in memory (rather than hard-coding the response to make the test
            # pass).
            try_until(lambda: get("http://" + docker_host() +
                                  ":8080/set?value=%s" % (value, )))
            getting_value = try_until(
                lambda: get("http://" + docker_host() + ":8080/get"))
            self.assertEqual(getting_value.content, "Value: %s" % (value, ))
コード例 #9
0
ファイル: test_plugin.py プロジェクト: mohamedhagag/dvol
 def try_get_memorydiskserver_value(self):
     """
     Get a memorydiskserver value and wait for it to return.
     """
     return try_until(lambda: get(
         "http://%s:8080/get" % (docker_host(),)
     )).content
コード例 #10
0
ファイル: test_plugin.py プロジェクト: mohamedhagag/dvol
    def test_docker_run_roundtrip_value(self):
        self.cleanup_memorydiskserver()
        self.start_memorydiskserver()

        for value in ("10", "20"):
            # Running test with multiple values forces container to persist it
            # in memory (rather than hard-coding the response to make the test
            # pass).
            try_until(
                lambda: get(
                    "http://" + docker_host() + ":8080/set?value=%s" % (value,)
                )
            )
            getting_value = try_until(
                lambda: get("http://" + docker_host() + ":8080/get")
            )
            self.assertEqual(getting_value.content, "Value: %s" % (value,))
コード例 #11
0
ファイル: test_plugin.py プロジェクト: cameronbraid/dvol
    def test_docker_run_dvol_multiple_containers_shows_up_in_list_output(self):
        container1 = "fancy"
        container2 = "fancier"

        def cleanup():
            cmds = [
                ["docker", "rm", "-f", container1],
                ["docker", "rm", "-f", container2],
                ["docker", "volume", "rm", "memorydiskserver"],
                [DVOL, "rm", "-f", "memorydiskserver"],
            ]
            for cmd in cmds:
                try:
                    run(cmd)
                except:
                    pass

        cleanup()
        self.addCleanup(cleanup)
        run([
            "docker", "run", "--name", container1, "-d", "-v",
            "memorydiskserver:/data", "--volume-driver", "dvol",
            "clusterhq/memorydiskserver"
        ])
        run([
            "docker", "run", "--name", container2, "-d", "-v",
            "memorydiskserver:/data", "--volume-driver", "dvol",
            "clusterhq/memorydiskserver"
        ])

        def dvol_list_includes_container_names():
            result = dvol(["list"])
            # Either way round is OK
            if (("/" + container1 + ",/" + container2 not in result)
                    and ("/" + container2 + ",/" + container1 not in result)):
                raise Exception("containers never showed up in result %s" %
                                (result, ))

        try_until(dvol_list_includes_container_names)
コード例 #12
0
ファイル: test_plugin.py プロジェクト: mohamedhagag/dvol
    def test_docker_run_test_container(self):
        def cleanup():
            run(["docker", "rm", "-f", "memorydiskserver"])
        try:
            cleanup()
        except:
            pass
        run([
            "docker", "run", "--name", "memorydiskserver", "-d",
            "-p", "8080:80", "clusterhq/memorydiskserver"
        ])

        wait_for_server = try_until(
            lambda: get("http://" + docker_host() + ":8080/get")
        )
        self.assertEqual(wait_for_server.content, "Value: ")
コード例 #13
0
ファイル: test_plugin.py プロジェクト: cameronbraid/dvol
    def test_docker_run_test_container(self):
        def cleanup():
            run(["docker", "rm", "-f", "memorydiskserver"])

        try:
            cleanup()
        except:
            pass
        run([
            "docker", "run", "--name", "memorydiskserver", "-d", "-p",
            "8080:80", "clusterhq/memorydiskserver"
        ])

        wait_for_server = try_until(
            lambda: get("http://" + docker_host() + ":8080/get"))
        self.assertEqual(wait_for_server.content, "Value: ")
コード例 #14
0
ファイル: test_plugin.py プロジェクト: cameronbraid/dvol
 def try_get_memorydiskserver_value(self):
     """
     Get a memorydiskserver value and wait for it to return.
     """
     return try_until(lambda: get("http://%s:8080/get" %
                                  (docker_host(), ))).content