Skip to content

Commit

Permalink
Merge pull request #309 from mendix/DVAS-1093_appdynamics
Browse files Browse the repository at this point in the history
DVAS-1093 - Update Appdynamics agent in buildpack
  • Loading branch information
markbastiaans authored Apr 22, 2020
2 parents d902039 + 8d971b0 commit 26bfa2a
Show file tree
Hide file tree
Showing 5 changed files with 58 additions and 6 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -280,7 +280,7 @@ To enable AppDynamics, configure the following environment variables:

\* The `APPDYNAMICS_AGENT_NODE_NAME` environment variable will be appended with the value of the `CF_INSTANCE_ID` variable. If you use `my-app` for `APPDYNAMICS_AGENT_NODE_NAME`, the AppDynamics agent will be configured as `my-app-0` for instance `0` and `my-app-1` for instance `1`, etc.

If you have any environment variable that starts with `APPDYNAMICS_`, the AppDynamics Java Agent will be configured for your application. At the moment only agent version 4.3.5.7 is available. After configuring these environment variables, restage your app for the agent to be enabled.
If you have any environment variable that starts with `APPDYNAMICS_`, the AppDynamics Java Agent will be configured for your application. At the moment only agent version 20.3.0.29587 is available. After configuring these environment variables, restage your app for the agent to be enabled.

Please note that AppDynamics requires Mendix 6.2 or higher.

Expand Down
2 changes: 1 addition & 1 deletion bin/compile.py
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,7 @@ def set_up_appdynamics():
if buildpackutil.appdynamics_used():
buildpackutil.download_and_unpack(
buildpackutil.get_blobstore_url(
"/mx-buildpack/appdynamics-agent-4.3.5.7.tar.gz"
"/mx-buildpack/appdynamics-agent-20.3.0.29587.zip"
),
DOT_LOCAL_LOCATION,
CACHE_DIR,
Expand Down
4 changes: 3 additions & 1 deletion lib/buildpackutil.py
Original file line number Diff line number Diff line change
Expand Up @@ -147,13 +147,15 @@ def download_and_unpack(url, destination, cache_dir="/tmp/downloads"):
unpack_cmd = ["tar", "xf", cached_location, "-C", destination]
if file_name.startswith(("mono-", "jdk-", "jre-", "AdoptOpenJDK-")):
unpack_cmd.extend(("--strip", "1"))
subprocess.check_call(unpack_cmd)
elif file_name.endswith(".zip"):
unpack_cmd = ["unzip", cached_location, "-d", destination]
else:
raise Exception(
"do not know how to unpack {cached_location}".format(
cached_location=cached_location
)
)
subprocess.check_call(unpack_cmd)

logging.debug(
"source {file_name} retrieved & unpacked in {destination}".format(
Expand Down
9 changes: 6 additions & 3 deletions start.py
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@
from nginx import get_path_config, gen_htpasswd # noqa: E402
from buildpackutil import i_am_primary_instance # noqa: E402

BUILDPACK_VERSION = "4.4.1"
BUILDPACK_VERSION = "4.4.2"


logger.setLevel(buildpackutil.get_buildpack_loglevel())
Expand Down Expand Up @@ -740,17 +740,20 @@ def set_application_name(m2ee, name):


def activate_appdynamics(m2ee, app_name):
APPDYNAMICS_VERSION = "20.3.0.29587"
if not buildpackutil.appdynamics_used():
return
logger.info("Adding app dynamics")
m2ee.config._conf["m2ee"]["javaopts"].append(
"-javaagent:{path}".format(
path=os.path.abspath(".local/ver4.3.5.7/javaagent.jar")
path=os.path.abspath(
".local/ver" + APPDYNAMICS_VERSION + "/javaagent.jar"
)
)
)
m2ee.config._conf["m2ee"]["javaopts"].append(
"-Dappagent.install.dir={path}".format(
path=os.path.abspath(".local/ver4.3.5.7")
path=os.path.abspath(".local/ver" + APPDYNAMICS_VERSION)
)
)
APPDYNAMICS_AGENT_NODE_NAME = "APPDYNAMICS_AGENT_NODE_NAME"
Expand Down
47 changes: 47 additions & 0 deletions tests/usecase/test_appdynamics.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
import basetest


class TestCaseDeployWithAppdynamics(basetest.BaseTest):
def _deploy_app(self, mda_file):
super().setUp()
self.setUpCF(
mda_file,
env_vars={
"APPDYNAMICS_AGENT_ACCOUNT_NAME": "Mendix-test",
"APPDYNAMICS_AGENT_ACCOUNT_ACCESS_KEY": "NON-VALID-TEST-KEY",
"APPDYNAMICS_AGENT_APPLICATION_NAME": "Test",
"APPDYNAMICS_AGENT_NODE_NAME": "Test",
"APPDYNAMICS_AGENT_TIER_NAME": "Test",
"APPDYNAMICS_CONTROLLER_HOST_NAME": "test.mendix.com",
"APPDYNAMICS_CONTROLLER_PORT": 443,
"APPDYNAMICS_CONTROLLER_SSL_ENABLED": "true",
},
)
self.startApp()

def _test_appdynamics_running(self, mda_file):
APPDYNAMICS_VERSION = "20.3.0.29587"
self._deploy_app(mda_file)
self.assert_app_running()

# check if appdynamics agent is running
output = self.cmd(
("cf", "ssh", self.app_name, "-c", "ps -ef| grep javaagent")
)
assert output is not None
assert str(output).find(APPDYNAMICS_VERSION) >= 0

def _test_appdynamics(self, mda_file):
self._test_appdynamics_running(mda_file)
self.assert_string_in_recent_logs(
"Started AppDynamics Java Agent Successfully"
)

def test_appdynamics_mx8(self):
self._test_appdynamics("Mendix8.1.1.58432_StarterApp.mda")

def test_appdynamics_mx7(self):
self._test_appdynamics("BuildpackTestApp-mx-7-16.mda")

def test_appdynamics_mx6(self):
self._test_appdynamics("sample-6.2.0.mda")

0 comments on commit 26bfa2a

Please sign in to comment.