예제 #1
0
        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)));
        }
예제 #2
0
        internal void InternalUpdateClusterManifestTest(string v1clusterConfigPath, string v2clusterConfigPath, string targetClusterManifestPath)
        {
            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             v2generatedClusterManifest = v1mockupClusterManifestBuilder.UpdateClusterManifest(v1mockupClusterManifestBuilder.GenerateClusterManifest(), new MockupAdminConfig().GetFabricSettingsMetadata());

            XmlSerializer xmlSerializer = new XmlSerializer(typeof(ClusterManifestType));

            StringWriter generatedClusterManifestWriter = new StringWriter();

            xmlSerializer.Serialize(generatedClusterManifestWriter, v2generatedClusterManifest);
            string generatedClusterManifestString = generatedClusterManifestWriter.ToString();

            var          targetClusterManifest       = System.Fabric.Interop.Utility.ReadXml <ClusterManifestType>(Path.Combine(Constant.TestDirectory, targetClusterManifestPath), SchemaLocation.GetWindowsFabricSchemaLocation());
            StringWriter targetClusterManifestWriter = new StringWriter();

            xmlSerializer.Serialize(targetClusterManifestWriter, targetClusterManifest);
            string targetClusterManifestString = targetClusterManifestWriter.ToString();

            Assert.AreEqual(Utility.RemoveRandomGuid(generatedClusterManifestString), Utility.RemoveRandomGuid(targetClusterManifestString));
        }