Github user stefanobaghino commented on the pull request:

    https://github.com/apache/flink/pull/1704#issuecomment-195818369
  
    Thanks for the feedback. Basically the tests so far have been a carbon copy 
of the ones run on the operators I delegate to from the extensions. I agree 
that this approach is a little bit heavy and would like to make it lighter but 
perhaps I can use some help on this.
    
    I've made a few changes that perhaps go in the right direction in my latest 
commit ([source 
here](https://github.com/radicalbit/flink/blob/3e6c58c84c977299d05ef9c9675ecda31368731a/flink-tests/src/test/scala/org/apache/flink/api/scala/extensions/AcceptPFMapITCase.scala)).
    
    Here's a snippet:
    
    ```scala
    class AcceptPFMapITCase extends TestLogger {
    
      private val optimizer = new Optimizer(new Configuration)
      private val unusedResultPath = "UNUSED"
    
      def isTransformation(n: PlanNode): Boolean =
        !n.isInstanceOf[SourcePlanNode] && !n.isInstanceOf[SinkPlanNode]
    
      private def getOptimizerTransformationNodes(env: ExecutionEnvironment): 
Iterable[OptimizerNode] =
        for {
          node <- optimizer.compile(env.createProgramPlan("UNUSED")).getAllNodes
          transformation = node.getOptimizerNode if isTransformation(node)
        } yield transformation
    
      @Test
      def testIdentityMapperWithBasicType(): Unit = {
        val env = ExecutionEnvironment.getExecutionEnvironment
        val ds = CollectionDataSets.getStringDataSet(env)
        val identityMapDs = ds.mapWith(identity)
        identityMapDs.writeAsText(unusedResultPath, WriteMode.OVERWRITE)
        val nodes = getOptimizerTransformationNodes(env)
        assertTrue("The plan should contain 1 transformation", nodes.size == 1)
        assertTrue("The transformation should be a map", 
nodes.forall(_.isInstanceOf[MapNode]))
      }
    
      /* [...] */
    ```
    
    If this approach sounds fine, I can apply it to the other tests as well, 
along with a wider coverage of the extension methods.
    
    Apart from the approach in general, I have a couple of doubts:
    * is it safe to share an `Optimizer` among several tests (i.e. no state 
involved)?
    * is it enough to test the transformation or should I test the input and 
output types as well?


---
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 [email protected] or file a JIRA ticket
with INFRA.
---

Reply via email to