-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
test: Add E2E test and enhance simulator flexibility (#330)
This PR adds new functionality aimed at making the simulator a better and more flexible test driver for E2E tests. It achieves this by: - Adding a new StreamStatus data object, which collects and stores information about the recently published/consumed blocks, as well as the latest statuses. - Exposing the necessary methods to make this usable in other modules, primarily the E2E Tests module. - Adding a new E2E test that covers the positive scenario where the simulator sends blocks to the Block Node, which responds with the correct response. - Adds a new CustomThreadPoolExecutor to handle simulator threads, for now I'm just handling thrown errors, but in the future we might extend, depending on our needs. Signed-off-by: georgi-l95 <[email protected]>
- Loading branch information
1 parent
256d486
commit 46ad591
Showing
26 changed files
with
1,027 additions
and
75 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -9,6 +9,7 @@ | |
|
||
# Mobile Tools for Java (J2ME) | ||
.mtj.tmp/ | ||
bin/ | ||
|
||
# Package Files # | ||
*.jar | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
122 changes: 122 additions & 0 deletions
122
simulator/src/main/java/com/hedera/block/simulator/config/data/StreamStatus.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,122 @@ | ||
/* | ||
* Copyright (C) 2024 Hedera Hashgraph, LLC | ||
* | ||
* 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. | ||
*/ | ||
|
||
package com.hedera.block.simulator.config.data; | ||
|
||
import static com.hedera.block.common.utils.Preconditions.requireWhole; | ||
import static java.util.Objects.requireNonNull; | ||
|
||
import java.util.ArrayList; | ||
import java.util.List; | ||
|
||
/** | ||
* Represents the status of the stream. | ||
* | ||
* @param publishedBlocks the number of published blocks | ||
* @param consumedBlocks the number of consumed blocks | ||
* @param lastKnownPublisherStatuses the last known publisher statuses | ||
* @param lastKnownConsumersStatuses the last known consumers statuses | ||
*/ | ||
public record StreamStatus( | ||
long publishedBlocks, | ||
long consumedBlocks, | ||
List<String> lastKnownPublisherStatuses, | ||
List<String> lastKnownConsumersStatuses) { | ||
|
||
/** | ||
* Creates a new {@link Builder} instance for constructing a {@code StreamStatus}. | ||
* | ||
* @return a new {@code Builder} | ||
*/ | ||
public static Builder builder() { | ||
return new Builder(); | ||
} | ||
|
||
/** | ||
* A builder for creating instances of {@link StreamStatus}. | ||
*/ | ||
public static class Builder { | ||
private long publishedBlocks = 0; | ||
private long consumedBlocks = 0; | ||
private List<String> lastKnownPublisherStatuses = new ArrayList<>(); | ||
private List<String> lastKnownConsumersStatuses = new ArrayList<>(); | ||
|
||
/** | ||
* Creates a new instance of the {@code Builder} class with default configuration values. | ||
*/ | ||
public Builder() { | ||
// Default constructor | ||
} | ||
|
||
/** | ||
* Sets the number of published blocks. | ||
* | ||
* @param publishedBlocks the number of published blocks | ||
* @return the builder instance | ||
*/ | ||
public Builder publishedBlocks(long publishedBlocks) { | ||
requireWhole(publishedBlocks); | ||
this.publishedBlocks = publishedBlocks; | ||
return this; | ||
} | ||
|
||
/** | ||
* Sets the number of consumed blocks. | ||
* | ||
* @param consumedBlocks the number of consumed blocks | ||
* @return the builder instance | ||
*/ | ||
public Builder consumedBlocks(long consumedBlocks) { | ||
requireWhole(consumedBlocks); | ||
this.consumedBlocks = consumedBlocks; | ||
return this; | ||
} | ||
|
||
/** | ||
* Sets the last known publisher statuses. | ||
* | ||
* @param lastKnownPublisherStatuses the last known publisher statuses | ||
* @return the builder instance | ||
*/ | ||
public Builder lastKnownPublisherStatuses(List<String> lastKnownPublisherStatuses) { | ||
requireNonNull(lastKnownPublisherStatuses); | ||
this.lastKnownPublisherStatuses = new ArrayList<>(lastKnownPublisherStatuses); | ||
return this; | ||
} | ||
|
||
/** | ||
* Sets the last known consumers statuses. | ||
* | ||
* @param lastKnownConsumersStatuses the last known consumers statuses | ||
* @return the builder instance | ||
*/ | ||
public Builder lastKnownConsumersStatuses(List<String> lastKnownConsumersStatuses) { | ||
requireNonNull(lastKnownConsumersStatuses); | ||
this.lastKnownConsumersStatuses = new ArrayList<>(lastKnownConsumersStatuses); | ||
return this; | ||
} | ||
|
||
/** | ||
* Builds a new {@link StreamStatus} instance. | ||
* | ||
* @return a new {@link StreamStatus} instance | ||
*/ | ||
public StreamStatus build() { | ||
return new StreamStatus( | ||
publishedBlocks, consumedBlocks, lastKnownPublisherStatuses, lastKnownConsumersStatuses); | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.