diff options
author | Sun Rui <rui.sun@intel.com> | 2015-12-07 10:38:17 -0800 |
---|---|---|
committer | Shivaram Venkataraman <shivaram@cs.berkeley.edu> | 2015-12-07 10:38:17 -0800 |
commit | 39d677c8f1ee7ebd7e142bec0415cf8f90ac84b6 (patch) | |
tree | a4e8d1cb04e4956d0157819402d88977ab248d89 /R/pkg/inst/tests/testthat/test_broadcast.R | |
parent | 9cde7d5fa87e7ddfff0b9c1212920a1d9000539b (diff) | |
download | spark-39d677c8f1ee7ebd7e142bec0415cf8f90ac84b6.tar.gz spark-39d677c8f1ee7ebd7e142bec0415cf8f90ac84b6.tar.bz2 spark-39d677c8f1ee7ebd7e142bec0415cf8f90ac84b6.zip |
[SPARK-12034][SPARKR] Eliminate warnings in SparkR test cases.
This PR:
1. Suppress all known warnings.
2. Cleanup test cases and fix some errors in test cases.
3. Fix errors in HiveContext related test cases. These test cases are actually not run previously due to a bug of creating TestHiveContext.
4. Support 'testthat' package version 0.11.0 which prefers that test cases be under 'tests/testthat'
5. Make sure the default Hadoop file system is local when running test cases.
6. Turn on warnings into errors.
Author: Sun Rui <rui.sun@intel.com>
Closes #10030 from sun-rui/SPARK-12034.
Diffstat (limited to 'R/pkg/inst/tests/testthat/test_broadcast.R')
-rw-r--r-- | R/pkg/inst/tests/testthat/test_broadcast.R | 48 |
1 files changed, 48 insertions, 0 deletions
diff --git a/R/pkg/inst/tests/testthat/test_broadcast.R b/R/pkg/inst/tests/testthat/test_broadcast.R new file mode 100644 index 0000000000..bb86a5c922 --- /dev/null +++ b/R/pkg/inst/tests/testthat/test_broadcast.R @@ -0,0 +1,48 @@ +# +# 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. +# + +context("broadcast variables") + +# JavaSparkContext handle +sc <- sparkR.init() + +# Partitioned data +nums <- 1:2 +rrdd <- parallelize(sc, nums, 2L) + +test_that("using broadcast variable", { + randomMat <- matrix(nrow=10, ncol=10, data=rnorm(100)) + randomMatBr <- broadcast(sc, randomMat) + + useBroadcast <- function(x) { + sum(SparkR:::value(randomMatBr) * x) + } + actual <- collect(lapply(rrdd, useBroadcast)) + expected <- list(sum(randomMat) * 1, sum(randomMat) * 2) + expect_equal(actual, expected) +}) + +test_that("without using broadcast variable", { + randomMat <- matrix(nrow=10, ncol=10, data=rnorm(100)) + + useBroadcast <- function(x) { + sum(randomMat * x) + } + actual <- collect(lapply(rrdd, useBroadcast)) + expected <- list(sum(randomMat) * 1, sum(randomMat) * 2) + expect_equal(actual, expected) +}) |