Search in sources :

Example 1 with NETWORK

use of tech.pegasys.teku.infrastructure.metrics.TekuMetricCategory.NETWORK in project teku by ConsenSys.

the class BeaconNodeCommandTest method overrideConfigFileValuesIfKeyIsPresentInCLIOptions.

@Test
public void overrideConfigFileValuesIfKeyIsPresentInCLIOptions() throws IOException {
    final Path configFile = createConfigFile();
    final String[] args = { CONFIG_FILE_OPTION_NAME, configFile.toString(), "--p2p-interface", "1.2.3.5" };
    beaconNodeCommand.parse(args);
    final TekuConfiguration expected = expectedCompleteConfigInFileBuilder().network(n -> n.networkInterface("1.2.3.5")).build();
    assertTekuAndLoggingConfiguration(expected, expectedCompleteConfigInFileLoggingBuilder().build());
}
Also used : Path(java.nio.file.Path) BeforeEach(org.junit.jupiter.api.BeforeEach) PRUNE(tech.pegasys.teku.storage.server.StateStorageMode.PRUNE) URL(java.net.URL) Assertions.assertThat(org.assertj.core.api.Assertions.assertThat) ValidatorPerformanceTrackingMode(tech.pegasys.teku.validator.api.ValidatorPerformanceTrackingMode) OptionalInt(java.util.OptionalInt) StringUtils(org.apache.commons.lang3.StringUtils) ArrayList(java.util.ArrayList) LIBP2P(tech.pegasys.teku.infrastructure.metrics.TekuMetricCategory.LIBP2P) DEFAULT_BOTH(tech.pegasys.teku.infrastructure.logging.LoggingDestination.DEFAULT_BOTH) BEACON(tech.pegasys.teku.infrastructure.metrics.TekuMetricCategory.BEACON) Duration(java.time.Duration) Map(java.util.Map) SLASH(tech.pegasys.teku.cli.OSUtils.SLASH) VersionedDatabaseFactory(tech.pegasys.teku.storage.server.VersionedDatabaseFactory) NETWORK(tech.pegasys.teku.infrastructure.metrics.TekuMetricCategory.NETWORK) LoggingConfigBuilder(tech.pegasys.teku.infrastructure.logging.LoggingConfig.LoggingConfigBuilder) BOTH(tech.pegasys.teku.infrastructure.logging.LoggingDestination.BOTH) FileBackedGraffitiProvider(tech.pegasys.teku.validator.api.FileBackedGraffitiProvider) Path(java.nio.file.Path) CommandLine(picocli.CommandLine) LOG_FILE_PREFIX(tech.pegasys.teku.cli.BeaconNodeCommand.LOG_FILE_PREFIX) Resources(com.google.common.io.Resources) UTF_8(java.nio.charset.StandardCharsets.UTF_8) NatMethod(tech.pegasys.teku.networking.nat.NatMethod) Set(java.util.Set) IOException(java.io.IOException) EVENTBUS(tech.pegasys.teku.infrastructure.metrics.TekuMetricCategory.EVENTBUS) CONFIG_FILE_OPTION_NAME(tech.pegasys.teku.cli.BeaconNodeCommand.CONFIG_FILE_OPTION_NAME) Eth1Address(tech.pegasys.teku.spec.datastructures.eth1.Eth1Address) Test(org.junit.jupiter.api.Test) BeaconRestApiConfig(tech.pegasys.teku.beaconrestapi.BeaconRestApiConfig) PROCESS(org.hyperledger.besu.metrics.StandardMetricCategory.PROCESS) List(java.util.List) TekuConfiguration(tech.pegasys.teku.config.TekuConfiguration) Eth2NetworkConfiguration(tech.pegasys.teku.networks.Eth2NetworkConfiguration) DEFAULT_METRICS_CATEGORIES(tech.pegasys.teku.infrastructure.metrics.MetricsConfig.DEFAULT_METRICS_CATEGORIES) DatabaseVersion(tech.pegasys.teku.storage.server.DatabaseVersion) JVM(org.hyperledger.besu.metrics.StandardMetricCategory.JVM) Optional(java.util.Optional) Pattern(java.util.regex.Pattern) LoggingConfig(tech.pegasys.teku.infrastructure.logging.LoggingConfig) Collections(java.util.Collections) InteropConfig(tech.pegasys.teku.validator.api.InteropConfig) TekuConfiguration(tech.pegasys.teku.config.TekuConfiguration) Test(org.junit.jupiter.api.Test)

Example 2 with NETWORK

use of tech.pegasys.teku.infrastructure.metrics.TekuMetricCategory.NETWORK in project teku by ConsenSys.

