-
Notifications
You must be signed in to change notification settings - Fork 12
Add support for managing cluster capacity policy #106
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
Merged
Changes from 31 commits
Commits
Show all changes
44 commits
Select commit
Hold shift + click to select a range
d511900
Add cluster capacity policy model
ashleyvansp f38ef03
Add unit tests
ashleyvansp f9d4433
First pass at writing capacity policy
ashleyvansp 407147e
Ignore nulls when serializing
ashleyvansp aa036af
Add clusters.yml test files for different capacity policy cases
ashleyvansp 3d7709d
remove unused test files
ashleyvansp e67a422
Merge branch 'main' into ashleyvansp/capacityPolicy
ashleyvansp ff73111
Separate generic library functionality from app-specific implementation
ashleyvansp e0d5028
remove whitespace
ashleyvansp 238625f
fix cluster model
ashleyvansp cb269f4
new cluster orchestrator
ashleyvansp 9c11c41
fix some errors
ashleyvansp e0cfb77
fix build
ashleyvansp e67e3fc
unit test data
ashleyvansp 15ac317
rename
ashleyvansp 3e29698
cluster changes
ashleyvansp e6ba13f
add ;
ashleyvansp 1d11d5b
small fix
ashleyvansp 5dc3cd2
fix property
ashleyvansp b24d5a1
build succeeds
ashleyvansp 28e23ce
move YamlDatabaseParserTests
ashleyvansp 5bb8be2
make model comparable and add first unit test
ashleyvansp 5626175
undo schema handler change
ashleyvansp 82e59c9
genericize the capacity policy diff
ashleyvansp 0093e1f
Finish test for generate changes
ashleyvansp f48e441
revert serialization change
ashleyvansp 0585bc7
Potential fix for code scanning alert no. 36: Call to System.IO.Path.…
ashleyvansp e1fe5b5
Orchestrator tests
ashleyvansp 59986f1
yaml cluster handler
ashleyvansp be9c073
yaml cluster handler and test
ashleyvansp 48fd778
fix test path
ashleyvansp 2af167b
handler changes
ashleyvansp 60b6965
add GenerateChangesFromFileAsync
ashleyvansp b5d6d28
add diagnostics to script
ashleyvansp b7c400b
remove property changes
ashleyvansp c0f5562
remove redundant property
ashleyvansp d2ae9a4
tidy up
ashleyvansp 3207d8b
Potential fix for code scanning alert no. 103: Call to System.IO.Path…
ashleyvansp 467b0df
Merge branch 'main' into ashleyvansp/capacityPolicy
ashleyvansp f1fa409
yaml cluster handler factory interface
ashleyvansp 76e3a83
Merge branch 'ashleyvansp/capacityPolicy' of https://github.com/githu…
ashleyvansp b46769c
don't swallow exceptions
ashleyvansp 734b1d1
update readme
ashleyvansp 7c57660
small readme change
ashleyvansp 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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,141 @@ | ||
| using KustoSchemaTools.Changes; | ||
| using KustoSchemaTools.Model; | ||
| using Microsoft.Extensions.Logging; | ||
| using Moq; | ||
| using Newtonsoft.Json; | ||
| using System.Linq; | ||
| using Xunit; | ||
|
|
||
| namespace KustoSchemaTools.Tests.Changes | ||
| { | ||
| public class ClusterChangesTests | ||
| { | ||
| private readonly Mock<ILogger> _loggerMock; | ||
|
|
||
| public ClusterChangesTests() | ||
| { | ||
| _loggerMock = new Mock<ILogger>(); | ||
| } | ||
|
|
||
| [Fact] | ||
| public void GenerateChanges_WithIdenticalPolicies_ShouldDetectNoChanges() | ||
| { | ||
| // Arrange | ||
| var oldCluster = CreateClusterWithPolicy(0.2, 1, 2, 3); | ||
| var newCluster = CreateClusterWithPolicy(0.2, 1, 2, 3); | ||
|
|
||
| // Act | ||
| var changeSet = ClusterChanges.GenerateChanges(oldCluster, newCluster, _loggerMock.Object); | ||
|
|
||
| // Assert | ||
| Assert.NotNull(changeSet); | ||
| Assert.Empty(changeSet.Changes); | ||
| } | ||
| [Fact] | ||
| public void GenerateChanges_WithSinglePropertyChange_ShouldDetectChangeAndCreateScript() | ||
| { | ||
| // Arrange | ||
| var oldCluster = CreateClusterWithPolicy(0.2, 1, 2, 3); | ||
| var newCluster = CreateClusterWithPolicy(0.2, 1, 2, 5); | ||
|
|
||
| // Act | ||
| var changeSet = ClusterChanges.GenerateChanges(oldCluster, newCluster, _loggerMock.Object); | ||
|
|
||
| // Assert | ||
| Assert.NotNull(changeSet); | ||
| Assert.NotEmpty(changeSet.Changes); | ||
| Assert.NotEmpty(changeSet.Scripts); | ||
|
|
||
| // Asserts that there is exactly one policy change in the change set | ||
| var policyChange = Assert.Single(changeSet.Changes) as PolicyChange<ClusterCapacityPolicy>; | ||
| Assert.NotNull(policyChange); | ||
|
|
||
| // Asserts that there is exactly one property change detected. | ||
| // Because a nested property changed, the top-level property containing it is marked as changed. | ||
| var propertyChange = Assert.Single(policyChange.PropertyChanges); | ||
| Assert.Equal("MaterializedViewsCapacity", propertyChange.PropertyName); | ||
| Assert.Equal("{\"ClusterMaximumConcurrentOperations\":1,\"ExtentsRebuildCapacity\":{\"ClusterMaximumConcurrentOperations\":2,\"MaximumConcurrentOperationsPerNode\":3}}", propertyChange.OldValue); | ||
| Assert.Equal("{\"ClusterMaximumConcurrentOperations\":1,\"ExtentsRebuildCapacity\":{\"ClusterMaximumConcurrentOperations\":2,\"MaximumConcurrentOperationsPerNode\":5}}", propertyChange.NewValue); | ||
|
|
||
| // Assert that the correct script is generated | ||
| var expectedScript = newCluster.CapacityPolicy.ToUpdateScript(); | ||
| var actualScriptContainer = Assert.Single(changeSet.Scripts); | ||
| Assert.Equal(expectedScript, actualScriptContainer.Script.Text); | ||
| } | ||
|
|
||
| [Fact] | ||
| public void GenerateChanges_WithMultiplePropertyChanges_ShouldDetectAllChanges() | ||
| { | ||
| // Arrange | ||
| var oldCluster = CreateClusterWithPolicy(ingestionCapacityCoreUtilizationCoefficient: 0.75, materializedViewsCapacityClusterMaximumConcurrentOperations: 10); | ||
| var newCluster = CreateClusterWithPolicy(ingestionCapacityCoreUtilizationCoefficient: 0.95, materializedViewsCapacityClusterMaximumConcurrentOperations: 20); | ||
|
|
||
| // Act | ||
| var changeSet = ClusterChanges.GenerateChanges(oldCluster, newCluster, _loggerMock.Object); | ||
|
|
||
| // Assert | ||
| var policyChange = Assert.Single(changeSet.Changes) as PolicyChange<ClusterCapacityPolicy>; | ||
| Assert.NotNull(policyChange); | ||
| Assert.Equal(2, policyChange.PropertyChanges.Count); | ||
|
|
||
|
|
||
| var ingestionChange = Assert.Single(policyChange.PropertyChanges, p => p.PropertyName == "IngestionCapacity"); | ||
|
|
||
| Assert.Equal("{\"CoreUtilizationCoefficient\":0.75}", ingestionChange.OldValue); | ||
| Assert.Equal("{\"CoreUtilizationCoefficient\":0.95}", ingestionChange.NewValue); | ||
|
|
||
| var mvChange = Assert.Single(policyChange.PropertyChanges, p => p.PropertyName == "MaterializedViewsCapacity"); | ||
| Assert.Equal("{\"ClusterMaximumConcurrentOperations\":10}", mvChange.OldValue); | ||
| Assert.Equal("{\"ClusterMaximumConcurrentOperations\":20}", mvChange.NewValue); | ||
|
|
||
| // Assert that the correct script is generated | ||
| var expectedScript = newCluster.CapacityPolicy.ToUpdateScript(); | ||
| var actualScriptContainer = Assert.Single(changeSet.Scripts); | ||
| Assert.Equal(expectedScript, actualScriptContainer.Script.Text); | ||
| } | ||
|
|
||
| [Fact] | ||
| public void GenerateChanges_WithNullNewCapacityPolicy_ShouldNotGenerateChanges() | ||
| { | ||
| // Arrange | ||
| var oldCluster = CreateClusterWithPolicy(ingestionCapacityCoreUtilizationCoefficient: 0.75); | ||
| var newCluster = new Cluster { Name = oldCluster.Name, CapacityPolicy = null }; | ||
|
|
||
| // Act | ||
| var changeSet = ClusterChanges.GenerateChanges(oldCluster, newCluster, _loggerMock.Object); | ||
|
|
||
| // Assert | ||
| Assert.NotNull(changeSet); | ||
| Assert.Empty(changeSet.Changes); | ||
| Assert.Empty(changeSet.Scripts); | ||
| } | ||
|
|
||
| #region Helper Methods | ||
| private Cluster CreateClusterWithPolicy( | ||
| double? ingestionCapacityCoreUtilizationCoefficient = null, | ||
| int? materializedViewsCapacityClusterMaximumConcurrentOperations = null, | ||
| int? extentsRebuildClusterMaximumConcurrentOperations = null, | ||
| int? extentsRebuildMaximumConcurrentOperationsPerNode = null | ||
| ) | ||
| { | ||
| return new Cluster | ||
| { | ||
| CapacityPolicy = new ClusterCapacityPolicy | ||
| { | ||
| MaterializedViewsCapacity = new MaterializedViewsCapacity | ||
| { | ||
| ClusterMaximumConcurrentOperations = materializedViewsCapacityClusterMaximumConcurrentOperations, | ||
| ExtentsRebuildCapacity = (extentsRebuildClusterMaximumConcurrentOperations != null || extentsRebuildMaximumConcurrentOperationsPerNode != null) ? new ExtentsRebuildCapacity | ||
| { | ||
| ClusterMaximumConcurrentOperations = extentsRebuildClusterMaximumConcurrentOperations, | ||
| MaximumConcurrentOperationsPerNode = extentsRebuildMaximumConcurrentOperationsPerNode | ||
| } : null | ||
| }, | ||
| IngestionCapacity = new IngestionCapacity | ||
| { | ||
| CoreUtilizationCoefficient = ingestionCapacityCoreUtilizationCoefficient | ||
| }, | ||
| } | ||
| }; | ||
| } | ||
| #endregion | ||
| } | ||
| } | ||
37 changes: 37 additions & 0 deletions
37
...chemaTools.Tests/DemoData/ClusterScopedChanges/clusterWithComprehensiveCapacityPolicy.yml
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 |
|---|---|---|
| @@ -0,0 +1,37 @@ | ||
| connections: | ||
| - name: test | ||
| url: test.eastus | ||
| capacityPolicy: | ||
| ingestionCapacity: | ||
| clusterMaximumConcurrentOperations: 512 | ||
| coreUtilizationCoefficient: 0.75 | ||
| extentsMergeCapacity: | ||
| minimumConcurrentOperationsPerNode: 1 | ||
| maximumConcurrentOperationsPerNode: 3 | ||
| extentsPurgeRebuildCapacity: | ||
| maximumConcurrentOperationsPerNode: 1 | ||
| exportCapacity: | ||
| clusterMaximumConcurrentOperations: 100 | ||
| coreUtilizationCoefficient: 0.25 | ||
| extentsPartitionCapacity: | ||
| clusterMinimumConcurrentOperations: 1 | ||
| clusterMaximumConcurrentOperations: 32 | ||
| materializedViewsCapacity: | ||
| clusterMaximumConcurrentOperations: 1 | ||
| extentsRebuildCapacity: | ||
| clusterMaximumConcurrentOperations: 50 | ||
| maximumConcurrentOperationsPerNode: 5 | ||
| storedQueryResultsCapacity: | ||
| maximumConcurrentOperationsPerDbAdmin: 250 | ||
| coreUtilizationCoefficient: 0.75 | ||
| streamingIngestionPostProcessingCapacity: | ||
| maximumConcurrentOperationsPerNode: 4 | ||
| purgeStorageArtifactsCleanupCapacity: | ||
| maximumConcurrentOperationsPerCluster: 2 | ||
| periodicStorageArtifactsCleanupCapacity: | ||
| maximumConcurrentOperationsPerCluster: 2 | ||
| queryAccelerationCapacity: | ||
| clusterMaximumConcurrentOperations: 100 | ||
| coreUtilizationCoefficient: 0.5 | ||
| graphSnapshotsCapacity: | ||
| clusterMaximumConcurrentOperations: 5 |
13 changes: 13 additions & 0 deletions
13
KustoSchemaTools.Tests/DemoData/ClusterScopedChanges/clusterWithPartialCapacityPolicy.yml
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 |
|---|---|---|
| @@ -0,0 +1,13 @@ | ||
| connections: | ||
| - name: test | ||
| url: test.eastus | ||
| capacityPolicy: | ||
| ingestionCapacity: | ||
| clusterMaximumConcurrentOperations: 256 | ||
| exportCapacity: | ||
| coreUtilizationCoefficient: 0.5 | ||
| materializedViewsCapacity: | ||
| clusterMaximumConcurrentOperations: 2 | ||
| queryAccelerationCapacity: | ||
| clusterMaximumConcurrentOperations: 75 | ||
| coreUtilizationCoefficient: 0.6 |
16 changes: 16 additions & 0 deletions
16
KustoSchemaTools.Tests/DemoData/ClusterScopedChanges/multipleClusters.yml
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 |
|---|---|---|
| @@ -0,0 +1,16 @@ | ||
| connections: | ||
| - name: test1 | ||
| url: test1.eastus | ||
| capacityPolicy: | ||
| ingestionCapacity: | ||
| clusterMaximumConcurrentOperations: 512 | ||
| coreUtilizationCoefficient: 0.75 | ||
| extentsMergeCapacity: | ||
| minimumConcurrentOperationsPerNode: 1 | ||
| maximumConcurrentOperationsPerNode: 3 | ||
| - name: test2 | ||
| url: test2.eastus | ||
| capacityPolicy: | ||
| ingestionCapacity: | ||
| clusterMaximumConcurrentOperations: 500 | ||
| coreUtilizationCoefficient: 0.8 |
Oops, something went wrong.
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.
Uh oh!
There was an error while loading. Please reload this page.