Example #1
0
 def setUpClass(cls):
     print(
         ' \n >>>> ==== Running Test 3 - Verify Compose with secret, postgres, custom-extensions'
         + ' ===== ')
     print(' >>>> ==== using IMAGE = ' + cls.docker_image + ' ===== ')
     DockerUtil.empty_test_folder("tmp")
     # Setup test dir as volume to by mounted by container
     # exts =  DockerUtil.create_test_dir("tmp/exts")
     if os.name == 'nt':
         DockerUtil.create_test_dir("tmp\\exts")
         os.system('copy /y .\\testdata\\*.zip .\\tmp\\exts')
         os.system('copy /y .\\testdata\\secret.properties .\\tmp')
     else:
         DockerUtil.create_test_dir("tmp/exts")
         os.system('cp ./testdata/*.zip ./tmp/exts/')
         os.system('cp ./testdata/secret.properties ./tmp/')
     DockerUtil.generate_compose_yml(cls.test_yml, cls.docker_image)
     # Run docker compose
     os.system(cls.composeCmd + " up -d")
     client = docker.from_env()
     cls.container = client.containers.get("mctest3_mc_1")
     # wait for MC to come up
     try:
         DockerUtil.wait_for_containers([cls.container], cls.max_wait_time)
     except Exception, e:
         print(">>>> MC server failed to start")
         cls.tearDownClass()
         raise e
Example #2
0
class DockerTests1(unittest.TestCase):
    docker_image = ""
    container = ""
    mirth_properties_map = {}
    vmoptions_array = []
    max_wait_time = 240

    @classmethod
    def setUpClass(cls):
        # run docker image with 2 environment variables
        print(' \n >>>> ==== Running Test 1 - Verify Environment Variables' +
              ' ===== ')
        print(' >>>> ==== using IMAGE = ' + cls.docker_image + ' ===== ')
        client = docker.from_env()
        cls.container = client.containers.run(
            cls.docker_image,
            environment=["SESSION_STORE=true", "VMOPTIONS=-Xmx768m"],
            detach=True,
            name="mctest1")
        # wait for MC to come up
        try:
            DockerUtil.wait_for_containers([cls.container], cls.max_wait_time)
        except Exception, e:
            print(">>>> MC server failed to start")
            cls.tearDownClass()
            raise e
        # retrieve container mirth.properties file as a map
        cls.mirth_properties_map = DockerUtil.get_prop_file_as_map(
            cls.container, "/opt/connect/conf/mirth.properties")
        # retrieve container server.vmoptions file as string array
        cls.vmoptions_array = DockerUtil.get_file_as_string_array(
            cls.container, "/opt/connect/mcserver.vmoptions")
    def test_extensions_https(self):
        # HTTPS and allowing insecure

        # expect not to find SSL cert problem
        with self.assertRaises(Exception) as e:
            DockerUtil.wait_for_log_message(
                [self.container],
                "SSL certificate problem: self signed certificate",
                self.max_wait_time)

        # expect to find downloading extensions in to folder
        try:
            DockerUtil.wait_for_log_message([self.container],
                                            "Downloading extensions at",
                                            self.max_wait_time)
            DockerUtil.wait_for_log_message([self.container],
                                            "Unzipping contents of",
                                            self.max_wait_time)
        except Exception as e:
            self.fail(e)

        # Verify plugin.xml file for each test Extensions in MC extensions folder
        # retrieve container extensions folder
        exts = DockerUtil.list_container_dir(self.__class__.container,
                                             "/opt/connect/extensions/")
        self.assertTrue(("extensions/testExtension3/plugin.xml" in exts)
                        and ("extensions/testExtension2/plugin.xml" in exts)
                        and ("extensions/testExtension1/plugin.xml" in exts))

        # expect to see Connect start
        try:
            DockerUtil.wait_for_containers([self.container],
                                           self.max_wait_time)
        except Exception as e:
            self.fail(e)
Example #4
0
    def test_CustomJars_http(self):
        # HTTPS and allowing insecure

        # expect not to find SSL cert problem
        with self.assertRaises(Exception) as e:
            DockerUtil.wait_for_log_message(
                [self.container],
                "SSL certificate problem: self signed certificate",
                self.max_wait_time)

        # expect to find downloading custom jars in to folder
        try:
            DockerUtil.wait_for_log_message([self.container],
                                            "Downloading Jars at",
                                            self.max_wait_time)
            DockerUtil.wait_for_log_message([self.container],
                                            "Unzipping contents of",
                                            self.max_wait_time)
        except Exception as e:
            self.fail(e)

        # expect to see Connect start
        try:
            DockerUtil.wait_for_containers([self.container],
                                           self.max_wait_time)
        except Exception as e:
            self.fail(e)
    def test_keystore_http(self):
        # HTTP download

        # expect to find downloading keystore message
        # expect to see Connect start
        try:
            # wait for keystore download message
            DockerUtil.wait_for_log_message([self.container], "Downloading keystore at", self.max_wait_time)

            # wait for MC to come up
            DockerUtil.wait_for_containers([self.container], self.max_wait_time)
        except Exception as e:
            # fail if there is any exception
            self.fail(e)
