Skip to content

[SPARK-25338][Test] Ensure to call super.beforeAll() and super.afterAll() in test cases - #22337

Closed
kiszk wants to merge 8 commits into
apache:masterfrom
kiszk:SPARK-25338
Closed

[SPARK-25338][Test] Ensure to call super.beforeAll() and super.afterAll() in test cases#22337
kiszk wants to merge 8 commits into
apache:masterfrom
kiszk:SPARK-25338

Conversation

@kiszk

@kiszkkiszk commented Sep 5, 2018

Copy link
Copy Markdown
Member

What changes were proposed in this pull request?

This PR ensures to call super.afterAll() in override afterAll() method for test suites.

  • Some suites did not call super.afterAll()
  • Some suites may call super.afterAll() only under certain condition
  • Others never call super.afterAll().

This PR also ensures to call super.beforeAll() in override beforeAll() for test suites.

How was this patch tested?

Existing UTs

@SparkQA

Copy link
Copy Markdown

Test build #95698 has finished for PR 22337 at commit a429ddb.

  • This patch fails due to an unknown error code, -9.
  • This patch merges cleanly.
  • This patch adds no public classes.

@kiszk

kiszk commented Sep 5, 2018

Copy link
Copy Markdown
MemberAuthor

retest this please

@SparkQA

Copy link
Copy Markdown

Test build #95703 has finished for PR 22337 at commit a429ddb.

  • This patch passes all tests.
  • This patch merges cleanly.
  • This patch adds no public classes.

@dongjoon-hyun

Copy link
Copy Markdown
Member

Hi, @kiszk . Oh, did you check them all? Are these all of them?

@dongjoon-hyundongjoon-hyunSep 6, 2018

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

It seems that we need try...finally for _sc.stop().

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Here, too. Let's use try to make it sure the invocation of super.afterAll().

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

ditto.

@dongjoon-hyun

dongjoon-hyun commented Sep 6, 2018

Copy link
Copy Markdown
Member

Could you check the other suites like ExternalAppendOnlyUnsafeRowArraySuite and TakeOrderedAndProjectSuite, too? Then, we can remove [kafka][kinesis][flume] from the title.

@kiszk

kiszk commented Sep 6, 2018

Copy link
Copy Markdown
MemberAuthor

Sure, I just focused on files under external. Let me address other files, too.

@kiszkkiszk changed the title [SPARK-25338][Test][kafka][kinesis][flume] Ensure to call super.afterAll() in afterAll method in test cases[SPARK-25338][Test] Ensure to call super.afterAll() in afterAll method in test casesSep 6, 2018
@SparkQA

Copy link
Copy Markdown

Test build #95748 has finished for PR 22337 at commit 32db2fc.

  • This patch passes all tests.
  • This patch merges cleanly.
  • This patch adds no public classes.

@kiszk

kiszk commented Sep 6, 2018

Copy link
Copy Markdown
MemberAuthor

cc @dongjoon-hyun

@dongjoon-hyundongjoon-hyunSep 7, 2018

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Oh, this one is beforeAll. Did you check beforeAll, too?

Copy link
Copy Markdown
MemberAuthor

Choose a reason for hiding this comment

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

I see. Let me check beforeAll.

@dongjoon-hyundongjoon-hyunSep 7, 2018

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Is it correct in this test suite context? We usually put super.afterAll() into finally. If there is no reason, let's fix this by switch them.

Copy link
Copy Markdown
MemberAuthor

Choose a reason for hiding this comment

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

In general, I agree with your opinion. I found some exceptional cases like this. Thus, I keep the original order.

Should we keep the original order or try to swap them?

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

IMHO this is clearly an error and we should swap it

@dongjoon-hyundongjoon-hyunSep 7, 2018

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Could you check the history of this too? Is there a reason for this StateStoreRDDSuite to put deleteRecursively at the end? For the other state store suite, super.afterAll is consistently before delete...

Copy link
Copy Markdown
MemberAuthor

Choose a reason for hiding this comment

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

I cannot find other state store suite. Could you please let me know the name of these suites?

I intentionally changed the order since I saw this order (deleteRecursively() ->super.afterAll()) in the following other places.
Since I am neutral on this order, it is ok to keep the original order like

