Skip to content
This repository was archived by the owner on Jan 9, 2020. It is now read-only.

Conversation

@mccheah
Copy link

@mccheah mccheah commented Mar 10, 2017

Starting to unit test and harden everything we have so far.

@mccheah
Copy link
Author

mccheah commented Mar 10, 2017

@kimoonkim @ssuchter for review

private val IP_ADDRESS = "192.168.99.100"
private val SSL_SECRET_DIR = s"$DRIVER_CONTAINER_SECRETS_BASE_DIR/$APP_ID-ssl"

private val sslFolder = Files.createTempDirectory("ssl-configuration-provider-suite").toFile
Copy link
Author

@mccheah mccheah Mar 10, 2017

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I couldn't quite find an elegant Scalatest equivalent to JUnit's TemporaryFolder Rule. I wonder if there's a better option than manually setting up the directory. We do this in KubernetesSuite as well.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The current approach looks fine to me. I see many tests in core uses Utils.createTempDir, which is similar to this code:

  /**
   * Create a temporary directory inside the given parent directory. The directory will be
   * automatically deleted when the VM shuts down.
   */
  def createTempDir(
      root: String = System.getProperty("java.io.tmpdir"),
      namePrefix: String = "spark"): File = {
    val dir = createDirectory(root, namePrefix)
    ShutdownHookManager.registerShutdownDeleteDir(dir)
    dir
  }

Here's code snippet from SparkContextSuite:

  test("basic case for addFile and listFiles") {
    val dir = Utils.createTempDir()

    val file1 = File.createTempFile("someprefix1", "somesuffix1", dir)
    val absolutePath1 = file1.getAbsolutePath

Maybe we want to switch to this to be consistent. But, I don't have a strong preference here. i.e. I think it's your call.

Copy link
Member

@kimoonkim kimoonkim left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks great to me.

I don't have much experience with Scala unit test code, but this test code is very easy to read and understand. Thanks for writing this change. @mccheah.

I think it's good to go after addressing minor comments of mine below.

val tempDir = Files.createTempDirectory("temp-ssl-stores").toFile()
val tempDir = Files.createTempDirectory("temp-ssl-stores").toFile
tempDir.deleteOnExit()
tempDir.deleteOnExit()
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No need to call deleteOnExit twice at line 65 and 66?

private val IP_ADDRESS = "192.168.99.100"
private val SSL_SECRET_DIR = s"$DRIVER_CONTAINER_SECRETS_BASE_DIR/$APP_ID-ssl"

private val sslFolder = Files.createTempDirectory("ssl-configuration-provider-suite").toFile
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The current approach looks fine to me. I see many tests in core uses Utils.createTempDir, which is similar to this code:

  /**
   * Create a temporary directory inside the given parent directory. The directory will be
   * automatically deleted when the VM shuts down.
   */
  def createTempDir(
      root: String = System.getProperty("java.io.tmpdir"),
      namePrefix: String = "spark"): File = {
    val dir = createDirectory(root, namePrefix)
    ShutdownHookManager.registerShutdownDeleteDir(dir)
    dir
  }

Here's code snippet from SparkContextSuite:

  test("basic case for addFile and listFiles") {
    val dir = Utils.createTempDir()

    val file1 = File.createTempFile("someprefix1", "somesuffix1", dir)
    val absolutePath1 = file1.getAbsolutePath

Maybe we want to switch to this to be consistent. But, I don't have a strong preference here. i.e. I think it's your call.

@mccheah
Copy link
Author

mccheah commented Mar 10, 2017

Think I want #173 to merge first actually since that PR heavily refactors the class in question.

@ash211
Copy link

ash211 commented Mar 16, 2017

Please rebase onto branch-2.1-kubernetes and send this PR into that branch instead of k8s-support-alternate-incremental which is now deprecated.

@mccheah
Copy link
Author

mccheah commented May 18, 2017

This is likely out of date with V2 submission work.

@mccheah mccheah closed this May 18, 2017
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants