-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #241 from solarwinds/NH-67051-add-configure-tests
NH-67051 Add configurator._configure_otel_components tests
- Loading branch information
Showing
3 changed files
with
239 additions
and
1 deletion.
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
58 changes: 58 additions & 0 deletions
58
tests/unit/test_configurator/test_configurator_configure.py
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,58 @@ | ||
# © 2023 SolarWinds Worldwide, LLC. All rights reserved. | ||
# | ||
# 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. | ||
|
||
from solarwinds_apm import configurator | ||
|
||
class TestConfiguratorConfigure: | ||
def test_configurator_configure( | ||
mocker, | ||
mock_txn_name_manager_init, | ||
mock_fwkv_manager_init, | ||
mock_apmconfig_enabled, | ||
mock_meter_manager_init, | ||
mock_noop_meter_manager_init, | ||
mock_init_sw_reporter, | ||
mock_config_otel_components, | ||
mock_report_init, | ||
): | ||
test_configurator = configurator.SolarWindsConfigurator() | ||
test_configurator._configure() | ||
|
||
mock_txn_name_manager_init.assert_called_once() | ||
mock_fwkv_manager_init.assert_called_once() | ||
mock_apmconfig_enabled.assert_called_once() | ||
|
||
mock_noop_meter_manager_init.assert_called_once() | ||
mock_meter_manager_init.assert_not_called() | ||
|
||
mock_init_sw_reporter.assert_called_once() | ||
mock_config_otel_components.assert_called_once() | ||
mock_report_init.assert_called_once() | ||
|
||
def test_configurator_configure_experimental( | ||
mocker, | ||
mock_txn_name_manager_init, | ||
mock_fwkv_manager_init, | ||
mock_apmconfig_experimental_otelcol_init, | ||
mock_meter_manager_init, | ||
mock_noop_meter_manager_init, | ||
mock_init_sw_reporter, | ||
mock_config_otel_components, | ||
mock_report_init, | ||
): | ||
test_configurator = configurator.SolarWindsConfigurator() | ||
test_configurator._configure() | ||
|
||
mock_txn_name_manager_init.assert_called_once() | ||
mock_fwkv_manager_init.assert_called_once() | ||
mock_apmconfig_experimental_otelcol_init.assert_called_once() | ||
|
||
mock_meter_manager_init.assert_called_once() | ||
mock_noop_meter_manager_init.assert_not_called() | ||
|
||
mock_init_sw_reporter.assert_called_once() | ||
mock_config_otel_components.assert_called_once() | ||
mock_report_init.assert_called_once() |
82 changes: 82 additions & 0 deletions
82
tests/unit/test_configurator/test_configurator_configure_otel.py
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,82 @@ | ||
# © 2023 SolarWinds Worldwide, LLC. All rights reserved. | ||
# | ||
# 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. | ||
|
||
from solarwinds_apm import configurator | ||
|
||
class TestConfiguratorConfigureOtelComponents: | ||
def test_configure_otel_components_agent_enabled( | ||
mocker, | ||
mock_txn_name_manager, | ||
mock_fwkv_manager, | ||
mock_meter_manager, | ||
mock_extension, | ||
mock_apmconfig_enabled, | ||
|
||
mock_config_inbound_processor, | ||
mock_config_otlp_processor, | ||
mock_config_traces_exp, | ||
mock_config_metrics_exp, | ||
mock_config_propagator, | ||
mock_config_response_propagator, | ||
): | ||
test_configurator = configurator.SolarWindsConfigurator() | ||
test_configurator._configure_otel_components( | ||
mock_txn_name_manager, | ||
mock_fwkv_manager, | ||
mock_apmconfig_enabled, | ||
mock_extension.Reporter, | ||
mock_meter_manager, | ||
) | ||
|
||
mock_config_inbound_processor.assert_called_once_with( | ||
mock_txn_name_manager, | ||
mock_apmconfig_enabled, | ||
) | ||
mock_config_otlp_processor.assert_called_once_with( | ||
mock_txn_name_manager, | ||
mock_apmconfig_enabled, | ||
mock_meter_manager, | ||
) | ||
mock_config_traces_exp.assert_called_once_with( | ||
mock_extension.Reporter, | ||
mock_txn_name_manager, | ||
mock_fwkv_manager, | ||
mock_apmconfig_enabled, | ||
) | ||
mock_config_metrics_exp.assert_called_once_with(mock_apmconfig_enabled) | ||
mock_config_propagator.assert_called_once() | ||
mock_config_response_propagator.assert_called_once() | ||
|
||
def test_configure_otel_components_agent_disabled( | ||
mocker, | ||
mock_txn_name_manager, | ||
mock_fwkv_manager, | ||
mock_meter_manager, | ||
mock_extension, | ||
mock_apmconfig_disabled, | ||
|
||
mock_config_inbound_processor, | ||
mock_config_otlp_processor, | ||
mock_config_traces_exp, | ||
mock_config_metrics_exp, | ||
mock_config_propagator, | ||
mock_config_response_propagator, | ||
): | ||
test_configurator = configurator.SolarWindsConfigurator() | ||
test_configurator._configure_otel_components( | ||
mock_txn_name_manager, | ||
mock_fwkv_manager, | ||
mock_apmconfig_disabled, | ||
mock_extension.Reporter, | ||
mock_meter_manager, | ||
) | ||
|
||
mock_config_inbound_processor.assert_not_called() | ||
mock_config_otlp_processor.assert_not_called() | ||
mock_config_traces_exp.assert_not_called() | ||
mock_config_metrics_exp.assert_not_called() | ||
mock_config_propagator.assert_not_called() | ||
mock_config_response_propagator.assert_not_called() |