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")
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/")