the class BeaconNodeCommandTest method overrideConfigFileValuesIfKeyIsPresentInEnvironmentVariables.

@Test
public void overrideConfigFileValuesIfKeyIsPresentInEnvironmentVariables() throws IOException {
    final Path configFile = createConfigFile();
    final String[] args = { CONFIG_FILE_OPTION_NAME, configFile.toString() };
    beaconNodeCommand = new BeaconNodeCommand(outputWriter, errorWriter, Collections.singletonMap("TEKU_P2P_INTERFACE", "1.2.3.5"), startAction, loggingConfigurator);
    beaconNodeCommand.parse(args);
    final TekuConfiguration expected = expectedCompleteConfigInFileBuilder().network(n -> n.networkInterface("1.2.3.5")).build();
    assertTekuAndLoggingConfiguration(expected, expectedCompleteConfigInFileLoggingBuilder().build());
}
Also used : Path(java.nio.file.Path) BeforeEach(org.junit.jupiter.api.BeforeEach) PRUNE(tech.pegasys.teku.storage.server.StateStorageMode.PRUNE) URL(java.net.URL) Assertions.assertThat(org.assertj.core.api.Assertions.assertThat) ValidatorPerformanceTrackingMode(tech.pegasys.teku.validator.api.ValidatorPerformanceTrackingMode) OptionalInt(java.util.OptionalInt) StringUtils(org.apache.commons.lang3.StringUtils) ArrayList(java.util.ArrayList) LIBP2P(tech.pegasys.teku.infrastructure.metrics.TekuMetricCategory.LIBP2P) DEFAULT_BOTH(tech.pegasys.teku.infrastructure.logging.LoggingDestination.DEFAULT_BOTH) BEACON(tech.pegasys.teku.infrastructure.metrics.TekuMetricCategory.BEACON) Duration(java.time.Duration) Map(java.util.Map) SLASH(tech.pegasys.teku.cli.OSUtils.SLASH) VersionedDatabaseFactory(tech.pegasys.teku.storage.server.VersionedDatabaseFactory) NETWORK(tech.pegasys.teku.infrastructure.metrics.TekuMetricCategory.NETWORK) LoggingConfigBuilder(tech.pegasys.teku.infrastructure.logging.LoggingConfig.LoggingConfigBuilder) BOTH(tech.pegasys.teku.infrastructure.logging.LoggingDestination.BOTH) FileBackedGraffitiProvider(tech.pegasys.teku.validator.api.FileBackedGraffitiProvider) Path(java.nio.file.Path) CommandLine(picocli.CommandLine) LOG_FILE_PREFIX(tech.pegasys.teku.cli.BeaconNodeCommand.LOG_FILE_PREFIX) Resources(com.google.common.io.Resources) UTF_8(java.nio.charset.StandardCharsets.UTF_8) NatMethod(tech.pegasys.teku.networking.nat.NatMethod) Set(java.util.Set) IOException(java.io.IOException) EVENTBUS(tech.pegasys.teku.infrastructure.metrics.TekuMetricCategory.EVENTBUS) CONFIG_FILE_OPTION_NAME(tech.pegasys.teku.cli.BeaconNodeCommand.CONFIG_FILE_OPTION_NAME) Eth1Address(tech.pegasys.teku.spec.datastructures.eth1.Eth1Address) Test(org.junit.jupiter.api.Test) BeaconRestApiConfig(tech.pegasys.teku.beaconrestapi.BeaconRestApiConfig) PROCESS(org.hyperledger.besu.metrics.StandardMetricCategory.PROCESS) List(java.util.List) TekuConfiguration(tech.pegasys.teku.config.TekuConfiguration) Eth2NetworkConfiguration(tech.pegasys.teku.networks.Eth2NetworkConfiguration) DEFAULT_METRICS_CATEGORIES(tech.pegasys.teku.infrastructure.metrics.MetricsConfig.DEFAULT_METRICS_CATEGORIES) DatabaseVersion(tech.pegasys.teku.storage.server.DatabaseVersion) JVM(org.hyperledger.besu.metrics.StandardMetricCategory.JVM) Optional(java.util.Optional) Pattern(java.util.regex.Pattern) LoggingConfig(tech.pegasys.teku.infrastructure.logging.LoggingConfig) Collections(java.util.Collections) InteropConfig(tech.pegasys.teku.validator.api.InteropConfig) TekuConfiguration(tech.pegasys.teku.config.TekuConfiguration) Test(org.junit.jupiter.api.Test)

Example 3 with NETWORK

use of tech.pegasys.teku.infrastructure.metrics.TekuMetricCategory.NETWORK in project teku by ConsenSys.

