-
Notifications
You must be signed in to change notification settings - Fork 278
AMA: enable libcurl ODS upload (ENABLE_CURL_UPLOAD) in eastus2euap and centraluseuap #2190
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
Merged
Siddhartha Mathiharan (simathih)
merged 3 commits into
master
from
siddhartha/enable-curl-upload-eastus2euap
Jun 30, 2026
Merged
Changes from all commits
Commits
Show all changes
3 commits
Select commit
Hold shift + click to select a range
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 hidden or 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 hidden or 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 |
|---|---|---|
|
|
@@ -20,6 +20,25 @@ | |
| sys.modules['Utils.WAAgentUtil'].waagent = MagicMock() | ||
| sys.modules['Utils.HandlerUtil'] = MagicMock() | ||
|
|
||
| # Mock build-only packages that agent.py imports at module level (telegraf/metrics | ||
| # helpers). Only mock them when the real package is not importable in this | ||
| # environment, so a CI checkout that ships these packages uses the real modules. | ||
| import importlib | ||
| for mod_name in ( | ||
| 'telegraf_utils', | ||
| 'telegraf_utils.telegraf_config_handler', | ||
| 'metrics_ext_utils', | ||
| 'metrics_ext_utils.metrics_constants', | ||
| 'metrics_ext_utils.metrics_ext_handler', | ||
| 'metrics_ext_utils.metrics_common_utils', | ||
| ): | ||
| if mod_name in sys.modules: | ||
| continue | ||
| try: | ||
| importlib.import_module(mod_name) | ||
| except ImportError: | ||
| sys.modules[mod_name] = MagicMock() | ||
|
|
||
| sys.path.insert(0, os.path.abspath(os.path.join(os.path.dirname(__file__), '..'))) | ||
| sys.path.insert(0, os.path.abspath(os.path.join(os.path.dirname(__file__), '..', '..', 'LAD-AMA-Common'))) | ||
|
|
||
|
|
@@ -319,5 +338,97 @@ def test_port_reset_allows_regeneration(self, mock_exists): | |
| self.assertEqual(agent.MDSDSyslogPort, 0) | ||
|
|
||
|
|
||
| class TestIsFeatureEnabledCurlUpload(unittest.TestCase): | ||
| """Tests for is_feature_enabled('enableCurlUpload') region gating (PR #2190).""" | ||
|
|
||
| def test_curl_upload_in_feature_support_matrix(self): | ||
| """enableCurlUpload must be gated to the canary regions only (not 'all').""" | ||
| # Re-derive the matrix the same way is_feature_enabled does, by exercising | ||
| # the function across regions; only the canary regions must match. | ||
| with patch('os.path.exists', return_value=False): | ||
| with patch('agent.get_azure_environment_and_region', | ||
| return_value=(None, 'eastus2euap')): | ||
| self.assertTrue(agent.is_feature_enabled('enableCurlUpload')) | ||
|
|
||
| def test_enabled_in_eastus2euap(self): | ||
| with patch('os.path.exists', return_value=False): | ||
| with patch('agent.get_azure_environment_and_region', | ||
| return_value=('AzureCloud', 'eastus2euap')): | ||
| self.assertTrue(agent.is_feature_enabled('enableCurlUpload')) | ||
|
|
||
| def test_enabled_in_centraluseuap(self): | ||
| with patch('os.path.exists', return_value=False): | ||
| with patch('agent.get_azure_environment_and_region', | ||
| return_value=('AzureCloud', 'centraluseuap')): | ||
| self.assertTrue(agent.is_feature_enabled('enableCurlUpload')) | ||
|
|
||
| def test_disabled_in_other_region(self): | ||
| for region in ('eastus', 'westus2', 'centralus', ''): | ||
| with patch('os.path.exists', return_value=False): | ||
| with patch('agent.get_azure_environment_and_region', | ||
| return_value=('AzureCloud', region)): | ||
| self.assertFalse( | ||
| agent.is_feature_enabled('enableCurlUpload'), | ||
| msg="enableCurlUpload should be disabled in region %r" % region) | ||
|
|
||
| def test_preview_flag_file_forces_enable(self): | ||
| """A previewFeatures/<feature> flag file enables the feature in any region.""" | ||
| flag_path = agent.PreviewFeaturesDirectory + 'enableCurlUpload' | ||
|
|
||
| def exists_side_effect(path): | ||
| return path == flag_path | ||
|
|
||
| with patch('os.path.exists', side_effect=exists_side_effect): | ||
| # Region would otherwise be unsupported, but the flag wins. | ||
| with patch('agent.get_azure_environment_and_region', | ||
| return_value=('AzureCloud', 'eastus')): | ||
| self.assertTrue(agent.is_feature_enabled('enableCurlUpload')) | ||
|
|
||
| def test_disabled_flag_file_forces_disable(self): | ||
| """A previewFeatures/<feature>Disabled flag file disables it even in eastus2euap.""" | ||
| disabled_path = agent.PreviewFeaturesDirectory + 'enableCurlUploadDisabled' | ||
|
|
||
| def exists_side_effect(path): | ||
| return path == disabled_path | ||
|
|
||
| with patch('os.path.exists', side_effect=exists_side_effect): | ||
| with patch('agent.get_azure_environment_and_region', | ||
| return_value=('AzureCloud', 'eastus2euap')): | ||
| self.assertFalse(agent.is_feature_enabled('enableCurlUpload')) | ||
|
|
||
| def test_unknown_feature_disabled(self): | ||
|
Contributor
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. nit: shouldn't this be in a general feature flag test class rather than a ENABLE_CURL specific one? |
||
| """A feature not present in the support matrix is disabled.""" | ||
| with patch('os.path.exists', return_value=False): | ||
| with patch('agent.get_azure_environment_and_region', | ||
| return_value=('AzureCloud', 'eastus2euap')): | ||
| self.assertFalse(agent.is_feature_enabled('someUnknownFeature')) | ||
|
|
||
|
|
||
| class TestEnableCurlUploadConfig(unittest.TestCase): | ||
| """Tests that enable() writes ENABLE_CURL_UPLOAD only when the feature is enabled (PR #2190).""" | ||
|
|
||
| def _run_enable_default_configs(self, feature_enabled): | ||
| """ | ||
| Drive only the small ENABLE_CURL_UPLOAD branch added to enable() in isolation, | ||
| mirroring agent.py: | ||
| if is_feature_enabled('enableCurlUpload'): | ||
| default_configs["ENABLE_CURL_UPLOAD"] = "true" | ||
| """ | ||
| default_configs = {} | ||
| with patch('agent.is_feature_enabled', return_value=feature_enabled) as mock_feat: | ||
| if agent.is_feature_enabled('enableCurlUpload'): | ||
| default_configs["ENABLE_CURL_UPLOAD"] = "true" | ||
| mock_feat.assert_called_with('enableCurlUpload') | ||
| return default_configs | ||
|
|
||
| def test_curl_upload_config_set_when_enabled(self): | ||
| configs = self._run_enable_default_configs(feature_enabled=True) | ||
| self.assertEqual(configs.get("ENABLE_CURL_UPLOAD"), "true") | ||
|
|
||
| def test_curl_upload_config_absent_when_disabled(self): | ||
| configs = self._run_enable_default_configs(feature_enabled=False) | ||
| self.assertNotIn("ENABLE_CURL_UPLOAD", configs) | ||
|
|
||
|
|
||
| if __name__ == '__main__': | ||
| unittest.main() | ||
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.
nit: Isn't this more of an "azure_envionment" test rather than "is feature in support matrix"? latter is covered by the test case below