Example #1
0
        internal static NodeDescriptionGA CreateNodeDescription(string nodeName, string nodeTypeRef, string iPAddress, string faultDomain, string upgradeDomain)
        {
            NodeDescriptionGA nodeDescription = new NodeDescriptionGA();

            nodeDescription.NodeName      = nodeName;
            nodeDescription.NodeTypeRef   = nodeTypeRef;
            nodeDescription.IPAddress     = iPAddress;
            nodeDescription.FaultDomain   = faultDomain;
            nodeDescription.UpgradeDomain = upgradeDomain;

            return(nodeDescription);
        }
        public void ValidateUpgradeTest()
        {
            // Windows/ GMSA security <-> unsecure is not allowed.
            StandAloneInstallerJSONModelAugust2017 v1model   = Utility.CreateMockupStandAloneJsonModel("testCluster", "1.0.0", security: Utility.CreateGMSASecurity());
            StandAloneInstallerJSONModelAugust2017 v2model   = Utility.CreateMockupStandAloneJsonModel("testCluster", "2.0.0");
            StandaloneSettingsValidator            validator = new StandaloneSettingsValidator(v2model);

            Utility.ValidateExpectedValidationException(
                delegate
            {
                validator.ValidateUpdateFrom(v1model.GetUserConfig(), v1model.GetClusterTopology(), false).GetAwaiter().GetResult();
            },
                ClusterManagementErrorCode.AuthenticationTypeCannotBeChangedFromWindowsToUnsecured);

            // For the same nodename, node IP can't be changed.
            List <NodeDescriptionGA> nodelist   = new List <NodeDescriptionGA>();
            NodeDescriptionGA        node       = Utility.CreateNodeDescription("node1", "NodeType0", "machine1", "fd:/dc1/r0", "UD0");
            List <NodeDescriptionGA> nodelistV2 = new List <NodeDescriptionGA>();
            NodeDescriptionGA        nodeV2     = Utility.CreateNodeDescription("node1", "NodeType0", "machine2", "fd:/dc1/r0", "UD0");

            nodelist.Add(node);
            nodelistV2.Add(nodeV2);
            v1model   = Utility.CreateMockupStandAloneJsonModel("testCluster", "1.0.0", nodes: nodelist);
            v2model   = Utility.CreateMockupStandAloneJsonModel("testCluster", "2.0.0", nodes: nodelistV2);
            validator = new StandaloneSettingsValidator(v2model);

            Utility.ValidateExpectedValidationException(
                delegate
            {
                validator.ValidateUpdateFrom(v1model.GetUserConfig(), v1model.GetClusterTopology(), false).GetAwaiter().GetResult();
            },
                ClusterManagementErrorCode.NodeIPNodeTypeRefCantBeChanged);

            // Reverse proxy port change is allowed.
            v1model = Utility.CreateMockupStandAloneJsonModel("testCluster", "1.0.0");
            v2model = Utility.CreateMockupStandAloneJsonModel("testCluster", "2.0.0");
            foreach (var currentNodeType in v2model.Properties.NodeTypes)
            {
                currentNodeType.ReverseProxyEndpointPort = 19081;
            }
            validator = new StandaloneSettingsValidator(v2model);
            validator.ValidateUpdateFrom(v1model.GetUserConfig(), v1model.GetClusterTopology(), false).GetAwaiter().GetResult();
        }
        public void ValidateTopologyTest()
        {
            // Node name contains invalid characters.
            List <NodeDescriptionGA> nodelist = new List <NodeDescriptionGA>();
            NodeDescriptionGA        node     = Utility.CreateNodeDescription("<", "nodetype1", "machine1", "fd:/dc1/r0", "UD0");

            nodelist.Add(node);
            StandAloneInstallerJSONModelAugust2017 v1model           = Utility.CreateMockupStandAloneJsonModel("testCluster", "1.0.0", nodes: nodelist);
            StandaloneSettingsValidator            settingsValidator = new StandaloneSettingsValidator(v1model);

            Utility.ValidateExpectedValidationException(
                delegate
            {
                settingsValidator.ValidateTopology();
            },
                ClusterManagementErrorCode.NodeNameContainsInvalidChars);

            // Duplicate node name.
            List <NodeDescriptionGA> nodelist2 = new List <NodeDescriptionGA>();
            NodeDescriptionGA        node1     = Utility.CreateNodeDescription("node1", "nodetype1", "machine1", "fd:/dc1/r0", "UD0");
            NodeDescriptionGA        node2     = Utility.CreateNodeDescription("node1", "nodetype1", "machine2", "fd:/dc1/r1", "UD1");

            nodelist2.Add(node1);
            nodelist2.Add(node2);
            v1model = Utility.CreateMockupStandAloneJsonModel("testCluster", "1.0.0", nodes: nodelist2);

            Utility.ValidateExpectedValidationException(
                delegate
            {
                settingsValidator = new StandaloneSettingsValidator(v1model);
            },
                ClusterManagementErrorCode.NodeNameDuplicateDetected);

            // FD count needs to be greater than 2 for multi-box deployment.
            List <NodeDescriptionGA> nodelist4 = new List <NodeDescriptionGA>();

            node1 = Utility.CreateNodeDescription("node1", "nodetype1", "machine1", "fd:/dc1/r0", "UD0");
            node2 = Utility.CreateNodeDescription("node2", "nodetype1", "machine2", "fd:/dc1/r0", "UD1");
            NodeDescriptionGA node3 = Utility.CreateNodeDescription("node3", "nodetype1", "machine3", "fd:/dc1/r0", "UD2");

            nodelist4.Add(node1);
            nodelist4.Add(node2);
            nodelist4.Add(node3);
            v1model           = Utility.CreateMockupStandAloneJsonModel("testCluster", "1.0.0", nodes: nodelist4);
            settingsValidator = new StandaloneSettingsValidator(v1model);

            Utility.ValidateExpectedValidationException(
                delegate
            {
                settingsValidator.ValidateTopology();
            },
                ClusterManagementErrorCode.FDMustBeGreaterThan2);

            // Scale-min should be blocked for multi-box deployment
            List <NodeDescriptionGA> nodelistScaleMin = new List <NodeDescriptionGA>();

            node1 = Utility.CreateNodeDescription("node1", "nodetype1", "machine1", "fd:/dc1/r0", "UD0");
            node2 = Utility.CreateNodeDescription("node2", "nodetype1", "machine1", "fd:/dc1/r1", "UD1");
            node3 = Utility.CreateNodeDescription("node3", "nodetype1", "machine2", "fd:/dc2/r1", "UD2");
            nodelistScaleMin.Add(node1);
            nodelistScaleMin.Add(node2);
            nodelistScaleMin.Add(node3);
            v1model           = Utility.CreateMockupStandAloneJsonModel("testCluster", "1.0.0", nodes: nodelistScaleMin);
            settingsValidator = new StandaloneSettingsValidator(v1model);

            Utility.ValidateExpectedValidationException(
                delegate
            {
                settingsValidator.ValidateTopology();
            },
                ClusterManagementErrorCode.ScaleMinNotAllowed);
        }