the class MetricsOptionsTest method metricsCategories_shouldAcceptMultipleValues.

@Test
public void metricsCategories_shouldAcceptMultipleValues() {
    TekuConfiguration tekuConfiguration = getTekuConfigurationFromArguments("--metrics-categories", "LIBP2P,NETWORK,EVENTBUS,PROCESS");
    final MetricsConfig config = tekuConfiguration.metricsConfig();
    assertThat(config.getMetricsCategories()).isEqualTo(Set.of(LIBP2P, NETWORK, EVENTBUS, PROCESS));
    assertThat(createConfigBuilder().metrics(b -> b.metricsCategories(Set.of(LIBP2P, NETWORK, EVENTBUS, PROCESS))).build()).usingRecursiveComparison().withComparatorForFields(SET_COMPARATOR, SET_FIELDS).isEqualTo(tekuConfiguration);
}
Also used : Assertions.assertThat(org.assertj.core.api.Assertions.assertThat) Set(java.util.Set) EnumSource(org.junit.jupiter.params.provider.EnumSource) EVENTBUS(tech.pegasys.teku.infrastructure.metrics.TekuMetricCategory.EVENTBUS) MetricsConfig(tech.pegasys.teku.infrastructure.metrics.MetricsConfig) Test(org.junit.jupiter.api.Test) PROCESS(org.hyperledger.besu.metrics.StandardMetricCategory.PROCESS) LIBP2P(tech.pegasys.teku.infrastructure.metrics.TekuMetricCategory.LIBP2P) List(java.util.List) ParameterizedTest(org.junit.jupiter.params.ParameterizedTest) TekuMetricCategory(tech.pegasys.teku.infrastructure.metrics.TekuMetricCategory) StandardMetricCategory(org.hyperledger.besu.metrics.StandardMetricCategory) TekuConfiguration(tech.pegasys.teku.config.TekuConfiguration) JVM(org.hyperledger.besu.metrics.StandardMetricCategory.JVM) NETWORK(tech.pegasys.teku.infrastructure.metrics.TekuMetricCategory.NETWORK) AbstractBeaconNodeCommandTest(tech.pegasys.teku.cli.AbstractBeaconNodeCommandTest) MetricCategory(org.hyperledger.besu.plugin.services.metrics.MetricCategory) Comparator(java.util.Comparator) TekuConfiguration(tech.pegasys.teku.config.TekuConfiguration) MetricsConfig(tech.pegasys.teku.infrastructure.metrics.MetricsConfig) Test(org.junit.jupiter.api.Test) ParameterizedTest(org.junit.jupiter.params.ParameterizedTest) AbstractBeaconNodeCommandTest(tech.pegasys.teku.cli.AbstractBeaconNodeCommandTest)

Example 4 with NETWORK

use of tech.pegasys.teku.infrastructure.metrics.TekuMetricCategory.NETWORK in project teku by ConsenSys.

the class BeaconNodeCommandTest method expectedDefaultConfigurationBuilder.

