Skip to content

Commit

Permalink
Fix CI is not failed when test have errors (#3790)
Browse files Browse the repository at this point in the history
* Fix CI is not failed when test have errors
---

### Motivation

We added the test coverage to report the tests status.
But when we use the code-coverage profile, it will ignore
test failure because we set `<testFailureIgnore>true</testFailureIgnore>`.

We should do the test and test coverage in different steps
and fail the test if there have errors.

* Fix the test errors
  • Loading branch information
zymap authored Feb 21, 2023
1 parent e0fd93a commit 6b6ea76
Show file tree
Hide file tree
Showing 14 changed files with 25 additions and 6 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/bk-ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -434,4 +434,4 @@ jobs:
with:
name: dependency report
path: target/dependency-check-report.html
retention-days: 7
retention-days: 7
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,7 @@
import org.junit.runner.RunWith;
import org.mockito.invocation.InvocationOnMock;
import org.mockito.stubbing.Answer;
import org.powermock.core.classloader.annotations.PowerMockIgnore;
import org.powermock.core.classloader.annotations.PrepareForTest;
import org.powermock.modules.junit4.PowerMockRunner;
import org.powermock.reflect.Whitebox;
Expand All @@ -63,6 +64,7 @@
* Test the bookie journal.
*/
@RunWith(PowerMockRunner.class)
@PowerMockIgnore({"javax.xml.*", "org.xml.*", "org.w3c.*", "javax.xml.*", "com.sun.org.apache.xerces.*"})
@PrepareForTest({JournalChannel.class, Journal.class, DefaultFileChannel.class})
@Slf4j
public class BookieJournalForceTest {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@
import org.junit.Test;
import org.junit.rules.TemporaryFolder;
import org.junit.runner.RunWith;
import org.powermock.core.classloader.annotations.PowerMockIgnore;
import org.powermock.core.classloader.annotations.PrepareForTest;
import org.powermock.modules.junit4.PowerMockRunner;
import org.powermock.reflect.Whitebox;
Expand All @@ -46,6 +47,7 @@
* Test the bookie journal max memory controller.
*/
@RunWith(PowerMockRunner.class)
@PowerMockIgnore({"javax.xml.*", "org.xml.*", "org.w3c.*", "com.sun.org.apache.xerces.*"})
@PrepareForTest({JournalChannel.class, Journal.class})
@Slf4j
public class BookieJournalMaxMemoryTest {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,7 @@
import org.junit.runner.RunWith;
import org.mockito.invocation.InvocationOnMock;
import org.mockito.stubbing.Answer;
import org.powermock.core.classloader.annotations.PowerMockIgnore;
import org.powermock.core.classloader.annotations.PrepareForTest;
import org.powermock.modules.junit4.PowerMockRunner;
import org.powermock.reflect.Whitebox;
Expand All @@ -59,6 +60,7 @@
* Test the bookie journal PageCache flush interval.
*/
@RunWith(PowerMockRunner.class)
@PowerMockIgnore({"javax.xml.*", "org.xml.*", "org.w3c.*", "com.sun.org.apache.xerces.*"})
@PrepareForTest({JournalChannel.class, Journal.class})
@Slf4j
public class BookieJournalPageCacheFlushTest {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,8 @@
*/
@RunWith(PowerMockRunner.class)
@PrepareForTest({JournalChannel.class, FileChannelProvider.class})
@PowerMockIgnore({"jdk.internal.loader.*", "javax.naming.*"})
@PowerMockIgnore({"jdk.internal.loader.*", "javax.xml.*", "org.xml.*", "org.w3c.*",
"com.sun.org.apache.xerces.*", "javax.naming.*"})
public class BookieJournalTest {
private static final Logger LOG = LoggerFactory.getLogger(BookieJournalTest.class);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -67,13 +67,15 @@
import org.junit.Test;
import org.junit.runner.RunWith;
import org.powermock.api.mockito.PowerMockito;
import org.powermock.core.classloader.annotations.PowerMockIgnore;
import org.powermock.core.classloader.annotations.PrepareForTest;
import org.powermock.modules.junit4.PowerMockRunner;

/**
* Unit test for {@link BookieShell}.
*/
@RunWith(PowerMockRunner.class)
@PowerMockIgnore({"com.sun.org.apache.xerces.*", "javax.xml.*", "org.xml.*", "org.w3c.*"})
@PrepareForTest({ BookieShell.class, MetadataDrivers.class, RecoverCommand.class })
public class BookieShellTest {

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,8 @@
*/
@RunWith(PowerMockRunner.class)
@PrepareForTest({BookieImpl.class})
@PowerMockIgnore({"jdk.internal.loader.*", "javax.naming.*"})
@PowerMockIgnore({"jdk.internal.loader.*", "javax.naming.*", "javax.xml.*",
"com.sun.org.apache.xerces.*", "org.w3c.*", "org.xml.*"})
@Slf4j
public class BookieWriteToJournalTest {

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -71,13 +71,15 @@
import org.junit.Test;
import org.junit.rules.TestName;
import org.junit.runner.RunWith;
import org.powermock.core.classloader.annotations.PowerMockIgnore;
import org.powermock.core.classloader.annotations.PrepareForTest;
import org.powermock.modules.junit4.PowerMockRunner;

/**
* Unit test of {@link RegistrationClient}.
*/
@RunWith(PowerMockRunner.class)
@PowerMockIgnore({"javax.xml.*", "org.xml.*", "org.w3c.*", "com.sun.org.apache.xerces.*"})
@PrepareForTest({ ZKRegistrationClient.class, ZkUtils.class })
@Slf4j
public abstract class AbstractTestZkRegistrationClient extends MockZooKeeperTestCase {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,7 @@
* Unit test of {@link AbstractZkLedgerManager}.
*/
@RunWith(PowerMockRunner.class)
@PowerMockIgnore("javax.management.*")
@PowerMockIgnore({"javax.xml.*", "org.xml.*", "org.w3c.*", "com.sun.org.apache.xerces.*"})
@PrepareForTest({ AbstractZkLedgerManager.class, ZkUtils.class })
public class AbstractZkLedgerManagerTest extends MockZooKeeperTestCase {

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,13 +36,15 @@
import org.junit.Test;
import org.junit.runner.RunWith;
import org.powermock.api.mockito.PowerMockito;
import org.powermock.core.classloader.annotations.PowerMockIgnore;
import org.powermock.core.classloader.annotations.PrepareForTest;
import org.powermock.modules.junit4.PowerMockRunner;

/**
* Unit test {@link ZKMetadataBookieDriver}.
*/
@RunWith(PowerMockRunner.class)
@PowerMockIgnore({"javax.xml.*", "org.xml.*", "org.w3c.*", "com.sun.org.apache.xerces.*"})
@PrepareForTest({ ZKMetadataDriverBase.class, ZooKeeperClient.class, ZKMetadataBookieDriver.class })
public class ZKMetadataBookieDriverTest extends ZKMetadataDriverTestBase {

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -40,13 +40,15 @@
import org.junit.Test;
import org.junit.runner.RunWith;
import org.powermock.api.mockito.PowerMockito;
import org.powermock.core.classloader.annotations.PowerMockIgnore;
import org.powermock.core.classloader.annotations.PrepareForTest;
import org.powermock.modules.junit4.PowerMockRunner;

/**
* Unit test {@link ZKMetadataClientDriver}.
*/
@RunWith(PowerMockRunner.class)
@PowerMockIgnore({"javax.xml.*", "org.xml.*", "org.w3c.*", "com.sun.org.apache.xerces.*"})
@PrepareForTest({ ZKMetadataDriverBase.class, ZooKeeperClient.class, ZKMetadataClientDriver.class })
public class ZKMetadataClientDriverTest extends ZKMetadataDriverTestBase {

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -46,13 +46,15 @@
import org.junit.Test;
import org.junit.runner.RunWith;
import org.powermock.api.mockito.PowerMockito;
import org.powermock.core.classloader.annotations.PowerMockIgnore;
import org.powermock.core.classloader.annotations.PrepareForTest;
import org.powermock.modules.junit4.PowerMockRunner;

/**
* Unit test of {@link ZKMetadataDriverBase}.
*/
@RunWith(PowerMockRunner.class)
@PowerMockIgnore({"javax.xml.*", "org.xml.*", "org.w3c.*", "com.sun.org.apache.xerces.*"})
@PrepareForTest({ ZKMetadataDriverBase.class, ZooKeeperClient.class, AbstractZkLedgerManagerFactory.class })
public class ZKMetadataDriverBaseTest extends ZKMetadataDriverTestBase {

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -59,13 +59,15 @@
import org.junit.Test;
import org.junit.runner.RunWith;
import org.powermock.api.mockito.PowerMockito;
import org.powermock.core.classloader.annotations.PowerMockIgnore;
import org.powermock.core.classloader.annotations.PrepareForTest;
import org.powermock.modules.junit4.PowerMockRunner;

/**
* Unit test of {@link EmbeddedServer}.
*/
@RunWith(PowerMockRunner.class)
@PowerMockIgnore({"javax.xml.*", "org.xml.*", "org.w3c.*", "com.sun.org.apache.xerces.*"})
@PrepareForTest({BookieService.class, BookieResources.class, EmbeddedServer.class})
public class TestEmbeddedServer {

Expand Down
3 changes: 1 addition & 2 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -1132,8 +1132,7 @@
<forkCount>${forkCount.variable}</forkCount>
<reuseForks>false</reuseForks>
<forkedProcessTimeoutInSeconds>1800</forkedProcessTimeoutInSeconds>
<!-- we want build to complete even in case of failures -->
<testFailureIgnore>true</testFailureIgnore>
<rerunFailingTestsCount>${testRetryCount}</rerunFailingTestsCount>
</configuration>
</plugin>
<plugin>
Expand Down

0 comments on commit 6b6ea76

Please sign in to comment.