-
Notifications
You must be signed in to change notification settings - Fork 1
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
NH-34752 Add config file tests + small changes #139
Merged
Merged
Changes from all commits
Commits
Show all changes
14 commits
Select commit
Hold shift + click to select a range
5d8ac41
Mv test_apm_config to subdir
tammy-baylis-swi 9764fbb
Refactor out get_cnf_dict helper
tammy-baylis-swi 8bff7a9
(WIP) add TestSolarWindsApmConfigCnfFile
tammy-baylis-swi f617550
Add cnf_file fixture
tammy-baylis-swi 4cf0846
Adjust get_cnf_dict for testing
tammy-baylis-swi 553187b
Add fixture_cnf_file and test
tammy-baylis-swi 5459973
Add prependdomain_valid config test
tammy-baylis-swi c86b70a
Add prependdomain_invalid config test
tammy-baylis-swi 7b206ed
Rm unused inst and inst_enabled configs
tammy-baylis-swi 73b1aae
Add more update_with_cnf_file tests
tammy-baylis-swi 80857a0
Add fixture_cnf_dict
tammy-baylis-swi b9a2367
Test env var set with update_with_cnf_file
tammy-baylis-swi 7258624
Another test env var set with update_with_cnf_file
tammy-baylis-swi e31c829
assert key instead of service name
tammy-baylis-swi File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Empty file.
Empty file.
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,34 @@ | ||
import pytest | ||
|
||
@pytest.fixture | ||
def fixture_cnf_dict(): | ||
return { | ||
"agentEnabled": True, | ||
"tracingMode": "enabled", | ||
"triggerTrace": "enabled", | ||
"collector": "foo-bar", | ||
"reporter": "udp", | ||
"debugLevel": 6, | ||
"serviceKey": "not-good-to-put-here:wont-be-used", | ||
"hostnameAlias": "foo-bar", | ||
"trustedpath": "foo-bar", | ||
"eventsFlushInterval": 2, | ||
"maxRequestSizeBytes": 2, | ||
"ec2MetadataTimeout": 1234, | ||
"maxFlushWaitTime": 2, | ||
"maxTransactions": 2, | ||
"logname": "foo-bar", | ||
"traceMetrics": 2, | ||
"tokenBucketCapacity": 2, | ||
"tokenBucketRate": 2, | ||
"bufsize": 2, | ||
"histogramPrecision": 2, | ||
"reporterFileSingle": 2, | ||
"enableSanitizeSql": True, | ||
"logTraceId": "always", | ||
"proxy": "http://foo-bar", | ||
"transaction": { | ||
"prependDomain": True | ||
}, | ||
"isGrpcCleanHackEnabled": True, | ||
} |
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,14 @@ | ||
import pytest | ||
|
||
@pytest.fixture | ||
def fixture_cnf_file(mocker): | ||
read_data = '{"foo": "bar"}' | ||
mocked_cnf_file_data = mocker.mock_open(read_data=read_data) | ||
builtin_open = "builtins.open" | ||
mocker.patch(builtin_open, mocked_cnf_file_data) | ||
|
||
@pytest.fixture | ||
def fixture_cnf_file_invalid_json(mocker): | ||
mocked_cnf_file_data = mocker.mock_open(read_data="invalid-foo") | ||
builtin_open = "builtins.open" | ||
mocker.patch(builtin_open, mocked_cnf_file_data) |
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,15 @@ | ||
import os | ||
import pytest | ||
|
||
from solarwinds_apm.apm_constants import ( | ||
INTL_SWO_DEFAULT_PROPAGATORS, | ||
INTL_SWO_DEFAULT_TRACES_EXPORTER, | ||
) | ||
|
||
@pytest.fixture(name="mock_env_vars") | ||
def fixture_mock_env_vars(mocker): | ||
mocker.patch.dict(os.environ, { | ||
"OTEL_PROPAGATORS": ",".join(INTL_SWO_DEFAULT_PROPAGATORS), | ||
"OTEL_TRACES_EXPORTER": INTL_SWO_DEFAULT_TRACES_EXPORTER, | ||
"SW_APM_SERVICE_KEY": "valid:key", | ||
}) |
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 |
---|---|---|
|
@@ -4,7 +4,6 @@ | |
# | ||
# 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. | ||
|
||
import json | ||
import os | ||
import pytest | ||
|
||
|
@@ -14,18 +13,10 @@ | |
from solarwinds_apm.apm_constants import ( | ||
INTL_SWO_AO_COLLECTOR, | ||
INTL_SWO_AO_STG_COLLECTOR, | ||
INTL_SWO_DEFAULT_PROPAGATORS, | ||
INTL_SWO_DEFAULT_TRACES_EXPORTER, | ||
) | ||
|
||
@pytest.fixture(name="mock_env_vars") | ||
def fixture_mock_env_vars(mocker): | ||
mocker.patch.dict(os.environ, { | ||
"OTEL_PROPAGATORS": ",".join(INTL_SWO_DEFAULT_PROPAGATORS), | ||
"OTEL_TRACES_EXPORTER": INTL_SWO_DEFAULT_TRACES_EXPORTER, | ||
"SW_APM_SERVICE_KEY": "valid:key", | ||
}) | ||
|
||
# pylint: disable=unused-import | ||
from .fixtures.env_vars import fixture_mock_env_vars | ||
Check notice Code scanning / CodeQL Unused import
Import of 'fixture_mock_env_vars' is not used.
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Dismissing because pytest is using them. |
||
|
||
class TestSolarWindsApmConfig: | ||
""" | ||
|
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is there a reason for having
transaction
inself.__config.keys()
. I think removing it from there will nullify this branch.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It's there as part of one way to store
transaction
with a default andtransaction.prepend_domain_name
as a nested object if set by customer, but I'm not convinced this is a good reason!Right now an accepted config file would be:
But it might make more sense to customer if it were:
I'll change this in a next PR.