Github user vanzin commented on a diff in the pull request: https://github.com/apache/spark/pull/14065#discussion_r72494408 --- Diff: yarn/src/test/scala/org/apache/spark/deploy/yarn/security/HDFSCredentialProviderSuite.scala --- @@ -0,0 +1,106 @@ +/* + * 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.spark.deploy.yarn.security + +import org.apache.hadoop.conf.Configuration +import org.apache.hadoop.fs.Path +import org.scalatest.{Matchers, PrivateMethodTester} + +import org.apache.spark.{SparkConf, SparkException, SparkFunSuite} + +class HDFSCredentialProviderSuite + extends SparkFunSuite + with PrivateMethodTester + with Matchers { + private val _nnsToAccess = PrivateMethod[Set[Path]]('nnsToAccess) + private val _getTokenRenewer = PrivateMethod[String]('getTokenRenewer) + + private def nnsToAccess( + hdfsCredentialProvider: HDFSCredentialProvider, sparkConf: SparkConf): Set[Path] = { + hdfsCredentialProvider invokePrivate _nnsToAccess(sparkConf) + } + + private def getTokenRenewer( + hdfsCredentialProvider: HDFSCredentialProvider, conf: Configuration): String = { + hdfsCredentialProvider invokePrivate _getTokenRenewer(conf) + } + + private var hdfsCredentialProvider: HDFSCredentialProvider = null + + override def beforeAll() { + super.beforeAll() + + if (hdfsCredentialProvider == null) { + hdfsCredentialProvider = new HDFSCredentialProvider() + } + } + + override def afterAll() { + if (hdfsCredentialProvider != null) { + hdfsCredentialProvider = null + } + + super.afterAll() + } + + test("check access nns empty") { + val sparkConf = new SparkConf() + .set("spark.yarn.access.namenodes", "") --- End diff -- I don't see a whole lot of value in these tests; you're basically testing the config parsing code, which is already tested thoroughly in other places. There's no custom parsing going on the HDFS provider code, aside from the transformation from String to Path. If you could instead test that the HDFS provider were actually getting tokens for all NNs that would be great, but I'm not sure you can do that easily with the current test infrastructure (e.g. you'd have to somehow be able to mock the `FileSystem` instance to see if the interesting methods were called).
--- If your project is set up for it, you can reply to this email and have your reply appear on GitHub as well. If your project does not have this feature enabled and wishes so, or if the feature is enabled but not working, please contact infrastructure at infrastruct...@apache.org or file a JIRA ticket with INFRA. --- --------------------------------------------------------------------- To unsubscribe, e-mail: reviews-unsubscr...@spark.apache.org For additional commands, e-mail: reviews-h...@spark.apache.org