try {
super.afterAll()
} finally {
Utils.deleteRecursively(new File(tempDir))
}
core/src/test/scala/org/apache/spark/rdd/RDDSuite.scala
core/src/test/scala/org/apache/spark/storage/DiskBlockManagerSuite.scala
sql/core/src/test/scala/org/apache/spark/sql/sources/CreateTableAsSelectSuite.scala
sql/core/src/test/scala/org/apache/spark/sql/sources/InsertSuite.scala
mllib/src/test/scala/org/apache/spark/ml/source/libsvm/LibSVMRelationSuite.scala
mllib/src/test/scala/org/apache/spark/ml/util/MLTest.scala
mllib/src/test/scala/org/apache/spark/ml/util/TempDirectory.scala
streaming/src/test/scala/org/apache/spark/streaming/rdd/MapWithStateRDDSuite.scala

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

I prefer your change, too. But, the reason why I asked is that you didn't fix the order in FlatMapGroupsWithStateSuite in this PR. I want to make it sure whether there is a obvious reason or not.

Copy link
Copy Markdown
MemberAuthor

Choose a reason for hiding this comment

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

Sure, let me change the order in FlatMapGroupsWithStateSuite , too.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Ur, are you sure? StreamingAggregationSuite, StreamTest, StreamingAggregationSuite and StreamingDeduplicationSuite also have reverse order for StateStore.stop().

Copy link
Copy Markdown
MemberAuthor

Choose a reason for hiding this comment

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

Hmm, I see. Let me keep the original order as

try {
super.afterAll()
} finally {
Utils.deleteRecursively(...)
}

Thank you for listing them out.

@kiszkkiszk changed the title [SPARK-25338][Test] Ensure to call super.afterAll() in afterAll method in test cases[SPARK-25338][Test] Ensure to call super.beforeAll() and super.afterAll() in test casesSep 7, 2018

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

@kiszk Just wanted to understand. Is there a reason that its not under finally block ?

Copy link
Copy Markdown
MemberAuthor

Choose a reason for hiding this comment

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

Good catch, added try-finally

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

@kiszk same question as above.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

@kiszk Can sc.stop throw an exception ? If so, shouldn't we attempt to do a teardown first before calling super.afterAll() ?

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

I'm confused by your comment, it looks like we try and stop the spark context first. Are you suggesting that we want to tear down kafka test utils even if the Spark stop context fails?

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

@holdenk Please correct me on this one, in my understanding, we do 3 distinct things in the afterAll() method.

1) sc.stop 2) kafkaTestUtils.teardown() 3) super.afterAll()

Currently, even if we fail in (1) or (2) , we will always do (3) as its done in the finally block. My question was , if we fail at (1) , should we do (2) and (3) ? I don't know about the details of the test suite to know for sure if this matters or not. I was just curious.

Copy link
Copy Markdown
MemberAuthor

Choose a reason for hiding this comment

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

sc.stop can throw an exception. Thus, I updated this using nested try-finally.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

@kiszk Can sc.stop throw an exception ? If so, shouldn't we attempt to do a teardown first before calling super.afterAll() ?

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

@kiszk same question as above.

@SparkQA

Copy link
Copy Markdown

Test build #95805 has finished for PR 22337 at commit 45c7a10.

  • This patch passes all tests.
  • This patch merges cleanly.
  • This patch adds no public classes.

@SparkQA

Copy link
Copy Markdown

Test build #95822 has finished for PR 22337 at commit a314776.

  • This patch fails due to an unknown error code, -9.
  • This patch merges cleanly.
  • This patch adds no public classes.

@SparkQA

Copy link
Copy Markdown

Test build #95821 has finished for PR 22337 at commit 6a4cbcf.

  • This patch fails due to an unknown error code, -9.
  • This patch merges cleanly.
  • This patch adds no public classes.

@kiszk

kiszk commented Sep 8, 2018

Copy link
Copy Markdown
MemberAuthor

retest this please

@SparkQA

Copy link
Copy Markdown

Test build #95832 has finished for PR 22337 at commit a314776.

  • This patch fails Spark unit tests.
  • This patch merges cleanly.
  • This patch adds no public classes.

@SparkQA

Copy link
Copy Markdown

Test build #95833 has finished for PR 22337 at commit 309e265.

  • This patch passes all tests.
  • This patch merges cleanly.
  • This patch adds no public classes.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

