def test_fast_deploy_7_23_1(self): FILENAME = "AdoptOpenJDKTest_7.23.1.mpk" self.setUpCF(FILENAME, env_vars={"DEPLOY_PASSWORD": self.mx_password}) self.startApp() self.cmd(( "wget", "--quiet", "-N", "-O", self.app_id + FILENAME, "https://s3-eu-west-1.amazonaws.com" "/mx-buildpack-ci/" + FILENAME, )) r = self._await_fast_deploy(self.app_id + FILENAME) if r.status_code != 200: print(self.get_recent_logs()) assert r.status_code == 200 and "STARTED" in r.text os.remove(self.app_id + FILENAME) jdk = java.determine_jdk(runtime.get_java_version("7.23.1")) target_dir = java.compose_jvm_target_dir(jdk) assert jdk["version"] == "8u202" assert (target_dir == "usr/lib/jvm/AdoptOpenJDK-jdk-8u202-AdoptOpenJDK-x64") self._check_java_presence(target_dir)
def set_up_instadeploy_if_deploy_password_is_set(m2ee_client): if os.getenv("DEPLOY_PASSWORD"): mx_version = m2ee_client.config.get_runtime_version() if util.use_instadeploy(mx_version): def reload_callback(): m2ee_client.client.request("reload_model") def restart_callback(): global app_is_restarting app_is_restarting = True if not m2ee_client.stop(): m2ee_client.terminate() runtime.complete_start_procedure_safe_to_use_for_restart(m2ee) app_is_restarting = False thread = instadeploy.InstaDeployThread( util.get_deploy_port(), restart_callback, reload_callback, mx_version, runtime.get_java_version(mx_version), ) thread.setDaemon(True) thread.start() if os.path.exists(os.path.expanduser("~/.sourcepush")): instadeploy.send_metadata_to_cloudportal() else: logging.warning( "Not setting up InstaDeploy because this mendix " "runtime version %s does not support it", mx_version, )
def test_adopt_jdk_11(self): self.setUpCF("AdoptOpenJDKTest_8beta3.mda", health_timeout=60) self.startApp() jdk = java.determine_jdk(runtime.get_java_version("8.0.0"), "jre") target_dir = java.compose_jvm_target_dir(jdk) assert jdk["version"] == "11.0.3" assert (target_dir == "usr/lib/jvm/AdoptOpenJDK-jre-11.0.3-AdoptOpenJDK-x64") self._check_java_presence(target_dir) self.assert_certificate_in_cacert("staat der nederlanden root ca - g3")
def test_oracle_jdk_8(self): self.setUpCF("BuildpackTestApp-mx-7-16.mda", health_timeout=60) self.startApp() jdk = java.determine_jdk(runtime.get_java_version("7.16.0"), "jre") target_dir = java.compose_jvm_target_dir(jdk) assert jdk["version"] == "8u202" assert target_dir == "usr/lib/jvm/jre-8u202-oracle-x64" self._check_java_presence(target_dir) self.assert_certificate_in_cacert("staat der nederlanden root ca - g3")
def _test_jdk(self, mda, mx_version, jdk_version, target_dir): self.stage_container(mda) jdk = java.determine_jdk(runtime.get_java_version(mx_version), "jre") target = java.compose_jvm_target_dir(jdk) assert jdk["version"] == jdk_version assert target == target_dir self.assert_java_presence(target) # TODO check if we can do this with staging / in one test only self.start_container() self.assert_certificate_in_cacert(CERT_TO_CHECK)
def set_up_m2ee_client(vcap_data): client = m2ee_class( yamlfiles=[".local/m2ee.yaml"], load_default_files=False, config={ "m2ee": { # this is named admin_pass, but it's the verification http header # to communicate with the internal management port of the runtime "admin_pass": security.get_m2ee_password() } }, ) version = client.config.get_runtime_version() mendix_runtimes_path = "/usr/local/share/mendix-runtimes.git" mendix_runtime_version_path = os.path.join(os.getcwd(), "runtimes", str(version)) if os.path.isdir(mendix_runtimes_path ) and not os.path.isdir(mendix_runtime_version_path): util.mkdir_p(mendix_runtime_version_path) env = dict(os.environ) env["GIT_WORK_TREE"] = mendix_runtime_version_path # checkout the runtime version process = subprocess.Popen( ["git", "checkout", str(version), "-f"], cwd=mendix_runtimes_path, env=env, stdout=subprocess.PIPE, stderr=subprocess.PIPE, ) process.communicate() if process.returncode != 0: logging.info("Mendix %s is not available in the rootfs", version) logging.info("Fallback (1): trying to fetch Mendix %s using git", version) process = subprocess.Popen( [ "git", "fetch", "origin", "refs/tags/{0}:refs/tags/{0}".format(str(version)), "&&", "git", "checkout", str(version), "-f", ], cwd=mendix_runtimes_path, env=env, stdout=subprocess.PIPE, stderr=subprocess.PIPE, ) process.communicate() if process.returncode != 0: logging.info( "Unable to fetch Mendix {} using git".format(version)) url = util.get_blobstore_url("/runtime/mendix-%s.tar.gz" % str(version)) logging.info( "Fallback (2): downloading Mendix {} from {}".format( version, url)) util.download_and_unpack(url, os.path.join(os.getcwd(), "runtimes")) client.reload_config() runtime.set_runtime_config( client.config._model_metadata, client.config._conf["mxruntime"], vcap_data, client, ) java_version = runtime.get_java_version( client.config.get_runtime_version())["version"] java.update_config(client.config._conf["m2ee"], vcap_data, java_version) runtime.set_jetty_config(client) newrelic.update_config(client, vcap_data["application_name"]) appdynamics.update_config(client, vcap_data["application_name"]) runtime.set_application_name(client, vcap_data["application_name"]) telegraf.update_config(client, vcap_data["application_name"]) datadog.update_config(client) return client
util.get_buildpack_version(), util.get_current_buildpack_commit(), ) try: if os.getenv("CF_INSTANCE_INDEX") is None: logging.warning( "CF_INSTANCE_INDEX environment variable not found. Assuming " "responsibility for scheduled events execution and database " "synchronization commands.") runtime.pre_process_m2ee_yaml() runtime.activate_license() m2ee = runtime.set_up_m2ee_client(util.get_vcap_data()) java_version = runtime.get_java_version( m2ee.config.get_runtime_version())["version"] java.update_config(m2ee.config._conf["m2ee"], util.get_vcap_data(), java_version) newrelic.update_config(m2ee, util.get_vcap_data()["application_name"]) appdynamics.update_config(m2ee, util.get_vcap_data()["application_name"]) dynatrace.update_config(m2ee, util.get_vcap_data()["application_name"]) mx_java_agent.update_config(m2ee) telegraf.update_config(m2ee, util.get_vcap_data()["application_name"]) ( databroker_jmx_instance_cfg, databroker_jmx_config_files, ) = databroker_processes.get_datadog_config( datadog._get_user_checks_dir()) datadog.update_config(
try: preflight_check() except (ValueError, NotImplementedError) as error: logging.error(error) exit(1) if is_source_push(): logging.info("Source push detected, starting MxBuild...") runtime_version = runtime.get_version(BUILD_DIR) try: mxbuild.stage( BUILD_DIR, CACHE_DIR, DOT_LOCAL_LOCATION, runtime_version, runtime.get_java_version(runtime_version), ) except RuntimeError as error: logging.error(error) exit(1) finally: for folder in ("mxbuild", "mono"): path = os.path.join(DOT_LOCAL_LOCATION, folder) shutil.rmtree(path, ignore_errors=True) set_up_directory_structure() copy_buildpack_resources() java.stage( BUILDPACK_DIR, CACHE_DIR, DOT_LOCAL_LOCATION,