Skip to content

Commit

Permalink
[INFRA-1263] Test data and logic for Jenkinsfile for PR builds
Browse files Browse the repository at this point in the history
  • Loading branch information
abayer committed Jul 5, 2017
1 parent 34db9e8 commit dde5d84
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 7 deletions.
25 changes: 18 additions & 7 deletions Jenkinsfile
Expand Up @@ -33,22 +33,33 @@ else {
"JAVA_HOME=${javaHome}",
]

final String usagestats_dir = './usage-stats'
final String census_dir = './census'
String usagestats_dir = './usage-stats'
String census_dir = './census'
String mongoDataDir = "mongo-data"

if (!infra.isTrusted() && env.BRANCH_NAME) {
// If we're running for a PR build, use a fresh testing directory and nuke whatever was there previously.
sh "rm -rf testing"
sh "mkdir -p testing/census"
sh "cd testing && tar -xvzf ../test-data/usage.tar.gz ."
usagestats_dir = './testing/usage'
census_dir = './testing/census'
mongoDataDir = "testing/mongo-data"
}
stage 'Sync raw data and census files'
sh "rsync -avz --delete ${USAGE_HOST}:/srv/usage/usage-stats ."
sh "rsync -avz --delete ${CENSUS_HOST}:/srv/census/census ."

if (infra.isTrusted()) {
sh "rsync -avz --delete ${USAGE_HOST}:/srv/usage/usage-stats ."
sh "rsync -avz --delete ${CENSUS_HOST}:/srv/census/census ."
}

stage 'Process raw logs'
// TODO: Fix ownership!
// The mongo-data directory will end up containing files and dirs owned by 999:docker that we can't do much about for the moment.
// Needs a better fix going forward, but for the moment...
sh "mkdir -p mongo-data"
sh "mkdir -p ${mongoDataDir}"

// Use the Mongo data directory in the workspace.
docker.image('mongo:2').withRun('-p 27017:27017 -v ' + pwd() + "/mongo-data:/data/db") { container ->
docker.image('mongo:2').withRun('-p 27017:27017 -v ' + pwd() + "/" + mongoDataDir + ":/data/db") { container ->
withEnv(customEnv) {
sh "groovy parseUsage.groovy --logs ${usagestats_dir} --output ${census_dir} --incremental"
}
Expand Down
Binary file added test-data/usage.tar.gz
Binary file not shown.

0 comments on commit dde5d84

Please sign in to comment.