-
Notifications
You must be signed in to change notification settings - Fork 464
[in-proc] Fix sync trigger error when AzureWebjobsStorage is not set in Managed #11214
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
Open
ishank12
wants to merge
4
commits into
in-proc
Choose a base branch
from
ishank12/syncTriggerFixInProc
base: in-proc
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
4 commits
Select commit
Hold shift + click to select a range
a4ce4f2
Fix sync trigger error when AzureWebjobsStorage is not set in Managed…
ishank12 829bb11
fixed and enabled sync trigger tests for k8s environment (#10923)
ishank12 a0685ff
Merge branch 'in-proc' into ishank12/syncTriggerFixInProc
ishank12 8113450
Update release_notes.md
ishank12 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
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 | ||||
---|---|---|---|---|---|---|
|
@@ -299,6 +299,62 @@ public async Task TrySyncTriggers_LocalEnvironment_ReturnsFalse() | |||||
} | ||||||
} | ||||||
|
||||||
[Fact] | ||||||
public async Task TrySyncTriggers_ManagedAppEnv_WithNo_AzureWebJobsStorage_ReturnsTrue() | ||||||
{ | ||||||
_vars.Add("AzureWebJobsStorage", null); | ||||||
_mockEnvironment.Setup(p => p.GetEnvironmentVariable(EnvironmentSettingNames.AzureWebsiteArmCacheEnabled)).Returns("0"); | ||||||
|
||||||
using (var env = new TestScopedEnvironmentVariable(_vars)) | ||||||
{ | ||||||
_mockEnvironment.Setup(p => p.GetEnvironmentVariable(EnvironmentSettingNames.ManagedEnvironment)).Returns("true"); | ||||||
_mockEnvironment.Setup(p => p.GetEnvironmentVariable("FUNCTIONS_API_SERVER")).Returns("https://appname.azurewebsites.net"); | ||||||
_mockEnvironment.Setup(p => p.GetEnvironmentVariable("CONTAINER_APP_NAME")).Returns("appname"); | ||||||
_mockEnvironment.Setup(p => p.GetEnvironmentVariable("CONTAINER_APP_NAMESPACE")).Returns("appns"); | ||||||
_mockEnvironment.Setup(p => p.GetEnvironmentVariable("CONTAINER_APP_REVISION")).Returns("appname--r1"); | ||||||
|
||||||
// _functionsSyncManager is initialized in the constructor with all the secrets from environment, | ||||||
// so HostAzureBlobStorageProvider will have AzureWebJobsStorage defined in both ActiveHostConfigurationSource | ||||||
// and the WebHost IConfiguration source from DI. | ||||||
// The TestScopedEnvironmentVariable only changes the WebHost level IConfiguration | ||||||
// When it is set to empty/null, the connection string from the ActiveHostConfigurationSource wins (never changed since it is set in | ||||||
// constructor as mentioned). | ||||||
// Therefore, we need to force refresh the configuration with an ActiveHostChanged event. This is because setting an empty/null environment variable | ||||||
// removes it, but will not remove it from the ActiveHostConfigurationSource. | ||||||
_scriptHostManager.OnActiveHostChanged(); | ||||||
var result = await _functionsSyncManager.TrySyncTriggersAsync(isBackgroundSync: true); | ||||||
Assert.True(result.Success); | ||||||
VerifyResultWithCacheOff(durableVersion: "V1"); | ||||||
} | ||||||
} | ||||||
|
||||||
[Fact] | ||||||
public async Task TrySyncTriggers_KubernetesManagedEnv_WithNo_AzureWebJobsStorage_ReturnsTrue() | ||||||
{ | ||||||
_vars.Add("AzureWebJobsStorage", null); | ||||||
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. Setting a dictionary value to null may not have the intended effect of removing the environment variable. Consider using an empty string or a specific test utility method to simulate the absence of this environment variable.
Suggested change
Copilot uses AI. Check for mistakes. Positive FeedbackNegative Feedback |
||||||
_mockEnvironment.Setup(p => p.GetEnvironmentVariable(EnvironmentSettingNames.AzureWebsiteArmCacheEnabled)).Returns("0"); | ||||||
|
||||||
using (var env = new TestScopedEnvironmentVariable(_vars)) | ||||||
{ | ||||||
_mockEnvironment.Setup(p => p.GetEnvironmentVariable("FUNCTIONS_API_SERVER")).Returns("https://appname.azurewebsites.net"); | ||||||
_mockEnvironment.Setup(p => p.GetEnvironmentVariable("KUBERNETES_SERVICE_HOST")).Returns("kubhost"); | ||||||
_mockEnvironment.Setup(p => p.GetEnvironmentVariable("POD_NAMESPACE")).Returns("podns"); | ||||||
|
||||||
// _functionsSyncManager is initialized in the constructor with all the secrets from environment, | ||||||
// so HostAzureBlobStorageProvider will have AzureWebJobsStorage defined in both ActiveHostConfigurationSource | ||||||
// and the WebHost IConfiguration source from DI. | ||||||
// The TestScopedEnvironmentVariable only changes the WebHost level IConfiguration | ||||||
// When it is set to empty/null, the connection string from the ActiveHostConfigurationSource wins (never changed since it is set in | ||||||
// constructor as mentioned). | ||||||
// Therefore, we need to force refresh the configuration with an ActiveHostChanged event. This is because setting an empty/null environment variable | ||||||
// removes it, but will not remove it from the ActiveHostConfigurationSource. | ||||||
_scriptHostManager.OnActiveHostChanged(); | ||||||
var result = await _functionsSyncManager.TrySyncTriggersAsync(isBackgroundSync: true); | ||||||
Assert.True(result.Success); | ||||||
VerifyResultWithCacheOff(durableVersion: "V1"); | ||||||
} | ||||||
} | ||||||
|
||||||
[Fact] | ||||||
public void ArmCacheEnabled_VerifyDefault() | ||||||
{ | ||||||
|
@@ -1147,4 +1203,4 @@ public void Reset() | |||||
} | ||||||
} | ||||||
} | ||||||
} | ||||||
} |
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.
Setting a dictionary value to null may not have the intended effect of removing the environment variable. Consider using an empty string or a specific test utility method to simulate the absence of this environment variable.
Copilot uses AI. Check for mistakes.