diff --git a/models/cluster_test.go b/models/cluster_test.go index 27839d08390a547f77ee42efdef584dab20a3bf8..dea734f70ea822530e83e125a851e19c37135dad 100644 --- a/models/cluster_test.go +++ b/models/cluster_test.go @@ -9,156 +9,26 @@ * See the Mulan PSL v2 for more details. * Author: liqiuyu * Date: 2022-04-19 16:49:51 - * LastEditTime: 2022-04-20 10:30:17 + * LastEditTime: 2024-08-20 10:30:17 * Description: 集群测试用例 ******************************************************************************/ package models import "testing" -func TestGetClusterPropertyFromXml(t *testing.T) { - _ = ` - - 1.0 - Cluster properties used by Pacemaker's scheduler, formerly known as pengine - scheduler properties - - - What to do when the cluster does not have quorum - - What to do when the cluster does not have quorum Allowed values: stop, freeze, ignore, suicide - - - All resources can run anywhere by default - - All resources can run anywhere by default - - - Should the cluster monitor resources and start/stop them as required - - Should the cluster monitor resources and start/stop them as required - - - Always treat start failures as fatal - - When set to TRUE, the cluster will immediately ban a resource from a node if it fails to start there. When FALSE, the cluster will instead check the resource's fail count against its migration-threshold. - - - Should the cluster check for active resources during startup - - Should the cluster check for active resources during startup - - - Failed nodes are STONITH'd - - Failed nodes are STONITH'd - - - Action to send to STONITH device ('poweroff' is a deprecated alias for 'off') - - Action to send to STONITH device ('poweroff' is a deprecated alias for 'off') Allowed values: reboot, off, poweroff - - - How long to wait for the STONITH action (reboot,on,off) to complete - - How long to wait for the STONITH action (reboot,on,off) to complete - - - Enable watchdog integration - - Set automatically by the cluster if SBD is detected. User configured values are ignored. - - - Allow performing fencing operations in parallel - - Allow performing fencing operations in parallel - - - STONITH unseen nodes - - Advanced Use Only! Not using the default is very unsafe! - - - Round trip delay over the network (excluding action execution) - - The "correct" value will depend on the speed and load of your network and cluster nodes. - - - The number of jobs that the TE is allowed to execute in parallel - - The "correct" value will depend on the speed and load of your network and cluster nodes. - - - The number of migration jobs that the TE is allowed to execute in parallel on a node - - The number of migration jobs that the TE is allowed to execute in parallel on a node - - - Should the cluster stop all active resources - - Should the cluster stop all active resources - - - Should deleted resources be stopped - - Should deleted resources be stopped - - - Should deleted actions be cancelled - - Should deleted actions be cancelled - - - Remove resources from the executor after they are stopped - - Always set this to false. Other values are, at best, poorly tested and potentially dangerous. - - - The number of scheduler inputs resulting in ERRORs to save - - Zero to disable, -1 to store unlimited - - - The number of scheduler inputs resulting in WARNINGs to save - - Zero to disable, -1 to store unlimited - - - The number of other scheduler inputs to save - - Zero to disable, -1 to store unlimited - - - The strategy combining node attributes to determine overall node health. - - Requires external entities to create node attributes (named with the prefix '#health') with values: 'red', 'yellow' or 'green'. Allowed values: none, migrate-on-red, only-green, progressive, custom - - - The base score assigned to a node - - Only used when node-health-strategy is set to progressive. - - - The score 'green' translates to in rsc_location constraints - - Only used when node-health-strategy is set to custom or progressive. - - - The score 'yellow' translates to in rsc_location constraints - - Only used when node-health-strategy is set to custom or progressive. - - - The score 'red' translates to in rsc_location constraints - - Only used when node-health-strategy is set to custom or progressive. - - - The strategy to determine resource placement - - The strategy to determine resource placement Allowed values: default, utilization, minimal, balanced - - - ` - // TODO: add test here +func TestGetClusterPropertiesInfo(t *testing.T) { + result := GetClusterPropertiesInfo() + if result["action"] != true { + t.Fatal("Get cluster properties failed") + } +} + +func TestUpdateClusterProperties(t *testing.T) { + clusterPropJson := map[string]interface{}{} + clusterPropJson["no-quorum-policy"] = "ignore" + print(clusterPropJson) + res := UpdateClusterProperties(clusterPropJson) + if res["action"] != true { + t.Fatal("Update cluster properties failed") + } }