From 45bb58dc8608c72cf4edbd3de7e5f151af538d2b Mon Sep 17 00:00:00 2001 From: smarthi Date: Wed, 6 Apr 2016 00:57:05 -0400 Subject: [PATCH] MAHOUT-1823: Modify MahoutFlinkTestSuite to implement FlinkTestBase --- flink/pom.xml | 11 +++++- .../flinkbindings/DistributedFlinkSuite.scala | 39 ++++++++++++++++--- .../DistributedDecompositionsSuite.scala | 28 ++++++++----- .../standard/DrmLikeOpsSuite.scala | 26 +++++++++---- .../flinkbindings/standard/DrmLikeSuite.scala | 26 +++++++++---- .../standard/RLikeDrmOpsSuite.scala | 19 ++++++++- 6 files changed, 117 insertions(+), 32 deletions(-) diff --git a/flink/pom.xml b/flink/pom.xml index a75c7e24c8..e9b94cf65e 100644 --- a/flink/pom.xml +++ b/flink/pom.xml @@ -132,7 +132,16 @@ flink-clients_${scala.compat.version} ${flink.version} - + + org.apache.flink + flink-test-utils_2.10 + ${flink.version} + + + org.apache.flink + flink-tests_2.10 + ${flink.version} + org.apache.mahout diff --git a/flink/src/test/scala/org/apache/mahout/flinkbindings/DistributedFlinkSuite.scala b/flink/src/test/scala/org/apache/mahout/flinkbindings/DistributedFlinkSuite.scala index 41c7a6aead..480a256e83 100644 --- a/flink/src/test/scala/org/apache/mahout/flinkbindings/DistributedFlinkSuite.scala +++ b/flink/src/test/scala/org/apache/mahout/flinkbindings/DistributedFlinkSuite.scala @@ -18,10 +18,15 @@ */ package org.apache.mahout.flinkbindings +import java.util.concurrent.TimeUnit + import org.apache.flink.api.scala.ExecutionEnvironment +import org.apache.flink.test.util.{ForkableFlinkMiniCluster, TestBaseUtils} import org.apache.mahout.math.drm.DistributedContext import org.apache.mahout.test.DistributedMahoutSuite -import org.scalatest.Suite +import org.scalatest.{ConfigMap, Suite} + +import scala.concurrent.duration.FiniteDuration trait DistributedFlinkSuite extends DistributedMahoutSuite { this: Suite => @@ -29,10 +34,12 @@ trait DistributedFlinkSuite extends DistributedMahoutSuite { this: Suite => protected implicit var mahoutCtx: DistributedContext = _ protected var env: ExecutionEnvironment = null + var cluster: Option[ForkableFlinkMiniCluster] = None + val parallelism = 4 + protected val DEFAULT_AKKA_ASK_TIMEOUT: Long = 1000 + protected var DEFAULT_TIMEOUT: FiniteDuration = new FiniteDuration(DEFAULT_AKKA_ASK_TIMEOUT, TimeUnit.SECONDS) + def initContext() { - env = ExecutionEnvironment.getExecutionEnvironment - // set this higher so that tests like dsqDist(X,Y) have enough available slots to pass on a single machine. - env.setParallelism(10) mahoutCtx = wrapContext(env) } @@ -45,4 +52,26 @@ trait DistributedFlinkSuite extends DistributedMahoutSuite { this: Suite => // env.execute("Mahout Flink Binding Test Suite") } -} \ No newline at end of file + override protected def afterAll(configMap: ConfigMap): Unit = { + super.afterAll(configMap) +// resetContext() + cluster.foreach(c => TestBaseUtils.stopCluster(c, DEFAULT_TIMEOUT)) + } + + override protected def beforeAll(configMap: ConfigMap): Unit = { + super.beforeAll(configMap) + + val cl = TestBaseUtils.startCluster( + 1, + parallelism, + false, + false, + true) + + env = ExecutionEnvironment.createLocalEnvironment(parallelism) + + cluster = Some(cl) + initContext() + } + +} diff --git a/flink/src/test/scala/org/apache/mahout/flinkbindings/standard/DistributedDecompositionsSuite.scala b/flink/src/test/scala/org/apache/mahout/flinkbindings/standard/DistributedDecompositionsSuite.scala index 82ca3ffc73..4256b52746 100644 --- a/flink/src/test/scala/org/apache/mahout/flinkbindings/standard/DistributedDecompositionsSuite.scala +++ b/flink/src/test/scala/org/apache/mahout/flinkbindings/standard/DistributedDecompositionsSuite.scala @@ -1,16 +1,26 @@ +/** + * 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. + */ package org.apache.mahout.flinkbindings.standard import org.apache.mahout.flinkbindings._ -import org.apache.mahout.math._ -import org.apache.mahout.math.drm._ -import org.apache.mahout.math.drm.RLikeDrmOps._ -import org.apache.mahout.math.scalabindings._ -import org.apache.mahout.math.scalabindings.RLikeOps._ -import org.junit.runner.RunWith -import org.scalatest.FunSuite -import org.scalatest.junit.JUnitRunner import org.apache.mahout.math.decompositions.DistributedDecompositionsSuiteBase - +import org.scalatest.FunSuite class DistributedDecompositionsSuite extends FunSuite with DistributedFlinkSuite with DistributedDecompositionsSuiteBase { diff --git a/flink/src/test/scala/org/apache/mahout/flinkbindings/standard/DrmLikeOpsSuite.scala b/flink/src/test/scala/org/apache/mahout/flinkbindings/standard/DrmLikeOpsSuite.scala index 325d118bde..3752187849 100644 --- a/flink/src/test/scala/org/apache/mahout/flinkbindings/standard/DrmLikeOpsSuite.scala +++ b/flink/src/test/scala/org/apache/mahout/flinkbindings/standard/DrmLikeOpsSuite.scala @@ -1,16 +1,26 @@ +/** + * 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. + */ package org.apache.mahout.flinkbindings.standard import org.apache.mahout.flinkbindings._ -import org.apache.mahout.math._ import org.apache.mahout.math.drm._ -import org.apache.mahout.math.drm.RLikeDrmOps._ -import org.apache.mahout.math.scalabindings._ -import org.apache.mahout.math.scalabindings.RLikeOps._ -import org.junit.runner.RunWith import org.scalatest.FunSuite -import org.scalatest.junit.JUnitRunner -import org.apache.mahout.math.decompositions.DistributedDecompositionsSuiteBase - class DrmLikeOpsSuite extends FunSuite with DistributedFlinkSuite with DrmLikeOpsSuiteBase { diff --git a/flink/src/test/scala/org/apache/mahout/flinkbindings/standard/DrmLikeSuite.scala b/flink/src/test/scala/org/apache/mahout/flinkbindings/standard/DrmLikeSuite.scala index dfa7360d82..0a1653b51b 100644 --- a/flink/src/test/scala/org/apache/mahout/flinkbindings/standard/DrmLikeSuite.scala +++ b/flink/src/test/scala/org/apache/mahout/flinkbindings/standard/DrmLikeSuite.scala @@ -1,16 +1,26 @@ +/** + * 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. + */ package org.apache.mahout.flinkbindings.standard import org.apache.mahout.flinkbindings._ -import org.apache.mahout.math._ import org.apache.mahout.math.drm._ -import org.apache.mahout.math.drm.RLikeDrmOps._ -import org.apache.mahout.math.scalabindings._ -import org.apache.mahout.math.scalabindings.RLikeOps._ -import org.junit.runner.RunWith import org.scalatest.FunSuite -import org.scalatest.junit.JUnitRunner -import org.apache.mahout.math.decompositions.DistributedDecompositionsSuiteBase - class DrmLikeSuite extends FunSuite with DistributedFlinkSuite with DrmLikeSuiteBase { diff --git a/flink/src/test/scala/org/apache/mahout/flinkbindings/standard/RLikeDrmOpsSuite.scala b/flink/src/test/scala/org/apache/mahout/flinkbindings/standard/RLikeDrmOpsSuite.scala index c0ff76c123..8bb1b02734 100644 --- a/flink/src/test/scala/org/apache/mahout/flinkbindings/standard/RLikeDrmOpsSuite.scala +++ b/flink/src/test/scala/org/apache/mahout/flinkbindings/standard/RLikeDrmOpsSuite.scala @@ -1,10 +1,27 @@ +/** + * 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. + */ package org.apache.mahout.flinkbindings.standard import org.apache.mahout.flinkbindings._ import org.apache.mahout.math.drm._ import org.scalatest.FunSuite - class RLikeDrmOpsSuite extends FunSuite with DistributedFlinkSuite with RLikeDrmOpsSuiteBase {