Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

bulk update of ATs to junit 5 #6278

Closed
wants to merge 27 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
27 commits
Select commit Hold shift + click to select a range
e3f01bd
permissioning to junit 5
macfarla Dec 7, 2023
d06d2f2
fixed tst
macfarla Dec 7, 2023
e925c1f
fixed tst
macfarla Dec 7, 2023
79bbd95
migrate to junit 5
macfarla Dec 6, 2023
2af4baa
migrate to junit 5
macfarla Dec 6, 2023
caa3299
update privacy tests to junit 5
macfarla Dec 8, 2023
fb7d885
remove remaining junit 4 dependencies
macfarla Dec 8, 2023
fc4f7dc
Merge branch 'main' of github.com:hyperledger/besu into all-ats
macfarla Dec 11, 2023
d00d0de
formatting
macfarla Dec 11, 2023
2d23a5f
revert total removal of junit dep
macfarla Dec 11, 2023
73b0b72
Merge branch 'main' of github.com:hyperledger/besu into all-ats
macfarla Dec 14, 2023
0af7705
change order of tests to run ATs first for diagnosis
macfarla Dec 15, 2023
897ceb4
remove vintage deps
macfarla Dec 15, 2023
742d1d1
add gradle heapdump on oom setting
macfarla Dec 15, 2023
f72e203
migrated testwatcher
macfarla Jan 3, 2024
df59166
Merge branch 'main' of github.com:hyperledger/besu into all-ats
macfarla Jan 3, 2024
116d9bc
renamed to include AcceptanceTest in name
macfarla Jan 3, 2024
0456099
junit5
macfarla Jan 3, 2024
e40a307
removed vintage dep
macfarla Jan 3, 2024
4a58fa2
formatting
macfarla Jan 3, 2024
7a82993
Merge branch 'main' of github.com:hyperledger/besu into all-ats
macfarla Jan 3, 2024
3648c36
copyright
macfarla Jan 3, 2024
4f59f10
rm jupiter
macfarla Jan 3, 2024
91b7bb6
echo args
macfarla Jan 3, 2024
fad4f05
change order of tasks
macfarla Jan 3, 2024
577cb5d
don't use junitPlatform
macfarla Jan 3, 2024
4b7ea35
echo command
macfarla Jan 3, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 12 additions & 8 deletions .circleci/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ executors:
resource_class: xlarge
working_directory: ~/project
environment:
GRADLE_OPTS: -Dorg.gradle.daemon=false -Dorg.gradle.parallel=true -Dorg.gradle.workers.max=4
GRADLE_OPTS: -Dorg.gradle.daemon=false -Dorg.gradle.parallel=true -Dorg.gradle.workers.max=4 -XX:+HeapDumpOnOutOfMemoryError

