internal void InternalUpdateCertificateTest(string v1clusterConfigPath, string v2clusterConfigPath, string[] targetClusterManifests) { MockupJsonModel jsonConfig = Utility.GetJsonConfigFromFile(Path.Combine(Constant.TestDirectory, v1clusterConfigPath)); var userConfig = jsonConfig.GetUserConfig(); var clusterTopology = jsonConfig.GetClusterTopology(); var adminConfig = new MockupAdminConfig(); var logger = new MockupTraceLogger(); List <NodeStatus> nodesStatus = new List <NodeStatus>(); foreach (NodeDescription node in clusterTopology.Nodes.Values) { NodeStatus nodeStatus = new NodeStatus() { NodeName = node.NodeName, InstanceId = 0, NodeDeactivationIntent = WrpNodeDeactivationIntent.Invalid, NodeState = NodeState.Enabled, NodeType = node.NodeTypeRef }; nodesStatus.Add(nodeStatus); } MockupCluster clusterResource = new MockupCluster(adminConfig, userConfig, clusterTopology, logger); MockupClusterManifestBuilder v1mockupClusterManifestBuilder = new MockupClusterManifestBuilder( clusterTopology, clusterResource.SeedNodeSelector, userConfig, adminConfig, new ClusterNodeConfig(nodesStatus, 2), new MockupManifestVersionGenerator(), clusterResource.FabricSettingsActivator, clusterResource.ClusterManifestGeneratorSettings, new MockupTraceLogger()); MockupJsonModel v2JsonConfig = Utility.GetJsonConfigFromFile(Path.Combine(Constant.TestDirectory, v2clusterConfigPath)); var v2generatedClusterManifests = v1mockupClusterManifestBuilder.UpdateCertificateInClusterManifest(v1mockupClusterManifestBuilder.GenerateClusterManifest(), v2JsonConfig.Properties.Security, new MockupAdminConfig().GetFabricSettingsMetadata()); XmlSerializer xmlSerializer = new XmlSerializer(typeof(ClusterManifestType)); int i = 0; foreach (string path in targetClusterManifests) { StringWriter generatedClusterManifestWriter = new StringWriter(); xmlSerializer.Serialize(generatedClusterManifestWriter, v2generatedClusterManifests[i++]); string generatedClusterManifestString = generatedClusterManifestWriter.ToString(); var targetClusterManifest = System.Fabric.Interop.Utility.ReadXml <ClusterManifestType>(Path.Combine(Constant.TestDirectory, path), SchemaLocation.GetWindowsFabricSchemaLocation()); StringWriter targetClusterManifestWriter = new StringWriter(); xmlSerializer.Serialize(targetClusterManifestWriter, targetClusterManifest); string targetClusterManifestString = targetClusterManifestWriter.ToString(); Assert.AreEqual(Utility.RemoveRandomGuid(generatedClusterManifestString), Utility.RemoveRandomGuid(targetClusterManifestString)); } }
internal static MockupCluster PopulateClusterWithBaselineJson(string jsonFilePath) { MockupJsonModel jsonConfig = Utility.GetJsonConfigFromFile(Path.Combine(Constant.TestDirectory, jsonFilePath)); var userConfig = jsonConfig.GetUserConfig(); var clusterTopology = jsonConfig.GetClusterTopology(); var adminConfig = new MockupAdminConfig(); var logger = new MockupTraceLogger(); return(new MockupCluster( adminConfig, userConfig, clusterTopology, logger)); }
internal void InternalGenerateClusterManifestTest(string clusterConfigPath, string clusterManifestPath) { MockupJsonModel jsonConfig = Utility.GetJsonConfigFromFile(Path.Combine(Constant.TestDirectory, clusterConfigPath)); var userConfig = jsonConfig.GetUserConfig(); var clusterTopology = jsonConfig.GetClusterTopology(); var adminConfig = new MockupAdminConfig(); var logger = new MockupTraceLogger(); List <NodeStatus> nodesStatus = new List <NodeStatus>(); foreach (NodeDescription node in clusterTopology.Nodes.Values) { NodeStatus nodeStatus = new NodeStatus() { NodeName = node.NodeName, InstanceId = 0, NodeDeactivationIntent = WrpNodeDeactivationIntent.Invalid, NodeState = NodeState.Enabled, NodeType = node.NodeTypeRef }; nodesStatus.Add(nodeStatus); } MockupCluster clusterResource = new MockupCluster(adminConfig, userConfig, clusterTopology, logger); MockupClusterManifestBuilder mockupClusterManifestBuilder = new MockupClusterManifestBuilder( clusterTopology, clusterResource.SeedNodeSelector, userConfig, adminConfig, new ClusterNodeConfig(nodesStatus, 2), new MockupManifestVersionGenerator(), clusterResource.FabricSettingsActivator, clusterResource.ClusterManifestGeneratorSettings, new MockupTraceLogger()); var generatedClusterManifest = mockupClusterManifestBuilder.GenerateClusterManifest(); var expectedClusterManifest = System.Fabric.Interop.Utility.ReadXml <ClusterManifestType>(Path.Combine(Constant.TestDirectory, clusterManifestPath), SchemaLocation.GetWindowsFabricSchemaLocation()); Assert.AreEqual(Utility.RemoveRandomGuid(Utility.GetClusterManifestXMLString(generatedClusterManifest)), Utility.RemoveRandomGuid(Utility.GetClusterManifestXMLString(expectedClusterManifest))); }