From 2e796057012896e16350c1ec419a5d716f682992 Mon Sep 17 00:00:00 2001 From: binh-dam-ibigroup <56846598+binh-dam-ibigroup@users.noreply.github.com> Date: Fri, 17 Jun 2022 17:34:51 -0400 Subject: [PATCH] test(setup-e2e): Add checks for folder permissions and OTP binary. --- __tests__/test-utils/setup-e2e.js | 20 ++++++++++++++++---- 1 file changed, 16 insertions(+), 4 deletions(-) diff --git a/__tests__/test-utils/setup-e2e.js b/__tests__/test-utils/setup-e2e.js index e31da0712..995892a19 100644 --- a/__tests__/test-utils/setup-e2e.js +++ b/__tests__/test-utils/setup-e2e.js @@ -20,6 +20,8 @@ const { } = require('./utils') const serverJarFilename = 'dt-latest-dev.jar' +const otpJarMavenUrl = 'https://repo1.maven.org/maven2/org/opentripplanner/otp/1.4.0/otp-1.4.0-shaded.jar' +const otpJarForOtpRunner = '/opt/otp/otp-v1.4.0' const ENV_YML_VARIABLES = [ 'AUTH0_CLIENT_ID', 'AUTH0_DOMAIN', @@ -333,10 +335,7 @@ async function startOtp () { console.log('downloading otp jar') // download otp - await downloadFile( - 'https://repo1.maven.org/maven2/org/opentripplanner/otp/1.4.0/otp-1.4.0-shaded.jar', - otpJarFilename - ) + await downloadFile(otpJarMavenUrl, otpJarFilename) console.log('starting otp') // Ensure default folder for graphs exists. @@ -407,6 +406,19 @@ async function verifySetupForLocalEnvironment () { } ] + // Make sure that certain e2e folders have permissions (assumes running on Linux/MacOS). + const desiredMode = 0o2777 + await fs.ensureDir('/tmp/otp', desiredMode) // For otp-runner manifest files + await fs.ensureDir('/tmp/otp/graphs', desiredMode) // For OTP graph + await fs.ensureDir('/var/log', desiredMode) // For otp-runner log + await fs.ensureDir('/opt/otp', desiredMode) // For OTP jar referenced by otp-runner + + // Download OTP jar into /opt/otp/ if not already present. + const otpJarExists = await fs.exists(otpJarForOtpRunner) + if (!otpJarExists) { + await downloadFile(otpJarMavenUrl, otpJarForOtpRunner) + } + await Promise.all( endpointChecks.map( endpoint => (