private TekuConfiguration.Builder expectedDefaultConfigurationBuilder() {
    final Eth2NetworkConfiguration networkConfig = Eth2NetworkConfiguration.builder("mainnet").build();
    return expectedConfigurationBuilder().eth2NetworkConfig(b -> b.applyNetworkDefaults("mainnet")).executionEngine(b -> b.endpoint(null)).powchain(b -> {
        b.depositContract(networkConfig.getEth1DepositContractAddress());
        b.eth1Endpoints(new ArrayList<>()).depositContractDeployBlock(networkConfig.getEth1DepositContractDeployBlock());
    }).storageConfiguration(b -> b.eth1DepositContract(networkConfig.getEth1DepositContractAddress())).metrics(b -> b.metricsCategories(DEFAULT_METRICS_CATEGORIES)).restApi(b -> b.eth1DepositContractAddress(networkConfig.getEth1DepositContractAddress())).p2p(p -> p.peerRateLimit(500).peerRequestLimit(50)).discovery(d -> d.isDiscoveryEnabled(true).listenUdpPort(9000).bootnodes(networkConfig.getDiscoveryBootnodes())).network(n -> n.advertisedPort(OptionalInt.empty()).networkInterface("0.0.0.0").listenPort(9000).privateKeyFile("")).validator(b -> b.validatorKeystoreLockingEnabled(true).validatorPerformanceTrackingMode(ValidatorPerformanceTrackingMode.ALL)).interop(b -> b.interopEnabled(false).interopGenesisTime(0).interopOwnedValidatorCount(0));
}
Also used : BeforeEach(org.junit.jupiter.api.BeforeEach) PRUNE(tech.pegasys.teku.storage.server.StateStorageMode.PRUNE) URL(java.net.URL) Assertions.assertThat(org.assertj.core.api.Assertions.assertThat) ValidatorPerformanceTrackingMode(tech.pegasys.teku.validator.api.ValidatorPerformanceTrackingMode) OptionalInt(java.util.OptionalInt) StringUtils(org.apache.commons.lang3.StringUtils) ArrayList(java.util.ArrayList) LIBP2P(tech.pegasys.teku.infrastructure.metrics.TekuMetricCategory.LIBP2P) DEFAULT_BOTH(tech.pegasys.teku.infrastructure.logging.LoggingDestination.DEFAULT_BOTH) BEACON(tech.pegasys.teku.infrastructure.metrics.TekuMetricCategory.BEACON) Duration(java.time.Duration) Map(java.util.Map) SLASH(tech.pegasys.teku.cli.OSUtils.SLASH) VersionedDatabaseFactory(tech.pegasys.teku.storage.server.VersionedDatabaseFactory) NETWORK(tech.pegasys.teku.infrastructure.metrics.TekuMetricCategory.NETWORK) LoggingConfigBuilder(tech.pegasys.teku.infrastructure.logging.LoggingConfig.LoggingConfigBuilder) BOTH(tech.pegasys.teku.infrastructure.logging.LoggingDestination.BOTH) FileBackedGraffitiProvider(tech.pegasys.teku.validator.api.FileBackedGraffitiProvider) Path(java.nio.file.Path) CommandLine(picocli.CommandLine) LOG_FILE_PREFIX(tech.pegasys.teku.cli.BeaconNodeCommand.LOG_FILE_PREFIX) Resources(com.google.common.io.Resources) UTF_8(java.nio.charset.StandardCharsets.UTF_8) NatMethod(tech.pegasys.teku.networking.nat.NatMethod) Set(java.util.Set) IOException(java.io.IOException) EVENTBUS(tech.pegasys.teku.infrastructure.metrics.TekuMetricCategory.EVENTBUS) CONFIG_FILE_OPTION_NAME(tech.pegasys.teku.cli.BeaconNodeCommand.CONFIG_FILE_OPTION_NAME) Eth1Address(tech.pegasys.teku.spec.datastructures.eth1.Eth1Address) Test(org.junit.jupiter.api.Test) BeaconRestApiConfig(tech.pegasys.teku.beaconrestapi.BeaconRestApiConfig) PROCESS(org.hyperledger.besu.metrics.StandardMetricCategory.PROCESS) List(java.util.List) TekuConfiguration(tech.pegasys.teku.config.TekuConfiguration) Eth2NetworkConfiguration(tech.pegasys.teku.networks.Eth2NetworkConfiguration) DEFAULT_METRICS_CATEGORIES(tech.pegasys.teku.infrastructure.metrics.MetricsConfig.DEFAULT_METRICS_CATEGORIES) DatabaseVersion(tech.pegasys.teku.storage.server.DatabaseVersion) JVM(org.hyperledger.besu.metrics.StandardMetricCategory.JVM) Optional(java.util.Optional) Pattern(java.util.regex.Pattern) LoggingConfig(tech.pegasys.teku.infrastructure.logging.LoggingConfig) Collections(java.util.Collections) InteropConfig(tech.pegasys.teku.validator.api.InteropConfig) ArrayList(java.util.ArrayList) Eth2NetworkConfiguration(tech.pegasys.teku.networks.Eth2NetworkConfiguration)

Example 5 with NETWORK

use of tech.pegasys.teku.infrastructure.metrics.TekuMetricCategory.NETWORK in project teku by ConsenSys.

the class BeaconNodeCommandTest method overrideEnvironmentValuesIfKeyIsPresentInCLIOptions.