Example #6
0
 def setUpClass(cls):
     # run docker image with 2 environment variables
     print(' \n >>>> ==== Running Test 1 - Verify Environment Variables')
     print(' >>>> ==== using IMAGE = ' + cls.docker_image + ' ===== ')
     client = docker.from_env()
     cls.container = client.containers.run(
         cls.docker_image,
         environment=["SESSION_STORE=true", "VMOPTIONS=-Xmx768m"],
         detach=True,
         name="mctest1")
     # wait for MC to come up
     try:
         DockerUtil.wait_for_containers([cls.container], 60)
     except Exception, e:
         print(">>>> MC server failed to start")
         cls.tearDownClass()
         raise e
    def test_extensions_http(self):
        # HTTP download

        # expect to find downloading extensions in to folder
        # expect to see Connect start
        try:
            # wait for extensions download message
            DockerUtil.wait_for_log_message([self.container],
                                            "Downloading extensions at",
                                            self.max_wait_time)
            DockerUtil.wait_for_log_message([self.container],
                                            "Unzipping contents of",
                                            self.max_wait_time)

            # Verify plugin.xml file for each test Extensions in MC extensions folder
            # retrieve container extensions folder
            exts = DockerUtil.list_container_dir(self.__class__.container,
                                                 "/opt/connect/extensions/")
            self.assertTrue(
                ("extensions/testExtension3/plugin.xml" in exts)
                and ("extensions/testExtension2/plugin.xml" in exts)
                and ("extensions/testExtension1/plugin.xml" in exts))

            # wait for MC to come up
            DockerUtil.wait_for_containers([self.container],
                                           self.max_wait_time)
        except Exception as e:
            # fail if there is any exception
            self.fail(e)
Example #8
0
class DockerTests3(unittest.TestCase):
    docker_image = ""
    container = ""
    mirth_properties_map = {}
    extensions_list = []
    test_yml = os.path.join('.', 'tmp', 'test.yml')
    composeCmd = 'docker-compose -f ' + test_yml + ' -p mctest3'
    max_wait_time = 240

    @classmethod
    def setUpClass(cls):
        print(
            ' \n >>>> ==== Running Test 3 - Verify Compose with secret, postgres, custom-extensions'
            + ' ===== ')
        print(' >>>> ==== using IMAGE = ' + cls.docker_image + ' ===== ')
        DockerUtil.empty_test_folder("tmp")
        # Setup test dir as volume to by mounted by container
        # exts =  DockerUtil.create_test_dir("tmp/exts")
        if os.name == 'nt':
            DockerUtil.create_test_dir("tmp\\exts")
            os.system('copy /y .\\testdata\\*.zip .\\tmp\\exts')
            os.system('copy /y .\\testdata\\secret.properties .\\tmp')
        else:
            DockerUtil.create_test_dir("tmp/exts")
            os.system('cp ./testdata/*.zip ./tmp/exts/')
            os.system('cp ./testdata/secret.properties ./tmp/')
        DockerUtil.generate_compose_yml(cls.test_yml, cls.docker_image)
        # Run docker compose
        os.system(cls.composeCmd + " up -d")
        client = docker.from_env()
        cls.container = client.containers.get("mctest3_mc_1")
        # wait for MC to come up
        try:
            DockerUtil.wait_for_containers([cls.container], cls.max_wait_time)
        except Exception, e:
            print(">>>> MC server failed to start")
            cls.tearDownClass()
            raise e
        # retrieve container mirth.properties file as a map
        cls.mirth_properties_map = DockerUtil.get_prop_file_as_map(
            cls.container, "/opt/connect/conf/mirth.properties")
        # retrieve container extensions folder
        cls.extensions_list = DockerUtil.list_container_dir(
            cls.container, "/opt/connect/extensions/")
    def setUpClass(cls):
        print(' \n >>>> ==== Running Test Keystore - Verify Compose with keystore download HTTP' + ' ===== ') 
        print( ' >>>> ==== using IMAGE = ' + cls.docker_image + ' ===== ')
        DockerUtil.empty_test_folder("tmp")

        # Setup test dir as volume to by mounted by container
        if os.name == 'nt':
            DockerUtil.create_test_dir("tmp")
            os.system('xcopy /E /I /Y .\\testdata\\web .\\tmp\\web')
        else:
            DockerUtil.create_test_dir("tmp")
            os.system('cp -r ./testdata/web ./tmp/web')
        DockerUtil.generate_compose_yml(cls.test_yml, cls.docker_image, 'keystore-http.yml')
        
        # Run docker compose
        os.system(cls.composeCmd + " up -d")
        client = docker.from_env()
        cls.container = client.containers.get("mctest_keystore_http_mc_1")
    def test_keystore_http(self):
        # HTTPS but not allowing insecure

        # expect to find downloading keystore message
        # expect to find SSL cert problem
        try:
            DockerUtil.wait_for_log_message([self.container],
                                            "Downloading keystore at",
                                            self.max_wait_time)
            DockerUtil.wait_for_log_message(
                [self.container],
                "SSL certificate problem: self signed certificate",
                self.max_wait_time)
        except Exception as e:
            self.fail(e)

        # expect Connect to not start
        with self.assertRaises(Exception) as e:
            DockerUtil.wait_for_containers([self.container],
                                           self.max_wait_time)
