# Licensed to the Apache Software Foundation (ASF) under one # or more contributor license agreements. See the NOTICE file # distributed with this work for additional information # regarding copyright ownership. The ASF licenses this file # to you under the Apache License, Version 2.0 (the # "License"); you may not use this file except in compliance # with the License. You may obtain a copy of the License at # # http://www.apache.org/licenses/LICENSE-2.0 # # Unless required by applicable law or agreed to in writing, # software distributed under the License is distributed on an # "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY # KIND, either express or implied. See the License for the # specific language governing permissions and limitations # under the License. ############################################################################### # curl command tests for templeton # # #use Yahoo::Miners::Test::PigSetup; #PigSetup::setup(); #my $me = `whoami`; #chomp $me; $cfg = { 'driver' => 'Curl', 'groups' => [ ##============================================================================================================= { 'name' => 'JOBS', 'tests' => [ { #a simple load store script as UNAME_OTHER 'num' => 1, 'method' => 'POST', 'url' => ':TEMPLETON_URL:/templeton/v1/pig', 'user_name' => ':UNAME_OTHER:', 'post_options' => ['user.name=:UNAME_OTHER:', 'arg=-p', 'arg=INPDIR=:INPDIR_HDFS:','arg=-p', 'arg=OUTDIR=:OUTDIR:', 'file=:INPDIR_HDFS:/loadstore.pig', ], 'json_field_substr_match' => { 'id' => '\d+'}, #results 'status_code' => 200, 'check_job_created' => 1, 'check_job_complete' => 'SUCCESS', 'check_call_back' => 1, }, { #a simple load store script as UNAME 'num' => 2, 'method' => 'POST', 'url' => ':TEMPLETON_URL:/templeton/v1/pig', 'user_name' => ':UNAME:', 'post_options' => ['user.name=:UNAME:', 'arg=-p', 'arg=INPDIR=:INPDIR_HDFS:','arg=-p', 'arg=OUTDIR=:OUTDIR:', 'file=:INPDIR_HDFS:/loadstore.pig', ], 'json_field_substr_match' => { 'id' => '\d+'}, #results 'status_code' => 200, 'check_job_created' => 1, 'check_job_complete' => 'SUCCESS', 'check_call_back' => 1, }, { #a simple load store script as UNAME_OTHER 'num' => 3, 'method' => 'POST', 'url' => ':TEMPLETON_URL:/templeton/v1/pig', 'user_name' => ':UNAME_OTHER:', 'post_options' => ['user.name=:UNAME_OTHER:', 'arg=-p', 'arg=INPDIR=:INPDIR_HDFS:','arg=-p', 'arg=OUTDIR=:OUTDIR:', 'file=:INPDIR_HDFS:/loadstore.pig', ], 'json_field_substr_match' => { 'id' => '\d+'}, #results 'status_code' => 200, 'check_job_created' => 1, 'check_job_complete' => 'SUCCESS', 'check_call_back' => 1, }, { # now we have 6 jobs (two of each previous test case), check if they have the right user tag # GET jobs?user.name=UNAME_OTHER&showall=true&fields=*, should get all 6 jobs, with the right username field 'num' => 4, 'depends_on' => 'JOBS_1,JOBS_2,JOBS_3', 'method' => 'GET', 'url' => ':TEMPLETON_URL:/templeton/v1/jobs?user.name=:UNAME_OTHER:&showall=true&fields=*', 'user_name' => ':UNAME_OTHER:', 'format_header' => 'Content-Type: application/json', 'filter_job_names' => ['TempletonControllerJob', 'PigLatin:loadstore.pig'], 'json_path' => {'$[-1:].detail.status.username' => ':UNAME_OTHER:', '$[-2:].detail.status.username' => ':UNAME_OTHER:', '$[-3:].detail.status.username' => ':UNAME:', '$[-4:].detail.status.username' => ':UNAME:', '$[-5:].detail.status.username' => ':UNAME_OTHER:', '$[-6:].detail.status.username' => ':UNAME_OTHER:'}, 'status_code' => 200, }, { # GET jobs?user.name=UNAME_OTHER&fields=*, should get only jobs launched as UNAME_OTHER 'num' => 5, 'depends_on' => 'JOBS_1,JOBS_2,JOBS_3', 'method' => 'GET', 'url' => ':TEMPLETON_URL:/templeton/v1/jobs?user.name=:UNAME_OTHER:&fields=*', 'user_name' => ':UNAME_OTHER:', 'format_header' => 'Content-Type: application/json', 'filter_job_names' => ['TempletonControllerJob', 'PigLatin:loadstore.pig'], 'json_path' => {'$[-1:].detail.status.username' => ':UNAME_OTHER:', '$[-2:].detail.status.username' => ':UNAME_OTHER:', '$[-3:].detail.status.username' => ':UNAME_OTHER:', '$[-4:].detail.status.username' => ':UNAME_OTHER:'}, 'status_code' => 200, }, { # GET jobs?user.name=UNAME_OTHER, only get jobid but no detail 'num' => 6, 'depends_on' => 'JOBS_1,JOBS_2,JOBS_3', 'method' => 'GET', 'url' => ':TEMPLETON_URL:/templeton/v1/jobs?user.name=:UNAME_OTHER:', 'user_name' => ':UNAME_OTHER:', 'format_header' => 'Content-Type: application/json', 'json_path' => {'$[-1:].id' => 'job_.*', '$[-1:].detail' => '^$'}, 'status_code' => 200, }, { # GET jobs?user.name=UNAME_OTHER&fields=*, get all the details of the job 'num' => 7, 'depends_on' => 'JOBS_1,JOBS_2,JOBS_3', 'method' => 'GET', 'url' => ':TEMPLETON_URL:/templeton/v1/jobs?user.name=:UNAME_OTHER:&fields=*', 'user_name' => ':UNAME_OTHER:', 'format_header' => 'Content-Type: application/json', 'filter_job_names' => ['TempletonControllerJob', 'PigLatin:loadstore.pig'], 'json_path' => {'$[-1:].id' => 'job_.*', '$[-1:].detail.status.jobId' => 'job_.*', '$[-1:].detail.status.runState' => '\\d+', '$[-1:].detail.status.jobId' => 'job_.*', '$[-1:].detail.status.jobComplete' => 'true', '$[-1:].detail.profile.user' => ':UNAME_OTHER:', '$[-1:].detail.profile.jobFile' => '^.+$', '$[-1:].detail.profile.queueName' => '^.+$', '$[-1:].detail.profile.jobName' => 'loadstore\.pig', '$[-1:].detail.profile.jobID.id' => '\\d+', '$[-1:].detail.profile.jobID.jtIdentifier' => '\\d+', '$[-1:].detail.profile.jobId' => 'job_.*', '$[-1:].detail.id' => 'job_.*', '$[-1:].detail.parentId' => 'job_.*', '$[-2:].detail.exitValue' => '0', '$[-2:].detail.user' => ':UNAME_OTHER:', '$[-2:].detail.callback' => '^.+$', '$[-2:].detail.completed' => 'done', '$[-2:].detail.percentComplete' => '100%', }, 'status_code' => 200, }, { # GET jobs?user.name=UNAME_OTHER&fields=*, get all the details of the oldest 2 jobs whose # id is greater than job_0 'num' => 8, 'depends_on' => 'JOBS_1,JOBS_2,JOBS_3', 'method' => 'GET', 'url' => ':TEMPLETON_URL:/templeton/v1/jobs?user.name=:UNAME_OTHER:&fields=*&numrecords=2&jobid=job_0', 'user_name' => ':UNAME_OTHER:', 'format_header' => 'Content-Type: application/json', 'json_path' => {'$[-1:].id' => 'job_.*', '$[-1:].detail.status.jobId' => 'job_.*', '$[-1:].detail.status.runState' => '\\d+', '$[-1:].detail.status.jobId' => 'job_.*', '$[-1:].detail.status.jobComplete' => 'true', '$[-1:].detail.profile.user' => ':UNAME_OTHER:', '$[-1:].detail.profile.jobFile' => '^.+$', '$[-1:].detail.profile.queueName' => '^.+$', '$[-1:].detail.profile.jobID.id' => '\\d+', '$[-1:].detail.profile.jobID.jtIdentifier' => '\\d+', '$[-1:].detail.profile.jobId' => 'job_.*', '$[-1:].detail.id' => 'job_.*', '$[-1:].detail.parentId' => 'job_.*', '$[-2:].detail.exitValue' => '0', '$[-2:].detail.user' => ':UNAME_OTHER:', '$[-2:].detail.callback' => '^.+$', '$[-2:].detail.completed' => 'done', '$[-2:].detail.percentComplete' => '100%', }, 'status_code' => 200, }, ] } ] } ;