unit-test for scalding when Stat with implict com.twitter.scalding.UniqueID used

83 views
Skip to first unread message

Serega Sheypak

unread,
Jul 28, 2015, 3:58:56 AM7/28/15
to cascading-user
Hi, I'm trying to write unit-tests for my traits with logic.
Trait methods use Stat object to count some stuff.
Here is a signature for the method:

def complexPipeCalculation()(implicit u: UniqueID): Pipe = {
///
}

Code compiles well, but tests don't scala require defenition for that implicit "u" 
what is the right way to provide that defenition in test?

Serega Sheypak

unread,
Jul 28, 2015, 6:39:43 AM7/28/15
to cascading-user
Okay, I found a way to compile it, I just passed random UniqueID as implicit value.
Now I'm getting:

Caused by: java.lang.RuntimeException: Error in job deployment, the FlowProcess for unique id UniqueID(1507929974409003008) isn't available
at scala.sys.package$.error(package.scala:27)
at com.twitter.scalding.RuntimeStats$$anonfun$getFlowProcessForUniqueId$2.apply(Stats.scala:121)
at com.twitter.scalding.RuntimeStats$$anonfun$getFlowProcessForUniqueId$2.apply(Stats.scala:121)
at scala.Option.getOrElse(Option.scala:121)
at com.twitter.scalding.RuntimeStats$.getFlowProcessForUniqueId(Stats.scala:120)
at com.twitter.scalding.Stat$$anon$1.flowProcess$lzycompute(Stats.scala:49)
at com.twitter.scalding.Stat$$anon$1.flowProcess(Stats.scala:49)
at com.twitter.scalding.Stat$$anon$1.incBy(Stats.scala:51)

Tried this in test:

@RunWith(classOf[JUnitRunner])
class MyTraitTest extends FunSuite
                  with Matchers
                  with BddDsl{

  implicit val flowDef: FlowDef = FlowDef.flowDef().setRunID("1")
  val flow: FlowDef = implicitly[FlowDef]
  flow.setRunID("1")

test("Geometric intersection of 2 square polygons") {
    val input = List(/* some input here */)

    Given {
      new MySource(input) withSchema List("someField")
    } When {
      (pipe: Pipe) => pipe.calculateWithCountersInside()(u=UniqueID.getRandom)
    } Then {
      //verify that stuff
    }
  }

Tried to u=UniqueID.getRandom change 
  (pipe: Pipe) => pipe.calculateWithCountersInside()(u=UniqueID.getRandom)
to
  (pipe: Pipe) => pipe.calculateWithCountersInside()(u=UniqueID.getIDFor)
or
 (pipe: Pipe) => pipe.calculateWithCountersInside()(u=UniqueID.getIDFor(flow))

no luck...

--
You received this message because you are subscribed to a topic in the Google Groups "cascading-user" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/cascading-user/ilgqtK4pAZI/unsubscribe.
To unsubscribe from this group and all its topics, send an email to cascading-use...@googlegroups.com.
To post to this group, send email to cascadi...@googlegroups.com.
Visit this group at http://groups.google.com/group/cascading-user.
To view this discussion on the web visit https://groups.google.com/d/msgid/cascading-user/659c986b-1bbf-486b-984e-2a97d0979bc0%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply all
Reply to author
Forward
0 new messages