public FluxExtensionSetupFixture() { this.cluster = new ClusterInfo( name: "arc-cluster", type: ClusterInfo.ClusterType.connectedClusters, location: "eastus2euap", resourceGroup: "dotnet-sdk-tests" ); this.extension = new Extension( name: "flux", extensionType: "microsoft.flux", identity: new Identity { Type = ResourceIdentityType.SystemAssigned }); using (var context = MockContext.Start(this.GetType())) { using (var testFixture = new ExtensionTestBase(context)) { testFixture.Cluster = cluster; testFixture.Extension = this.extension; testFixture.CreateExtension(); } } }
public void CanCreateUpdateDeleteExtensionInstanceWithIdentity() { ClusterInfo cluster = new ClusterInfo( name: "nanthicluster0923", type: ClusterInfo.ClusterType.connectedClusters, location: "eastus2euap", resourceGroup: "nanthirg0923" ); ExtensionInstance extensionInstance = new ExtensionInstance( name: "microsoft.azuredefender.kubernetes", type: ExtensionTestBase.ConfigurationType, location: "eastus2euap", extensionType: "microsoft.azuredefender.kubernetes", autoUpgradeMinorVersion: false, releaseTrain: "Stable", version: "0.4.61", scope: new Scope( cluster: new ScopeCluster( releaseNamespace: "azuredefender" ) ), identity: new ConfigurationIdentity( type: ResourceIdentityType.SystemAssigned ) ); using (var context = MockContext.Start(this.GetType())) { using (var testFixture = new ExtensionTestBase(context)) { testFixture.Cluster = cluster; testFixture.ExtensionInstance = extensionInstance; // List configurations and get count var extensions = testFixture.ListExtensionInstances(); int extensionCount = extensions.Count(); // Create a configuration var newExtension = testFixture.CreateExtensionInstance(); Assert.NotNull(newExtension); // Get the configuration and verify var ext = testFixture.GetExtensionInstance(); Assert.Equal(extensionInstance.Name, ext.Name); Assert.True((ext.InstallState.ToString() == "Pending") || (ext.InstallState.ToString() == "Installed")); // List configurations and get count to confirm it is up by one extensions = testFixture.ListExtensionInstances(); Assert.True(extensions.Count() == extensionCount + 1); // Delete the configuration created testFixture.DeleteExtensionInstance(); // List configurations and get count to confirm it is what we started with extensions = testFixture.ListExtensionInstances(); Assert.True(extensions.Count() == extensionCount); } } }
public void CanCreateUpdateDeleteExtensionInstanceWithIdentity() { ClusterInfo cluster = new ClusterInfo( name: "arc-cluster", type: ClusterInfo.ClusterType.connectedClusters, location: "eastus2euap", resourceGroup: "dotnet-sdk-tests" ); Extension extensionInstance = new Extension( name: "openservicemesh", type: ExtensionTestBase.ConfigurationType, extensionType: "microsoft.openservicemesh", autoUpgradeMinorVersion: false, releaseTrain: "pilot", version: "1.0.0", scope: new Scope( cluster: new ScopeCluster( releaseNamespace: "servicemesh-system" ) ), identity: new Identity( type: ResourceIdentityType.SystemAssigned ) ); using (var context = MockContext.Start(this.GetType())) { using (var testFixture = new ExtensionTestBase(context)) { testFixture.Cluster = cluster; testFixture.Extension = extensionInstance; // List configurations and get count var extensions = testFixture.ListExtensions(); int extensionCount = extensions.Count(); // Create a configuration var newExtension = testFixture.CreateExtension(); Assert.NotNull(newExtension); // Get the configuration and verify var ext = testFixture.GetExtension(); Assert.Equal(extensionInstance.Name, ext.Name); Assert.True((ext.ProvisioningState.ToString() == "Creating") || (ext.ProvisioningState.ToString() == "Succeeded")); // List configurations and get count to confirm it is up by one extensions = testFixture.ListExtensions(); Assert.True(extensions.Count() == extensionCount + 1); // Delete the configuration created testFixture.DeleteExtension(); // List configurations and get count to confirm it is what we started with extensions = testFixture.ListExtensions(); Assert.True(extensions.Count() == extensionCount); } } }
public void Dispose() { using (var context = MockContext.Start(this.GetType())) { using (var testFixture = new ExtensionTestBase(context)) { testFixture.Cluster = cluster; testFixture.Extension = this.extension; testFixture.DeleteExtension(); } } }
public ConfigXmlBuilder WithRunawayProcessKiller(RunawayProcessKillerExtension ext, string extensionId = "killRunawayProcess", bool enabled = true) { string fullyQualifiedExtensionName = ExtensionTestBase.GetExtensionClassNameWithAssembly(typeof(RunawayProcessKillerExtension)); var str = new StringBuilder(); str.AppendFormat(" <extension enabled=\"{0}\" className=\"{1}\" id=\"{2}\">\n", new object[] { enabled, fullyQualifiedExtensionName, extensionId }); str.AppendFormat(" <pidfile>{0}</pidfile>\n", ext.Pidfile); str.AppendFormat(" <stopTimeout>{0}</stopTimeout>\n", ext.StopTimeout.TotalMilliseconds); str.AppendFormat(" <stopParentFirst>{0}</stopParentFirst>\n", ext.StopParentProcessFirst); str.AppendFormat(" <checkWinSWEnvironmentVariable>{0}</checkWinSWEnvironmentVariable>\n", ext.CheckWinSWEnvironmentVariable); str.Append(" </extension>\n"); this.ExtensionXmls.Add(str.ToString()); return(this); }