Skip to content

Commit

Permalink
Add Traces.initialize to all tests
Browse files Browse the repository at this point in the history
Signed-off-by: Antoine Toulme <[email protected]>
  • Loading branch information
atoulme committed Oct 21, 2021
1 parent 9e2d029 commit 3b8cc32
Show file tree
Hide file tree
Showing 6 changed files with 24 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@
import org.hyperledger.fabric.metrics.Metrics;
import org.hyperledger.fabric.protos.peer.ChaincodeShim;
import org.hyperledger.fabric.shim.chaincode.EmptyChaincode;
import org.hyperledger.fabric.traces.Traces;
import org.junit.Ignore;
import org.junit.Rule;
import org.junit.Test;
Expand Down Expand Up @@ -299,6 +300,7 @@ public void connectChaincodeBase() throws IOException {

final Properties props = cb.getChaincodeConfig();
Metrics.initialize(props);
Traces.initialize(props);

cb.connectToPeer(new StreamObserver<ChaincodeShim.ChaincodeMessage>() {
@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
import org.hyperledger.fabric.protos.peer.ChaincodeShim;
import org.hyperledger.fabric.shim.chaincode.EmptyChaincode;
import org.hyperledger.fabric.shim.utils.MessageUtil;
import org.hyperledger.fabric.traces.Traces;
import org.junit.Rule;
import org.junit.contrib.java.lang.system.EnvironmentVariables;
import org.junit.jupiter.api.AfterEach;
Expand Down Expand Up @@ -103,6 +104,7 @@ void initEmptyId() throws IOException {

Properties props = chaincodeBase.getChaincodeConfig();
Metrics.initialize(props);
Traces.initialize(props);
ChatChaincodeWithPeer chatChaincodeWithPeer = new ChatChaincodeWithPeer(chaincodeBase);
},
"chaincode id not set, set env 'CORE_CHAINCODE_ID_NAME', for example 'CORE_CHAINCODE_ID_NAME=mycc'"
Expand Down Expand Up @@ -130,7 +132,7 @@ void connectNull() throws IOException {

Properties props = chaincodeBase.getChaincodeConfig();
Metrics.initialize(props);

Traces.initialize(props);
ChatChaincodeWithPeer chatChaincodeWithPeer = new ChatChaincodeWithPeer(chaincodeBase);
assertNull(chatChaincodeWithPeer.connect(null));
}
Expand All @@ -143,6 +145,7 @@ void connectAndReceiveRegister() throws IOException {
chaincodeBase.validateOptions();

Properties props = chaincodeBase.getChaincodeConfig();
Traces.initialize(props);
Metrics.initialize(props);

ChatChaincodeWithPeer chatChaincodeWithPeer = new ChatChaincodeWithPeer(chaincodeBase);
Expand Down Expand Up @@ -213,6 +216,7 @@ void connectAndReceiveRegisterComplete() throws IOException {
chaincodeBase.validateOptions();

Properties props = chaincodeBase.getChaincodeConfig();
Traces.initialize(props);
Metrics.initialize(props);

ChatChaincodeWithPeer chatChaincodeWithPeer = new ChatChaincodeWithPeer(chaincodeBase);
Expand Down Expand Up @@ -243,6 +247,7 @@ void connectAndReceiveRegisterException() throws IOException {
chaincodeBase.validateOptions();

Properties props = chaincodeBase.getChaincodeConfig();
Traces.initialize(props);
Metrics.initialize(props);

ChatChaincodeWithPeer chatChaincodeWithPeer = new ChatChaincodeWithPeer(chaincodeBase);
Expand Down Expand Up @@ -271,6 +276,7 @@ void connectOnCompletedException() throws IOException {

Properties props = chaincodeBase.getChaincodeConfig();
Metrics.initialize(props);
Traces.initialize(props);

ChatChaincodeWithPeer chatChaincodeWithPeer = new ChatChaincodeWithPeer(chaincodeBase);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@

import org.hyperledger.fabric.metrics.Metrics;
import org.hyperledger.fabric.shim.chaincode.EmptyChaincode;
import org.hyperledger.fabric.traces.Traces;
import org.junit.Rule;
import org.junit.contrib.java.lang.system.EnvironmentVariables;
import org.junit.jupiter.api.AfterEach;
Expand Down Expand Up @@ -221,6 +222,7 @@ void initEnvSetPortChaincodeServerAndCoreChaincodeIdName() throws IOException {

Properties props = chaincodeBase.getChaincodeConfig();
Metrics.initialize(props);
Traces.initialize(props);

ChaincodeServer chaincodeServer = new NettyChaincodeServer(chaincodeBase, new ChaincodeServerProperties());

Expand All @@ -235,6 +237,7 @@ void startAndStopSetCoreChaincodeIdName() {
chaincodeBase.processEnvironmentOptions();
Properties props = chaincodeBase.getChaincodeConfig();
Metrics.initialize(props);
Traces.initialize(props);

ChaincodeServer chaincodeServer = new NettyChaincodeServer(chaincodeBase, new ChaincodeServerProperties());
new Thread(() -> {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
import org.hyperledger.fabric.protos.peer.ChaincodeShim;
import org.hyperledger.fabric.shim.ChaincodeBase;
import org.hyperledger.fabric.shim.chaincode.EmptyChaincode;
import org.hyperledger.fabric.traces.Traces;
import org.junit.Rule;
import org.junit.contrib.java.lang.system.EnvironmentVariables;
import org.junit.jupiter.api.Assertions;
Expand All @@ -33,6 +34,7 @@ void testStartInvocationTaskManagerAndRequestObserverNull() throws IOException {

Properties props = chaincodeBase.getChaincodeConfig();
Metrics.initialize(props);
Traces.initialize(props);

final ManagedChannelBuilder<?> managedChannelBuilder = chaincodeBase.newChannelBuilder();
ChaincodeSupportClient chaincodeSupportClient = new ChaincodeSupportClient(managedChannelBuilder);
Expand Down Expand Up @@ -60,6 +62,7 @@ void testStartInvocationTaskManagerNullAndRequestObserver() throws IOException {

Properties props = chaincodeBase.getChaincodeConfig();
Metrics.initialize(props);
Traces.initialize(props);

final ManagedChannelBuilder<?> managedChannelBuilder = chaincodeBase.newChannelBuilder();
ChaincodeSupportClient chaincodeSupportClient = new ChaincodeSupportClient(managedChannelBuilder);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,7 @@ void getManagerChaincodeIDNull() throws IOException {

Properties props = chaincodeBase.getChaincodeConfig();
Metrics.initialize(props);
Traces.initialize(props);

Assertions.assertThrows(
IllegalArgumentException.class, () -> {
Expand Down Expand Up @@ -105,6 +106,7 @@ void onChaincodeMessage() throws IOException {

Properties props = chaincodeBase.getChaincodeConfig();
Metrics.initialize(props);
Traces.initialize(props);

final Chaincode.ChaincodeID chaincodeId = Chaincode.ChaincodeID.newBuilder().setName("chaincodeIdNumber12345").build();
final InvocationTaskManager itm = InvocationTaskManager.getManager(chaincodeBase, chaincodeId);
Expand All @@ -124,6 +126,7 @@ void setResponseConsumer() throws IOException {

Properties props = chaincodeBase.getChaincodeConfig();
Metrics.initialize(props);
Traces.initialize(props);

final Chaincode.ChaincodeID chaincodeId = Chaincode.ChaincodeID.newBuilder().setName("chaincodeIdNumber12345").build();
final InvocationTaskManager itm = InvocationTaskManager.getManager(chaincodeBase, chaincodeId);
Expand All @@ -139,6 +142,7 @@ void registerException() {

Properties props = chaincodeBase.getChaincodeConfig();
Metrics.initialize(props);
Traces.initialize(props);

final Chaincode.ChaincodeID chaincodeId = Chaincode.ChaincodeID.newBuilder().setName("chaincodeIdNumber12345").build();
final InvocationTaskManager itm = InvocationTaskManager.getManager(chaincodeBase, chaincodeId);
Expand All @@ -159,6 +163,7 @@ void onChaincodeMessageREGISTER() {

Properties props = chaincodeBase.getChaincodeConfig();
Metrics.initialize(props);
Traces.initialize(props);

final Chaincode.ChaincodeID chaincodeId = Chaincode.ChaincodeID.newBuilder().setName("chaincodeIdNumber12345").build();
final InvocationTaskManager itm = InvocationTaskManager.getManager(chaincodeBase, chaincodeId);
Expand All @@ -180,6 +185,7 @@ void onChaincodeMessageInvokeChaincode() {

Properties props = chaincodeBase.getChaincodeConfig();
Metrics.initialize(props);
Traces.initialize(props);

final String chaincodeIdNumber = "chaincodeIdNumber12345";
final Chaincode.ChaincodeID chaincodeId = Chaincode.ChaincodeID.newBuilder().setName(chaincodeIdNumber).build();
Expand All @@ -203,6 +209,7 @@ void onChaincodeMessagePutState() {

Properties props = chaincodeBase.getChaincodeConfig();
Metrics.initialize(props);
Traces.initialize(props);

final String chaincodeIdNumber = "chaincodeIdNumber12345";
final Chaincode.ChaincodeID chaincodeId = Chaincode.ChaincodeID.newBuilder().setName(chaincodeIdNumber).build();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
import org.hyperledger.fabric.protos.peer.Chaincode.ChaincodeID;
import org.hyperledger.fabric.protos.peer.ChaincodeShim.ChaincodeMessage;
import org.hyperledger.fabric.shim.ChaincodeBase;
import org.hyperledger.fabric.traces.Traces;
import org.junit.jupiter.api.AfterEach;
import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Test;
Expand All @@ -33,6 +34,7 @@ public final class InvocationTaskManagerTest {
@BeforeEach
public void setup() {
Metrics.initialize(new Properties());
Traces.initialize(new Properties());

chaincode = Mockito.mock(ChaincodeBase.class);
final ChaincodeID id = ChaincodeID.newBuilder().setName("randomname").build();
Expand Down

0 comments on commit 3b8cc32

Please sign in to comment.