Example #11
0
    def test_custom_jars_http(self):
        # HTTP download

        # expect to find downloading custom jars in to folder
        # expect to see Connect start
        try:
            # wait for custom jars download message
            DockerUtil.wait_for_log_message([self.container],
                                            "Downloading Jars at",
                                            self.max_wait_time)
            DockerUtil.wait_for_log_message([self.container],
                                            "Unzipping contents of",
                                            self.max_wait_time)

            # wait for MC to come up
            DockerUtil.wait_for_containers([self.container],
                                           self.max_wait_time)
        except Exception as e:
            # fail if there is any exception
            self.fail(e)
    def test_extensions_https(self):
        # HTTPS but not allowing insecure

        # expect to find downloading extensions in to folder
        # expect to find SSL cert problem
        try:
            DockerUtil.wait_for_log_message([self.container],
                                            "Downloading extensions at",
                                            self.max_wait_time)
            DockerUtil.wait_for_log_message(
                [self.container],
                "SSL certificate problem: self signed certificate",
                self.max_wait_time)
        except Exception as e:
            self.fail(e)

        # expect Connect to not start
        try:
            DockerUtil.wait_for_containers([self.container],
                                           self.max_wait_time)
        except Exception as e:
            self.fail(e)
Example #13
0
 def setUpClass(cls):
     print(' \n >>>> ==== Running Test 2 - Verify Mounted Volume')
     print(' >>>> ==== using IMAGE = ' + cls.docker_image + ' ===== ')
     DockerUtil.empty_test_folder("tmp")
     # Setup test dir as volume to by mounted by container
     appdata = DockerUtil.create_test_dir("tmp/appdata")
     exts = DockerUtil.create_test_dir("tmp/extensions")
     mount = {}
     mount[appdata] = {'bind': '/opt/connect/appdata', 'mode': 'rw'}
     mount[exts] = {'bind': '/opt/connect/custom-extensions', 'mode': 'ro'}
     # run docker image with -v option
     client = docker.from_env()
     cls.container = client.containers.run(cls.docker_image,
                                           volumes=mount,
                                           detach=True,
                                           name="mctest2")
     # wait for MC to come up
     try:
         DockerUtil.wait_for_containers([cls.container], 60)
     except Exception, e:
         print(">>>> MC server failed to start")
         cls.tearDownClass()
         raise e
Example #14
0
 def tearDownClass(cls):
     # clean up at the end of the test
     os.system(cls.composeCmd + " down")
     DockerUtil.empty_test_folder("tmp")
     cls.mirth_properties_map = {}
     cls.extensions_list = []
Example #15
0
 def test_mirthdb_postgres(self):
     # Verify MC started up with postgres
     self.assertTrue(
         DockerUtil.check_container_log(self.__class__.container,
                                        "postgres"))
Example #16
0
 def test_mounted_appdata(self):
     # Verify appdata is populated with files
     count = len(DockerUtil.list_test_dir("tmp/appdata/"))
     self.assertGreaterEqual(5, count)
Example #17
0
 def tearDownClass(cls):
     # clean up at the end of the test
     cls.container.stop()
     cls.container.remove()
     DockerUtil.empty_test_folder("tmp")
 def tearDownClass(cls):
     # clean up at the end of the test
     os.system(cls.composeCmd + " down")
     DockerUtil.empty_test_folder("tmp")
Example #19
0
 def test_mounted_appdata(self):
     # Verify appdata is populated with files
     count = len(
         DockerUtil.list_test_dir(os.path.join('tmp', 'appdata', '')))
     self.assertGreaterEqual(5, count)