xl_machine_executor:
machine: #https://circleci.com/developer/machine/image/ubuntu-2204
Expand Down Expand Up @@ -227,7 +227,8 @@ jobs:
| sed 's/.\{5\}$//' \
| circleci tests split --split-by=timings --timings-type=classname)
# Format the arguments to "./gradlew test"
GRADLE_ARGS=$(echo $CLASSNAMES | awk '{for (i=1; i<=NF; i++) print "--tests",$i}')
GRADLE_ARGS=$(echo $CLASSNAMES | awk '{for (i=1; i<=NF; i++) print "--tests",$i}') \
echo "calling gradle w args $GRADLE_ARGS"\
./gradlew --no-daemon acceptanceTestMainnet $GRADLE_ARGS
- capture_test_results
- capture_test_logs
Expand All @@ -239,7 +240,7 @@ jobs:
- attach_workspace:
at: ~/project
- run:
name: AcceptanceTests (Non-Mainnet)
name: AcceptanceTests (Clique + BFT)
no_output_timeout: 20m
command: |
./gradlew --no-daemon acceptanceTestCliqueBft
Expand All @@ -254,7 +255,7 @@ jobs:
- attach_workspace:
at: ~/project
- run:
name: AcceptanceTests (Non-Mainnet)
name: AcceptanceTests (Privacy)
no_output_timeout: 20m
command: |
CLASSNAMES=$(circleci tests glob "acceptance-tests/tests/src/test/java/**/*.java" \
Expand All @@ -263,7 +264,8 @@ jobs:
| sed 's/.\{5\}$//' \
| circleci tests split --split-by=timings --timings-type=classname)
# Format the arguments to "./gradlew test"
GRADLE_ARGS=$(echo $CLASSNAMES | awk '{for (i=1; i<=NF; i++) print "--tests",$i}')
GRADLE_ARGS=$(echo $CLASSNAMES | awk '{for (i=1; i<=NF; i++) print "--tests",$i}') \
echo "calling gradle acceptanceTestPrivacy w args $GRADLE_ARGS"\
./gradlew --no-daemon acceptanceTestPrivacy $GRADLE_ARGS
- capture_test_results
- capture_test_logs
Expand All @@ -275,7 +277,7 @@ jobs:
- attach_workspace:
at: ~/project
- run:
name: AcceptanceTests (Non-Mainnet)
name: AcceptanceTests (Permissioning)
no_output_timeout: 20m
command: |
./gradlew --no-daemon acceptanceTestPermissioning
Expand Down Expand Up @@ -409,12 +411,14 @@ workflows:
- unitTests:
requires:
- assemble
- acceptanceTests
- testWindows:
requires:
- assemble
- referenceTests:
requires:
- assemble
- acceptanceTests
- integrationTests:
requires:
- assemble
Expand All @@ -424,11 +428,11 @@ workflows:
- acceptanceTestsCliqueBft:
requires:
- assemble
- acceptanceTests
- acceptanceTestsPermissioning
- acceptanceTestsPermissioning:
requires:
- acceptanceTests
- assemble
- acceptanceTestsCliqueBft
- buildDocker:
requires:
- assemble
Expand Down
2 changes: 1 addition & 1 deletion acceptance-tests/dsl/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,6 @@ dependencies {
implementation 'info.picocli:picocli'
implementation 'io.reactivex.rxjava2:rxjava'
implementation 'io.vertx:vertx-core'
implementation 'junit:junit'
implementation 'io.opentelemetry:opentelemetry-api'
implementation 'io.tmio:tuweni-bytes'
implementation 'io.tmio:tuweni-io'
Expand All @@ -47,4 +46,5 @@ dependencies {
implementation 'org.web3j:crypto'

implementation 'org.testcontainers:testcontainers'
implementation 'org.junit.jupiter:junit-jupiter'
}
Original file line number Diff line number Diff line change
Expand Up @@ -49,23 +49,19 @@
import org.hyperledger.besu.tests.acceptance.dsl.transaction.web3.Web3Transactions;

import java.io.BufferedReader;
import java.io.File;
import java.io.IOException;
import java.io.InputStreamReader;
import java.lang.ProcessBuilder.Redirect;
import java.math.BigInteger;
import java.util.concurrent.ExecutorService;
import java.util.concurrent.Executors;

import org.junit.After;
import org.junit.Rule;
import org.junit.rules.TestName;
import org.junit.rules.TestWatcher;
import org.junit.runner.Description;
import org.junit.jupiter.api.AfterEach;
import org.junit.jupiter.api.extension.ExtendWith;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.slf4j.MDC;

@ExtendWith(AcceptanceTestBaseTestWatcher.class)
public class AcceptanceTestBase {

private static final Logger LOG = LoggerFactory.getLogger(AcceptanceTestBase.class);
Expand Down Expand Up @@ -131,9 +127,7 @@ protected AcceptanceTestBase() {
exitedSuccessfully = new ExitedWithCode(0);
}

@Rule public final TestName name = new TestName();

@After
@AfterEach
public void tearDownAcceptanceTestBase() {
reportMemory();
cluster.close();
Expand Down Expand Up @@ -178,49 +172,6 @@ private void printOutput(final Process process) {
}
}

@Rule
public TestWatcher logEraser =
new TestWatcher() {

@Override
protected void starting(final Description description) {
MDC.put("test", description.getMethodName());
MDC.put("class", description.getClassName());

final String errorMessage = "Uncaught exception in thread \"{}\"";
Thread.currentThread()
.setUncaughtExceptionHandler(
(thread, error) -> LOG.error(errorMessage, thread.getName(), error));
Thread.setDefaultUncaughtExceptionHandler(
(thread, error) -> LOG.error(errorMessage, thread.getName(), error));
}

@Override
protected void failed(final Throwable e, final Description description) {
// add the result at the end of the log so it is self-sufficient
LOG.error(
"==========================================================================================");
LOG.error("Test failed. Reported Throwable at the point of failure:", e);
LOG.error(e.getMessage());
}

@Override
protected void succeeded(final Description description) {
// if so configured, delete logs of successful tests
if (!Boolean.getBoolean("acctests.keepLogsOfPassingTests")) {
String pathname =
"build/acceptanceTestLogs/"
+ description.getClassName()
+ "."
+ description.getMethodName()
+ ".log";
LOG.info("Test successful, deleting log at {}", pathname);
File file = new File(pathname);
file.delete();
}
}
};

protected void waitForBlockHeight(final Node node, final long blockchainHeight) {
WaitUtils.waitFor(
120,
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,61 @@
/*
* Copyright contributors to Hyperledger Besu.
*
* Licensed 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.
*
* SPDX-License-Identifier: Apache-2.0
*/

package org.hyperledger.besu.tests.acceptance.dsl;

import java.io.File;
import java.util.Optional;

import org.junit.jupiter.api.extension.ExtensionContext;
import org.junit.jupiter.api.extension.TestWatcher;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

public class AcceptanceTestBaseTestWatcher implements TestWatcher {
private static final Logger LOG = LoggerFactory.getLogger(AcceptanceTestBaseTestWatcher.class);

@Override
public void testAborted(final ExtensionContext extensionContext, final Throwable throwable) {
LOG.info("test aborted:" + extensionContext.getDisplayName());
}

@Override
public void testDisabled(
final ExtensionContext extensionContext, final Optional<String> optional) {
LOG.info("test disabled:" + extensionContext.getDisplayName());
}

@Override
public void testFailed(final ExtensionContext extensionContext, final Throwable e) {
// add the result at the end of the log, so it is self-sufficient
LOG.error(
"==========================================================================================");
LOG.error("Test failed. Reported Throwable at the point of failure:", e);
LOG.error(e.getMessage());
}

@Override
public void testSuccessful(final ExtensionContext extensionContext) {
// TODO where is the other side of this - what creates these log files?

// if so configured, delete logs of successful tests
if (!Boolean.getBoolean("acctests.keepLogsOfPassingTests")) {
String pathname = "build/acceptanceTestLogs/" + extensionContext.getDisplayName() + ".log";
LOG.info("Test successful, deleting log at {}", pathname);
File file = new File(pathname);
file.delete();
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -25,43 +25,26 @@
import org.hyperledger.besu.tests.acceptance.dsl.privacy.transaction.RestrictedCreatePrivacyGroupTransaction;
import org.hyperledger.besu.tests.acceptance.dsl.transaction.Transaction;
import org.hyperledger.enclave.testutil.EnclaveEncryptorType;
import org.hyperledger.enclave.testutil.EnclaveType;

import java.util.Arrays;
import java.util.Collection;
import java.util.stream.Stream;

import org.junit.runner.RunWith;
import org.junit.runners.Parameterized;
import org.junit.runners.Parameterized.Parameters;
import org.junit.jupiter.params.provider.Arguments;
import org.web3j.utils.Restriction;

@RunWith(Parameterized.class)
public abstract class ParameterizedEnclaveTestBase extends PrivacyAcceptanceTestBase {
protected final Restriction restriction;
protected final EnclaveType enclaveType;
protected final EnclaveEncryptorType enclaveEncryptorType;

protected ParameterizedEnclaveTestBase(
final Restriction restriction,
final EnclaveType enclaveType,
final EnclaveEncryptorType enclaveEncryptorType) {
this.restriction = restriction;
this.enclaveType = enclaveType;
this.enclaveEncryptorType = enclaveEncryptorType;
}

@Parameters(name = "{0} tx with {1} enclave and {2} encryptor type")
public static Collection<Object[]> params() {
return Arrays.asList(
new Object[][] {
{RESTRICTED, TESSERA, NACL},
{RESTRICTED, TESSERA, EC},
{UNRESTRICTED, NOOP, EnclaveEncryptorType.NOOP}
});
public static Stream<Arguments> params() {
return Stream.of(
Arguments.of(RESTRICTED, TESSERA, NACL),
Arguments.of(RESTRICTED, TESSERA, EC),
Arguments.of(UNRESTRICTED, NOOP, EnclaveEncryptorType.NOOP));
}

public Transaction<String> createPrivacyGroup(
final String name, final String description, final PrivacyNode... nodes) {
final Restriction restriction,
final String name,
final String description,
final PrivacyNode... nodes) {

if (restriction == RESTRICTED) {
return new RestrictedCreatePrivacyGroupTransaction(name, description, nodes);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,12 +32,9 @@
import java.math.BigInteger;

import io.vertx.core.Vertx;
import org.junit.After;
import org.junit.ClassRule;
import org.junit.rules.TemporaryFolder;
import org.junit.jupiter.api.AfterEach;

public class PrivacyAcceptanceTestBase {
@ClassRule public static final TemporaryFolder privacy = new TemporaryFolder();

protected final PrivacyTransactions privacyTransactions;
protected final PrivateContractVerifier privateContractVerifier;
Expand Down Expand Up @@ -77,7 +74,7 @@ protected void waitForBlockHeight(final PrivacyNode node, final long blockchainH
.isGreaterThanOrEqualTo(BigInteger.valueOf(blockchainHeight)));
}

@After
@AfterEach
public void tearDownAcceptanceTestBase() {
privacyCluster.close();
vertx.close();
Expand Down
2 changes: 0 additions & 2 deletions acceptance-tests/test-plugins/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,6 @@ dependencies {

testImplementation 'org.assertj:assertj-core'
testImplementation 'org.junit.jupiter:junit-jupiter'

testRuntimeOnly 'org.junit.vintage:junit-vintage-engine'
}

task testPluginsJar(type: Jar) {
Expand Down
Loading
Loading