Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions docs/experimental-features.md
Original file line number Diff line number Diff line change
Expand Up @@ -91,9 +91,9 @@ Enables the `@validate()` decorator on types, type properties, parameters, and o
param p string
```

### `waitUntil`
### `waitAndRetry`

The feature introduces waitUntil decorators on resource data type. waitUntil() decorator waits for the resource until its usable based on the desired property's state.
The feature introduces waitUntil and retryOn decorators on resource data type. waitUnitl() decorator waits for the resource until its usable based on the desired property's state. retryOn() will retry the deployment if one if the listed exception codes are encountered.

## Other experimental functionality

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ public void OnlyIfNotExistsDecorator_ValidScenario()
[TestMethod]
public void OnlyIfNotExistsAndRetryOnDecorator_ValidScenario()
{
var services = new ServiceBuilder().WithFeatureOverrides(new FeatureProviderOverrides(TestContext));
var services = new ServiceBuilder().WithFeatureOverrides(new FeatureProviderOverrides(TestContext, WaitAndRetryEnabled: true));
var (template, diagnostics, _) = CompilationHelper.Compile(services, @"
@onlyIfNotExists()
@retryOn(['ResourceNotFound', 'ServerError'], 1)
Expand All @@ -70,7 +70,7 @@ public void OnlyIfNotExistsAndRetryOnDecorator_ValidScenario()
{
diagnostics.ExcludingLinterDiagnostics().Should().BeEmpty();

template.Should().NotBeNull().And.HaveValueAtPath("$.languageVersion", "2.0");
template.Should().NotBeNull().And.HaveValueAtPath("$.languageVersion", "2.1-experimental");
template.Should().NotBeNull()
.And.HaveValueAtPath("$.resources['sqlServer'].@options.onlyIfNotExists", onlyIfNotExistsJObject);
template.Should().NotBeNull()
Expand Down
30 changes: 15 additions & 15 deletions src/Bicep.Core.IntegrationTests/Decorators/RetryOnDecoratorTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ public class RetryOnDecoratorTests
[TestMethod]
public void RetryOnDecorator_InvalidErrorMessageItemType()
{
var services = new ServiceBuilder().WithFeatureOverrides(new FeatureProviderOverrides(TestContext));
var services = new ServiceBuilder().WithFeatureOverrides(new FeatureProviderOverrides(TestContext, WaitAndRetryEnabled: true));
var (template, diagnostics, _) = CompilationHelper.Compile(services, @"
@retryOn(['ResourceNotFound', 1010])
resource sqlServer 'Microsoft.Sql/servers@2021-11-01' = {
Expand All @@ -45,7 +45,7 @@ public void RetryOnDecorator_InvalidErrorMessageItemType()
[TestMethod]
public void RetryOnDecorator_ValidScenario()
{
var services = new ServiceBuilder().WithFeatureOverrides(new FeatureProviderOverrides(TestContext));
var services = new ServiceBuilder().WithFeatureOverrides(new FeatureProviderOverrides(TestContext, WaitAndRetryEnabled: true));
var (template, diagnostics, _) = CompilationHelper.Compile(services, @"
@retryOn(['ResourceNotFound', 'ServerError'], 1)
resource sqlServer 'Microsoft.Sql/servers@2021-11-01' = {
Expand All @@ -63,7 +63,7 @@ public void RetryOnDecorator_ValidScenario()
using (new AssertionScope())
{
diagnostics.ExcludingLinterDiagnostics().Should().BeEmpty();
template.Should().NotBeNull().And.HaveValueAtPath("$.languageVersion", "2.0");
template.Should().NotBeNull().And.HaveValueAtPath("$.languageVersion", "2.1-experimental");
template.Should().NotBeNull()
.And.HaveValueAtPath("$.resources['sqlServer'].@options.retryOn", retryOnJObject);
}
Expand All @@ -72,7 +72,7 @@ public void RetryOnDecorator_ValidScenario()
[TestMethod]
public void RetryOnDecorator_ExpectedResourceDeclaration()
{
var services = new ServiceBuilder().WithFeatureOverrides(new FeatureProviderOverrides(TestContext));
var services = new ServiceBuilder().WithFeatureOverrides(new FeatureProviderOverrides(TestContext, WaitAndRetryEnabled: true));
var (template, diagnostics, _) = CompilationHelper.Compile(services, @"
@retryOn(['ResourceNotFound'])
");
Expand All @@ -88,7 +88,7 @@ public void RetryOnDecorator_ExpectedResourceDeclaration()
[TestMethod]
public void RetryOnDecorator_WithModuleDeclaration_ShouldFail()
{
var services = new ServiceBuilder().WithFeatureOverrides(new FeatureProviderOverrides(TestContext));
var services = new ServiceBuilder().WithFeatureOverrides(new FeatureProviderOverrides(TestContext, WaitAndRetryEnabled: true));

var mainUri = new Uri("file:///main.bicep");
var moduleUri = new Uri("file:///module.bicep");
Expand Down Expand Up @@ -127,7 +127,7 @@ param inputb string
[TestMethod]
public void RetryOnDecorator_WithRetryCountOptionalParameter_ExpectedResourceDeclaration()
{
var services = new ServiceBuilder().WithFeatureOverrides(new FeatureProviderOverrides(TestContext));
var services = new ServiceBuilder().WithFeatureOverrides(new FeatureProviderOverrides(TestContext, WaitAndRetryEnabled: true));
var (template, diagnostics, _) = CompilationHelper.Compile(services, @"
@retryOn(['ResourceNotFound'], 5)
");
Expand All @@ -143,7 +143,7 @@ public void RetryOnDecorator_WithRetryCountOptionalParameter_ExpectedResourceDec
[TestMethod]
public void RetryOnDecorator_InvalidRetryCount()
{
var services = new ServiceBuilder().WithFeatureOverrides(new FeatureProviderOverrides(TestContext));
var services = new ServiceBuilder().WithFeatureOverrides(new FeatureProviderOverrides(TestContext, WaitAndRetryEnabled: true));
var (template, diagnostics, _) = CompilationHelper.Compile(services, @"
@retryOn(['ResourceNotFound'], 0)
resource sqlServer 'Microsoft.Sql/servers@2021-11-01' = {
Expand All @@ -163,7 +163,7 @@ public void RetryOnDecorator_InvalidRetryCount()
[TestMethod]
public void RetryOnDecorator_NegativeRetryCount()
{
var services = new ServiceBuilder().WithFeatureOverrides(new FeatureProviderOverrides(TestContext));
var services = new ServiceBuilder().WithFeatureOverrides(new FeatureProviderOverrides(TestContext, WaitAndRetryEnabled: true));
var (template, diagnostics, _) = CompilationHelper.Compile(services, @"
@retryOn(['ResourceNotFound'], -5)
resource sqlServer 'Microsoft.Sql/servers@2021-11-01' = {
Expand All @@ -183,7 +183,7 @@ public void RetryOnDecorator_NegativeRetryCount()
[TestMethod]
public void RetryOnDecorator_NonIntegerRetryCountValue()
{
var services = new ServiceBuilder().WithFeatureOverrides(new FeatureProviderOverrides(TestContext));
var services = new ServiceBuilder().WithFeatureOverrides(new FeatureProviderOverrides(TestContext, WaitAndRetryEnabled: true));
var (template, diagnostics, _) = CompilationHelper.Compile(services, @"
@retryOn(['ResourceNotFound'], 'randomString')
resource sqlServer 'Microsoft.Sql/servers@2021-11-01' = {
Expand All @@ -204,7 +204,7 @@ public void RetryOnDecorator_NonIntegerRetryCountValue()
[TestMethod]
public void RetryOnDecoratorWithCollections_ValidScenario()
{
var services = new ServiceBuilder().WithFeatureOverrides(new FeatureProviderOverrides(TestContext));
var services = new ServiceBuilder().WithFeatureOverrides(new FeatureProviderOverrides(TestContext, WaitAndRetryEnabled: true));
var (template, diagnostics, _) = CompilationHelper.Compile(services, @"
@retryOn(['ResourceNotFound', 'ServerError'], 1)
resource sqlServer 'Microsoft.Sql/servers@2021-11-01' = [for i in range(1, 2):{
Expand All @@ -222,7 +222,7 @@ public void RetryOnDecoratorWithCollections_ValidScenario()
using (new AssertionScope())
{
diagnostics.ExcludingLinterDiagnostics().Should().BeEmpty();
template.Should().NotBeNull().And.HaveValueAtPath("$.languageVersion", "2.0");

template.Should().NotBeNull()
.And.HaveValueAtPath("$.resources['sqlServer'].@options.retryOn", retryOnJObject);
}
Expand All @@ -231,7 +231,7 @@ public void RetryOnDecoratorWithCollections_ValidScenario()
[TestMethod]
public void RetryOnDecoratorWithCollection_InvalidErrorMessageItemType()
{
var services = new ServiceBuilder().WithFeatureOverrides(new FeatureProviderOverrides(TestContext));
var services = new ServiceBuilder().WithFeatureOverrides(new FeatureProviderOverrides(TestContext, WaitAndRetryEnabled: true));
var (template, diagnostics, _) = CompilationHelper.Compile(services, @"
@retryOn(['ResourceNotFound', 1010])
resource sqlServer 'Microsoft.Sql/servers@2021-11-01' = [for i in range(1, 2):{
Expand All @@ -253,7 +253,7 @@ public void RetryOnDecoratorWithCollection_InvalidErrorMessageItemType()
[TestMethod]
public void RetryOnDecoratorWithCollection_InvalidRetryCount()
{
var services = new ServiceBuilder().WithFeatureOverrides(new FeatureProviderOverrides(TestContext));
var services = new ServiceBuilder().WithFeatureOverrides(new FeatureProviderOverrides(TestContext, WaitAndRetryEnabled: true));
var (template, diagnostics, _) = CompilationHelper.Compile(services, @"
@retryOn(['ResourceNotFound'], 0)
resource sqlServer 'Microsoft.Sql/servers@2021-11-01' = [for i in range(1, 2):{
Expand All @@ -273,7 +273,7 @@ public void RetryOnDecoratorWithCollection_InvalidRetryCount()
[TestMethod]
public void RetryOnDecoratorWithCollection_NegativeRetryCount()
{
var services = new ServiceBuilder().WithFeatureOverrides(new FeatureProviderOverrides(TestContext));
var services = new ServiceBuilder().WithFeatureOverrides(new FeatureProviderOverrides(TestContext, WaitAndRetryEnabled: true));
var (template, diagnostics, _) = CompilationHelper.Compile(services, @"
@retryOn(['ResourceNotFound'], -5)
resource sqlServer 'Microsoft.Sql/servers@2021-11-01' = [for i in range(1, 2):{
Expand All @@ -293,7 +293,7 @@ public void RetryOnDecoratorWithCollection_NegativeRetryCount()
[TestMethod]
public void RetryOnDecoratorWithCollections_NonIntegerRetryCountValue()
{
var services = new ServiceBuilder().WithFeatureOverrides(new FeatureProviderOverrides(TestContext));
var services = new ServiceBuilder().WithFeatureOverrides(new FeatureProviderOverrides(TestContext, WaitAndRetryEnabled: true));
var (template, diagnostics, _) = CompilationHelper.Compile(services, @"
@retryOn(['ResourceNotFound'], 'randomString')
resource sqlServer 'Microsoft.Sql/servers@2021-11-01' = [for i in range(1, 2):{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ public class WaitUntilDecoratorTests
[DataRow("@waitUntil(x => x.ProvisionStatus == 'Succeeded' && x.routingState == 'Provisioned', 'PT20S')", "[lambda('x', and(equals(lambdaVariables('x').ProvisionStatus, 'Succeeded'), equals(lambdaVariables('x').routingState, 'Provisioned')))]")]
public void WaitUntilDecorator_ValidScenario(string input, string output)
{
var services = new ServiceBuilder().WithFeatureOverrides(new FeatureProviderOverrides(TestContext, WaitUntilEnabled: true));
var services = new ServiceBuilder().WithFeatureOverrides(new FeatureProviderOverrides(TestContext, WaitAndRetryEnabled: true));
var fileContent = $@"
{input}
resource sqlServer 'Microsoft.Sql/servers@2021-11-01' = {{
Expand Down Expand Up @@ -53,7 +53,7 @@ public void WaitUntilDecorator_ValidScenario(string input, string output)
[TestMethod]
public void WaitUntilDecorator_MissingDeclaration_ExpectedResourceDeclaration()
{
var services = new ServiceBuilder().WithFeatureOverrides(new FeatureProviderOverrides(TestContext, WaitUntilEnabled: true));
var services = new ServiceBuilder().WithFeatureOverrides(new FeatureProviderOverrides(TestContext, WaitAndRetryEnabled: true));
var (template, diagnostics, _) = CompilationHelper.Compile(services, @"
@waitUntil(x => x.ProvisionStatus == 'Succeeded', 'PT20S')
");
Expand All @@ -69,7 +69,7 @@ public void WaitUntilDecorator_MissingDeclaration_ExpectedResourceDeclaration()
[TestMethod]
public void WaitUntilDecorator_MissingParameters_ExpectedTwoParameters()
{
var services = new ServiceBuilder().WithFeatureOverrides(new FeatureProviderOverrides(TestContext, WaitUntilEnabled: true));
var services = new ServiceBuilder().WithFeatureOverrides(new FeatureProviderOverrides(TestContext, WaitAndRetryEnabled: true));
var (template, diagnostics, _) = CompilationHelper.Compile(services, @"
@waitUntil(x => x.ProvisionStatus == 'Succeeded')
");
Expand All @@ -87,7 +87,7 @@ public void WaitUntilDecorator_MissingParameters_ExpectedTwoParameters()
[TestMethod]
public void WaitUntilDecorator_WithModuleDeclaration_ShouldFail()
{
var services = new ServiceBuilder().WithFeatureOverrides(new FeatureProviderOverrides(TestContext, WaitUntilEnabled: true));
var services = new ServiceBuilder().WithFeatureOverrides(new FeatureProviderOverrides(TestContext, WaitAndRetryEnabled: true));

var mainUri = new Uri("file:///main.bicep");
var moduleUri = new Uri("file:///module.bicep");
Expand Down Expand Up @@ -126,7 +126,7 @@ param inputb string
[TestMethod]
public void WaitUntilDecorator_FirstArgumentIsntLambda()
{
var services = new ServiceBuilder().WithFeatureOverrides(new FeatureProviderOverrides(TestContext, WaitUntilEnabled: true));
var services = new ServiceBuilder().WithFeatureOverrides(new FeatureProviderOverrides(TestContext, WaitAndRetryEnabled: true));

var (template, diagnostics, _) = CompilationHelper.Compile(services, $@"
@waitUntil('PT20S', x => x.ProvisionStatus == 'Succeeded')
Expand All @@ -148,7 +148,7 @@ public void WaitUntilDecorator_FirstArgumentIsntLambda()
[TestMethod]
public void WaitUntilDecorator_SecondArgumentIsntString()
{
var services = new ServiceBuilder().WithFeatureOverrides(new FeatureProviderOverrides(TestContext, WaitUntilEnabled: true));
var services = new ServiceBuilder().WithFeatureOverrides(new FeatureProviderOverrides(TestContext, WaitAndRetryEnabled: true));

var (template, diagnostics, _) = CompilationHelper.Compile(services, $@"
@waitUntil( x => x.ProvisionStatus == 'Succeeded', 1)
Expand All @@ -172,7 +172,7 @@ public void WaitUntilDecorator_SecondArgumentIsntString()
[DataRow("@waitUntil(x => x.ProvisionStatus == 'Succeeded' && x.routingState == 'Provisioned', 'PT20S')", "[lambda('x', and(equals(lambdaVariables('x').ProvisionStatus, 'Succeeded'), equals(lambdaVariables('x').routingState, 'Provisioned')))]")]
public void WaitUntilDecoratorWithCollection_ValidScenario(string input, string output)
{
var services = new ServiceBuilder().WithFeatureOverrides(new FeatureProviderOverrides(TestContext, WaitUntilEnabled: true));
var services = new ServiceBuilder().WithFeatureOverrides(new FeatureProviderOverrides(TestContext, WaitAndRetryEnabled: true));
var fileContent = $@"
{input}
resource sqlServer 'Microsoft.Sql/servers@2021-11-01' = [for i in range(0, 2) :{{
Expand Down Expand Up @@ -200,7 +200,7 @@ public void WaitUntilDecoratorWithCollection_ValidScenario(string input, string
[TestMethod]
public void WaitUntilDecoratorWithCollection_FirstArgumentIsntLambda()
{
var services = new ServiceBuilder().WithFeatureOverrides(new FeatureProviderOverrides(TestContext, WaitUntilEnabled: true));
var services = new ServiceBuilder().WithFeatureOverrides(new FeatureProviderOverrides(TestContext, WaitAndRetryEnabled: true));

var (template, diagnostics, _) = CompilationHelper.Compile(services, $@"
@waitUntil('PT20S', x => x.ProvisionStatus == 'Succeeded')
Expand All @@ -222,7 +222,7 @@ public void WaitUntilDecoratorWithCollection_FirstArgumentIsntLambda()
[TestMethod]
public void WaitUntilDecoratorWithCollection_SecondArgumentIsntString()
{
var services = new ServiceBuilder().WithFeatureOverrides(new FeatureProviderOverrides(TestContext, WaitUntilEnabled: true));
var services = new ServiceBuilder().WithFeatureOverrides(new FeatureProviderOverrides(TestContext, WaitAndRetryEnabled: true));

var (template, diagnostics, _) = CompilationHelper.Compile(services, $@"
@waitUntil( x => x.ProvisionStatus == 'Succeeded', 1)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -222,27 +222,6 @@
"newText": "onlyIfNotExists()$0"
}
},
{
"label": "retryOn",
"kind": "function",
"documentation": {
"kind": "markdown",
"value": "```bicep\nretryOn(exceptionCodes: string[], [retryCount: int]): any\n\n``` \n \n"
},
"deprecated": false,
"preselect": false,
"sortText": "3_retryOn",
"insertTextFormat": "snippet",
"insertTextMode": "adjustIndentation",
"textEdit": {
"range": {},
"newText": "retryOn($0)"
},
"command": {
"title": "signature help",
"command": "editor.action.triggerParameterHints"
}
},
{
"label": "sealed",
"kind": "function",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -222,27 +222,6 @@
"newText": "onlyIfNotExists()$0"
}
},
{
"label": "retryOn",
"kind": "function",
"documentation": {
"kind": "markdown",
"value": "```bicep\nretryOn(exceptionCodes: string[], [retryCount: int]): any\n\n``` \n \n"
},
"deprecated": false,
"preselect": false,
"sortText": "3_retryOn",
"insertTextFormat": "snippet",
"insertTextMode": "adjustIndentation",
"textEdit": {
"range": {},
"newText": "retryOn($0)"
},
"command": {
"title": "signature help",
"command": "editor.action.triggerParameterHints"
}
},
{
"label": "sealed",
"kind": "function",
Expand Down
Loading
Loading