@kiszk . Let's remove with BeforeAndAfterAll and the whole afterAll(). These are redundant because we fixed afterAll in StreamTest already.

Copy link
Copy Markdown
MemberAuthor

Choose a reason for hiding this comment

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

good catch

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Here, too. Let's remove the redundant with BeforeAndAfterAll and the whole afterAll function.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Here, too. with BeforeAndAfterAll and override def afterAll() are redundant.

@SparkQA

Copy link
Copy Markdown

Test build #95890 has finished for PR 22337 at commit 2d9e34a.

  • This patch fails from timeout after a configured wait of `400m`.
  • This patch merges cleanly.
  • This patch adds the following public classes (experimental):
  • class FlatMapGroupsWithStateSuite extends StateStoreMetricsTest
  • class StreamingAggregationSuite extends StateStoreMetricsTest with Assertions
  • class StreamingDeduplicationSuite extends StateStoreMetricsTest

@kiszk

Copy link
Copy Markdown
MemberAuthor

retest this please

@SparkQA

Copy link
Copy Markdown

Test build #95909 has finished for PR 22337 at commit 2d9e34a.

  • This patch fails Spark unit tests.
  • This patch merges cleanly.
  • This patch adds the following public classes (experimental):
  • class FlatMapGroupsWithStateSuite extends StateStoreMetricsTest
  • class StreamingAggregationSuite extends StateStoreMetricsTest with Assertions
  • class StreamingDeduplicationSuite extends StateStoreMetricsTest

@dongjoon-hyun

Copy link
Copy Markdown
Member

Retest this please.

@SparkQA

Copy link
Copy Markdown

Test build #95917 has finished for PR 22337 at commit 2d9e34a.

  • This patch fails due to an unknown error code, -9.
  • This patch merges cleanly.
  • This patch adds the following public classes (experimental):
  • class FlatMapGroupsWithStateSuite extends StateStoreMetricsTest
  • class StreamingAggregationSuite extends StateStoreMetricsTest with Assertions
  • class StreamingDeduplicationSuite extends StateStoreMetricsTest

@kiszk

Copy link
Copy Markdown
MemberAuthor

retest this please

@SparkQA

Copy link
Copy Markdown

Test build #95938 has finished for PR 22337 at commit 2d9e34a.

  • This patch fails PySpark unit tests.
  • This patch merges cleanly.
  • This patch adds the following public classes (experimental):
  • class FlatMapGroupsWithStateSuite extends StateStoreMetricsTest
  • class StreamingAggregationSuite extends StateStoreMetricsTest with Assertions
  • class StreamingDeduplicationSuite extends StateStoreMetricsTest

@kiszk

Copy link
Copy Markdown
MemberAuthor

retest this please

@dongjoon-hyundongjoon-hyun left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

+1, LGTM.

@SparkQA

ghost commented Sep 11, 2018

Copy link
Copy Markdown

Test build #95958 has finished for PR 22337 at commit 2d9e34a.

  • This patch passes all tests.
  • This patch merges cleanly.
  • This patch adds the following public classes (experimental):
  • class FlatMapGroupsWithStateSuite extends StateStoreMetricsTest
  • class StreamingAggregationSuite extends StateStoreMetricsTest with Assertions
  • class StreamingDeduplicationSuite extends StateStoreMetricsTest

@dongjoon-hyun

ghost commented Sep 12, 2018

Copy link
Copy Markdown
Member

Ur, could you resolve the conflicts, @kiszk ?

@SparkQA

ghost commented Sep 13, 2018

Copy link
Copy Markdown

Test build #96039 has finished for PR 22337 at commit 53d1ba2.

  • This patch passes all tests.
  • This patch merges cleanly.
  • This patch adds the following public classes (experimental):
  • class FlatMapGroupsWithStateSuite extends StateStoreMetricsTest
  • class StreamingAggregationSuite extends StateStoreMetricsTest with Assertions
  • class StreamingDeduplicationSuite extends StateStoreMetricsTest

@dongjoon-hyun

ghost commented Sep 13, 2018

Copy link
Copy Markdown
Member

Thank you, @kiszk .
Merged to master.

Sign up for freeto join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

6 participants

@kiszk@SparkQA@dongjoon-hyun@holdenk@srowen@dilipbiswal