1/* 2 * Licensed to the Apache Software Foundation (ASF) under one or more 3 * contributor license agreements. See the NOTICE file distributed with 4 * this work for additional information regarding copyright ownership. 5 * The ASF licenses this file to You under the Apache License, Version 2.0 6 * (the "License"); you may not use this file except in compliance with 7 * the License. You may obtain a copy of the License at 8 * 9 * http://www.apache.org/licenses/LICENSE-2.0 10 * 11 * Unless required by applicable law or agreed to in writing, software 12 * distributed under the License is distributed on an "AS IS" BASIS, 13 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 * See the License for the specific language governing permissions and 15 * limitations under the License. 16 */ 17 18package org.apache.spark.streaming.kinesis 19 20import org.apache.spark.SparkFunSuite 21 22/** 23 * Helper class that runs Kinesis real data transfer tests or 24 * ignores them based on env variable is set or not. 25 */ 26trait KinesisFunSuite extends SparkFunSuite { 27 import KinesisTestUtils._ 28 29 /** Run the test if environment variable is set or ignore the test */ 30 def testIfEnabled(testName: String)(testBody: => Unit) { 31 if (shouldRunTests) { 32 test(testName)(testBody) 33 } else { 34 ignore(s"$testName [enable by setting env var $envVarNameForEnablingTests=1]")(testBody) 35 } 36 } 37 38 /** Run the give body of code only if Kinesis tests are enabled */ 39 def runIfTestsEnabled(message: String)(body: => Unit): Unit = { 40 if (shouldRunTests) { 41 body 42 } else { 43 ignore(s"$message [enable by setting env var $envVarNameForEnablingTests=1]")(()) 44 } 45 } 46} 47