@Test
public void overrideEnvironmentValuesIfKeyIsPresentInCLIOptions() {
    final String[] args = createCliArgs();
    args[5] = "1.2.3.5";
    beaconNodeCommand = new BeaconNodeCommand(outputWriter, errorWriter, Collections.singletonMap("TEKU_P2P_INTERFACE", "1.2.3.4"), startAction, loggingConfigurator);
    beaconNodeCommand.parse(args);
    TekuConfiguration expected = expectedConfigurationBuilder().network(n -> n.networkInterface("1.2.3.5")).build();
    assertTekuAndLoggingConfiguration(expected, expectedLoggingBuilder().build());
}
Also used : BeforeEach(org.junit.jupiter.api.BeforeEach) PRUNE(tech.pegasys.teku.storage.server.StateStorageMode.PRUNE) URL(java.net.URL) Assertions.assertThat(org.assertj.core.api.Assertions.assertThat) ValidatorPerformanceTrackingMode(tech.pegasys.teku.validator.api.ValidatorPerformanceTrackingMode) OptionalInt(java.util.OptionalInt) StringUtils(org.apache.commons.lang3.StringUtils) ArrayList(java.util.ArrayList) LIBP2P(tech.pegasys.teku.infrastructure.metrics.TekuMetricCategory.LIBP2P) DEFAULT_BOTH(tech.pegasys.teku.infrastructure.logging.LoggingDestination.DEFAULT_BOTH) BEACON(tech.pegasys.teku.infrastructure.metrics.TekuMetricCategory.BEACON) Duration(java.time.Duration) Map(java.util.Map) SLASH(tech.pegasys.teku.cli.OSUtils.SLASH) VersionedDatabaseFactory(tech.pegasys.teku.storage.server.VersionedDatabaseFactory) NETWORK(tech.pegasys.teku.infrastructure.metrics.TekuMetricCategory.NETWORK) LoggingConfigBuilder(tech.pegasys.teku.infrastructure.logging.LoggingConfig.LoggingConfigBuilder) BOTH(tech.pegasys.teku.infrastructure.logging.LoggingDestination.BOTH) FileBackedGraffitiProvider(tech.pegasys.teku.validator.api.FileBackedGraffitiProvider) Path(java.nio.file.Path) CommandLine(picocli.CommandLine) LOG_FILE_PREFIX(tech.pegasys.teku.cli.BeaconNodeCommand.LOG_FILE_PREFIX) Resources(com.google.common.io.Resources) UTF_8(java.nio.charset.StandardCharsets.UTF_8) NatMethod(tech.pegasys.teku.networking.nat.NatMethod) Set(java.util.Set) IOException(java.io.IOException) EVENTBUS(tech.pegasys.teku.infrastructure.metrics.TekuMetricCategory.EVENTBUS) CONFIG_FILE_OPTION_NAME(tech.pegasys.teku.cli.BeaconNodeCommand.CONFIG_FILE_OPTION_NAME) Eth1Address(tech.pegasys.teku.spec.datastructures.eth1.Eth1Address) Test(org.junit.jupiter.api.Test) BeaconRestApiConfig(tech.pegasys.teku.beaconrestapi.BeaconRestApiConfig) PROCESS(org.hyperledger.besu.metrics.StandardMetricCategory.PROCESS) List(java.util.List) TekuConfiguration(tech.pegasys.teku.config.TekuConfiguration) Eth2NetworkConfiguration(tech.pegasys.teku.networks.Eth2NetworkConfiguration) DEFAULT_METRICS_CATEGORIES(tech.pegasys.teku.infrastructure.metrics.MetricsConfig.DEFAULT_METRICS_CATEGORIES) DatabaseVersion(tech.pegasys.teku.storage.server.DatabaseVersion) JVM(org.hyperledger.besu.metrics.StandardMetricCategory.JVM) Optional(java.util.Optional) Pattern(java.util.regex.Pattern) LoggingConfig(tech.pegasys.teku.infrastructure.logging.LoggingConfig) Collections(java.util.Collections) InteropConfig(tech.pegasys.teku.validator.api.InteropConfig) TekuConfiguration(tech.pegasys.teku.config.TekuConfiguration) Test(org.junit.jupiter.api.Test)

Aggregations

List (java.util.List)5 Set (java.util.Set)5 Assertions.assertThat (org.assertj.core.api.Assertions.assertThat)5 JVM (org.hyperledger.besu.metrics.StandardMetricCategory.JVM)5 PROCESS (org.hyperledger.besu.metrics.StandardMetricCategory.PROCESS)5 Test (org.junit.jupiter.api.Test)5 TekuConfiguration (tech.pegasys.teku.config.TekuConfiguration)5 EVENTBUS (tech.pegasys.teku.infrastructure.metrics.TekuMetricCategory.EVENTBUS)5 LIBP2P (tech.pegasys.teku.infrastructure.metrics.TekuMetricCategory.LIBP2P)5 NETWORK (tech.pegasys.teku.infrastructure.metrics.TekuMetricCategory.NETWORK)5 Resources (com.google.common.io.Resources)4 IOException (java.io.IOException)4 URL (java.net.URL)4 UTF_8 (java.nio.charset.StandardCharsets.UTF_8)4 Path (java.nio.file.Path)4 Duration (java.time.Duration)4 ArrayList (java.util.ArrayList)4 Collections (java.util.Collections)4 Map (java.util.Map)4 Optional (java.util.Optional)4