pxf icon indicating copy to clipboard operation
pxf copied to clipboard

Pxf cluster config validation

Open djianwen-vmware opened this issue 1 year ago • 0 comments

  • add structs PxfServiceGroup, PxfCluster, PxfHost, and PxfDeployment.
  • add Validation() to PxfDeployment.
  • all the validation rules can be found under config_rules.go as private functions.
  • IsValidAddress() is public for testing purpose
    • this function contains a permissive regex to match FQDN, which means it will return error only if it's obviously an invalid format.
  • add tests with 100% statement coverage for config.go and config_rules.go

Validation rules and its corresponding functions:

  • [x] Attribute values should be valid for their intended types (numbers, booleans, etc): achieved by Golang int, bool, etc. Only need to handle them when parsing the config file.
  • [x] Cluster::name MUST be unique: achieved by Golang map
  • [x] Cluster::collocated MUST not be NULL: achieved by Golang bool
  • [x] Cluster::collocated==true SHOULD NOT have a list of hosts, they WILL be ignored: pxfClusterIgnoreHostsWhenCollocated
  • [x] Cluster::collocated==true SHOULD NOT have a Cluster::endpoint, it WILL be ignored: pxfClusterIgnoreEndpointWhenCollocated
  • [x] Cluster::collocated==false AND Cluster::endpoint==NULL MUST have a non-empty list of hosts: pxfClusterEndpointOrHostsMustExistWhenExternal
  • [x] Cluster::endpoint != NULL MUST have a value of a valid IPv4 or FQDN compliant syntax: pxfClusterValidEndpoint
  • [x] Host::hostname MUST be unique (a single host must belong to only one cluster): pxfDeploymentHostnameUnique
  • [x] Host::hostname MUST have a value with either IPv4 or FQDN compliant syntax: pxfHostValidHostname
  • [x] ServiceGroup::name MUST NOT be null / empty: pxfServiceGroupNameNotEmpty
  • [x] ServiceGroup::name MUST be unique across all Clusters: pxfDeploymentGroupNameUnique
  • [x] ServiceGroup::ports MUST be a non-empty array with at least 1 element: pxfServiceGroupAtLeastOnePort
  • [x] ServiceGroup::ports elements MUST be an integer value between 1-65535: pxfServiceGroupValidPorts
  • [x] ServiceGroup::ports elements SHOULD be larger than 1023 and smaller than 32768 (between privileged and ephemeral ranges): pxfServiceGroupPortsWarning
  • [x] There MUST be at least one Cluster: pxfDeploymentAtLeastOneCluster
  • [x] There MUST be no more than one Cluster::collocated==true: pxfDeploymentNoMoreThanOneCollocated
  • [x] There MUST be at least one ServiceGroup per Cluster: pxfClusterAtLeastOneServiceGroup

djianwen-vmware avatar Apr 03 '24 22:04 djianwen-vmware