spark-reviews mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From JoshRosen <...@git.apache.org>
Subject [GitHub] spark pull request: [SPARK-5341] Use maven coordinates as dependen...
Date Mon, 02 Feb 2015 22:00:12 GMT
Github user JoshRosen commented on a diff in the pull request:

    https://github.com/apache/spark/pull/4215#discussion_r23962899
  
    --- Diff: core/src/test/scala/org/apache/spark/deploy/SparkSubmitUtilsSuite.scala ---
    @@ -0,0 +1,100 @@
    +/*
    + * 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
    +
    +import java.io.File
    +
    +import org.apache.ivy.core.module.descriptor.MDArtifact
    +import org.apache.ivy.plugins.resolver.IBiblioResolver
    +import org.scalatest.FunSuite
    +
    +class SparkSubmitUtilsSuite extends FunSuite {
    +
    +  test("incorrect maven coordinate throws error") {
    +    val coordinates = Seq("a:b: ", " :a:b", "a: :b", "a:b:", ":a:b", "a::b", "::", "a:b",
"a")
    +    for (coordinate <- coordinates) {
    +      intercept[IllegalArgumentException] {
    +        SparkSubmitUtils.extractMavenCoordinates(coordinate)
    +      }
    +    }
    +  }
    +
    +  test("create repo resolvers") {
    +    val resolver1 = SparkSubmitUtils.createRepoResolvers(None)
    +    // should have central by default
    +    assert(resolver1.getResolvers.size() === 1)
    +    assert(resolver1.getResolvers.get(0).asInstanceOf[IBiblioResolver].getName === "central")
    +
    +    val repos = "a/1,b/2,c/3"
    +    val resolver2 = SparkSubmitUtils.createRepoResolvers(Option(repos))
    +    assert(resolver2.getResolvers.size() === 4)
    +    val expected = repos.split(",").map(r => s"$r/")
    +    resolver2.getResolvers.toArray.zipWithIndex.foreach { case (resolver: IBiblioResolver,
i) =>
    +      if (i == 0) {
    +        assert(resolver.getName === "central")
    +      } else {
    +        assert(resolver.getName === s"repo-$i")
    +        assert(resolver.getRoot === expected(i - 1))
    +      }
    +    }
    +  }
    +
    +  test("add dependencies works correctly") {
    +    val md = SparkSubmitUtils.getModuleDescriptor
    +    val artifacts = SparkSubmitUtils.extractMavenCoordinates("com.databricks:spark-csv_2.10:0.1,"
+
    +      "com.databricks:spark-avro_2.10:0.1")
    +
    +    SparkSubmitUtils.addDependenciesToIvy(md, artifacts, "default")
    +    assert(md.getDependencies.length === 2)
    +  }
    +
    +  test("ivy path works correctly") {
    +    val ivyPath = "dummy/ivy"
    +    val md = SparkSubmitUtils.getModuleDescriptor
    +    val artifacts = for (i <- 0 until 3) yield new MDArtifact(md, s"jar-$i", "jar",
"jar")
    +    var jPaths = SparkSubmitUtils.resolveDependencyPaths(artifacts.toArray, new File(ivyPath))
    +    for (i <- 0 until 3) {
    +      val index = jPaths.indexOf(ivyPath)
    +      assert(index >= 0)
    +      jPaths = jPaths.substring(index + ivyPath.length)
    +    }
    +    // end to end
    +    val jarPath = SparkSubmitUtils.resolveMavenCoordinates(
    +      "com.databricks:spark-csv_2.10:0.1", None, Option(ivyPath), true)
    +    assert(jarPath.indexOf(ivyPath) >= 0, "should use non-default ivy path")
    +  }
    +
    +  test("search for artifact at other repositories") {
    +    val path = SparkSubmitUtils.resolveMavenCoordinates("com.agimatec:agimatec-validation:0.9.3",
    +      Option("https://oss.sonatype.org/content/repositories/agimatec/"), None, true)
    +    assert(path.indexOf("agimatec-validation") >= 0, "should find package. If it doesn't,
check" +
    +      "if package still exists. If it has been removed, replace the example in this test.")
    --- End diff --
    
    This is kind of tricky, though, since I guess we do want to test against the actual repository
at some point.


---
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 infrastructure@apache.org or file a JIRA ticket
with INFRA.
---

---------------------------------------------------------------------
To unsubscribe, e-mail: reviews-unsubscribe@spark.apache.org
For additional commands, e-mail: reviews-help@spark.apache.org


Mime
View raw message