From 8c6b77de1a03d538e005234e682ffd4e5dfa2cbe Mon Sep 17 00:00:00 2001 From: Shlomi Noach <2607934+shlomi-noach@users.noreply.github.com> Date: Tue, 9 Jun 2020 11:35:52 +0300 Subject: [PATCH 01/10] API: transition into new terminology --- go/inst/instance.go | 101 +++++++++++++++++++++++++++----------------- 1 file changed, 62 insertions(+), 39 deletions(-) diff --git a/go/inst/instance.go b/go/inst/instance.go index 9a400b8e2..3569567a1 100644 --- a/go/inst/instance.go +++ b/go/inst/instance.go @@ -18,6 +18,7 @@ package inst import ( "database/sql" + "encoding/json" "fmt" "strconv" "strings" @@ -32,50 +33,57 @@ const ReasonableDiscoveryLatency = 500 * time.Millisecond // Instance represents a database instance, including its current configuration & status. // It presents important replication configuration and detailed replication status. type Instance struct { - Key InstanceKey - InstanceAlias string - Uptime uint - ServerID uint - ServerUUID string - Version string - VersionComment string - FlavorName string - ReadOnly bool - Binlog_format string - BinlogRowImage string - LogBinEnabled bool - LogSlaveUpdatesEnabled bool - SelfBinlogCoordinates BinlogCoordinates - MasterKey InstanceKey - MasterUUID string - AncestryUUID string - IsDetachedMaster bool - Slave_SQL_Running bool - Slave_IO_Running bool - ReplicationSQLThreadState ReplicationThreadState - ReplicationIOThreadState ReplicationThreadState - HasReplicationFilters bool - GTIDMode string - SupportsOracleGTID bool - UsingOracleGTID bool - UsingMariaDBGTID bool - UsingPseudoGTID bool - ReadBinlogCoordinates BinlogCoordinates - ExecBinlogCoordinates BinlogCoordinates - IsDetached bool - RelaylogCoordinates BinlogCoordinates - LastSQLError string - LastIOError string - SecondsBehindMaster sql.NullInt64 - SQLDelay uint - ExecutedGtidSet string - GtidPurged string - GtidErrant string + Key InstanceKey + InstanceAlias string + Uptime uint + ServerID uint + ServerUUID string + Version string + VersionComment string + FlavorName string + ReadOnly bool + Binlog_format string + BinlogRowImage string + LogBinEnabled bool + LogSlaveUpdatesEnabled bool + LogReplicationUpdatesEnabled bool + SelfBinlogCoordinates BinlogCoordinates + MasterKey InstanceKey + MasterUUID string + AncestryUUID string + IsDetachedMaster bool + + Slave_SQL_Running bool + ReplicationSQLThreadRuning bool + Slave_IO_Running bool + ReplicationIOThreadRuning bool + ReplicationSQLThreadState ReplicationThreadState + ReplicationIOThreadState ReplicationThreadState + + HasReplicationFilters bool + GTIDMode string + SupportsOracleGTID bool + UsingOracleGTID bool + UsingMariaDBGTID bool + UsingPseudoGTID bool + ReadBinlogCoordinates BinlogCoordinates + ExecBinlogCoordinates BinlogCoordinates + IsDetached bool + RelaylogCoordinates BinlogCoordinates + LastSQLError string + LastIOError string + SecondsBehindMaster sql.NullInt64 + SQLDelay uint + ExecutedGtidSet string + GtidPurged string + GtidErrant string masterExecutedGtidSet string // Not exported SlaveLagSeconds sql.NullInt64 + ReplicationLagSeconds sql.NullInt64 SlaveHosts InstanceKeyMap + Replicas InstanceKeyMap ClusterName string SuggestedClusterAlias string DataCenter string @@ -131,6 +139,21 @@ func NewInstance() *Instance { } } +func (this *Instance) MarshalJSON() ([]byte, error) { + i := struct { + Instance + }{} + i.Instance = *this + // change terminology. Users of the orchestrator API can switch to new terminology and avoid using old terminology + i.Replicas = i.SlaveHosts + i.ReplicationLagSeconds = this.SlaveLagSeconds + i.ReplicationSQLThreadRuning = this.Slave_SQL_Running + i.ReplicationIOThreadRuning = this.Slave_IO_Running + i.LogReplicationUpdatesEnabled = this.LogSlaveUpdatesEnabled + // + return json.Marshal(i) +} + // Equals tests that this instance is the same instance as other. The function does not test // configuration or status. func (this *Instance) Equals(other *Instance) bool { From ff5abb3b8ba897576a1397ebcb178bc4bd7fc776 Mon Sep 17 00:00:00 2001 From: Shlomi Noach <2607934+shlomi-noach@users.noreply.github.com> Date: Tue, 9 Jun 2020 11:44:15 +0300 Subject: [PATCH 02/10] use of ReplicationLagSeconds --- docs/script-samples.md | 2 +- docs/using-the-web-api.md | 4 ++-- resources/public/js/cluster.js | 2 +- resources/public/js/instance-problems.js | 2 +- resources/public/js/orchestrator.js | 8 ++++---- 5 files changed, 9 insertions(+), 9 deletions(-) diff --git a/docs/script-samples.md b/docs/script-samples.md index e23064254..e56300607 100644 --- a/docs/script-samples.md +++ b/docs/script-samples.md @@ -185,7 +185,7 @@ $ orchestrator-client -c api -path instance/$master_host/3306 | jq . "SQLDelay": 0, "ExecutedGtidSet": "", "GtidPurged": "", - "SlaveLagSeconds": { + "ReplicationLagSeconds": { "Int64": 0, "Valid": true }, diff --git a/docs/using-the-web-api.md b/docs/using-the-web-api.md index ba4cff6f5..bd3221556 100644 --- a/docs/using-the-web-api.md +++ b/docs/using-the-web-api.md @@ -86,7 +86,7 @@ This sample is followed by a field breakdown: }, "SQLDelay": 0, "ExecutedGtidSet": "230ea8ea-81e3-11e4-972a-e25ec4bd140a:1-49", - "SlaveLagSeconds": { + "ReplicationLagSeconds": { "Int64": 0, "Valid": true }, @@ -136,7 +136,7 @@ The structure of an Instance evolves and documentation will always fall behind. `"Valid": false` indicates a `NULL` * `SQLDelay`: the configured `MASTER_DELAY` * `ExecutedGtidSet`: if using Oracle GTID, the executed GTID set -* `SlaveLagSeconds`: when `ReplicationLagQuery` provided, the computed replica lag; otherwise same as `SecondsBehindMaster` +* `ReplicationLagSeconds`: when `ReplicationLagQuery` provided, the computed replica lag; otherwise same as `SecondsBehindMaster` * `SlaveHosts`: list of MySQL replicas _hostname & port_) * `ClusterName`: name of cluster this instance is associated with; uniquely identifies cluster * `DataCenter`: (metadata) name of data center, infered by `DataCenterPattern` config variable diff --git a/resources/public/js/cluster.js b/resources/public/js/cluster.js index 92d636a93..1e41bf3f5 100644 --- a/resources/public/js/cluster.js +++ b/resources/public/js/cluster.js @@ -1204,7 +1204,7 @@ function Cluster() { if (isAnonymized()) { instanceDescription = anonymizeInstanceId(instance.id); } - instanceDescription += ", " + instance.SlaveLagSeconds.Int64 + "s lag"; + instanceDescription += ", " + instance.ReplicationLagSeconds.Int64 + "s lag"; incrementProblems("", instanceDescription) instanceFullNames.push(getInstanceTitle(instance.Key.Hostname, instance.Key.Port)); instance.Problems.forEach(function(problem) { diff --git a/resources/public/js/instance-problems.js b/resources/public/js/instance-problems.js index 1974a8fc7..b3d5b9996 100644 --- a/resources/public/js/instance-problems.js +++ b/resources/public/js/instance-problems.js @@ -25,7 +25,7 @@ $(document).ready(function() { function SortByProblemOrder(instance0, instance1) { var orderDiff = instance0.problemOrder - instance1.problemOrder; if (orderDiff != 0) return orderDiff; - var orderDiff = instance1.SlaveLagSeconds.Int64 - instance0.SlaveLagSeconds.Int64; + var orderDiff = instance1.ReplicationLagSeconds.Int64 - instance0.ReplicationLagSeconds.Int64; if (orderDiff != 0) return orderDiff; orderDiff = instance0.title.localeCompare(instance1.title); if (orderDiff != 0) return orderDiff; diff --git a/resources/public/js/orchestrator.js b/resources/public/js/orchestrator.js index f94489e9c..fb8b658cf 100644 --- a/resources/public/js/orchestrator.js +++ b/resources/public/js/orchestrator.js @@ -276,7 +276,7 @@ function openNodeModal(node) { } } addNodeModalDataAttribute("Seconds behind master", node.SecondsBehindMaster.Valid ? node.SecondsBehindMaster.Int64 : "null"); - addNodeModalDataAttribute("Replication lag", node.SlaveLagSeconds.Valid ? node.SlaveLagSeconds.Int64 : "null"); + addNodeModalDataAttribute("Replication lag", node.ReplicationLagSeconds.Valid ? node.ReplicationLagSeconds.Int64 : "null"); addNodeModalDataAttribute("SQL delay", node.SQLDelay); var masterCoordinatesEl = addNodeModalDataAttribute("Master coordinates", node.ExecBinlogCoordinates.LogFile + ":" + node.ExecBinlogCoordinates.LogPos); @@ -605,7 +605,7 @@ function normalizeInstance(instance) { instance.replicationRunning = instance.Slave_SQL_Running && instance.Slave_IO_Running; instance.replicationAttemptingToRun = instance.Slave_SQL_Running || instance.Slave_IO_Running; - instance.replicationLagReasonable = Math.abs(instance.SlaveLagSeconds.Int64 - instance.SQLDelay) <= 10; + instance.replicationLagReasonable = Math.abs(instance.ReplicationLagSeconds.Int64 - instance.SQLDelay) <= 10; instance.isSeenRecently = instance.SecondsSinceLastSeen.Valid && instance.SecondsSinceLastSeen.Int64 <= 3600; instance.supportsGTID = instance.SupportsOracleGTID || instance.UsingMariaDBGTID; instance.usingGTID = instance.UsingOracleGTID || instance.UsingMariaDBGTID; @@ -709,7 +709,7 @@ function createVirtualInstance() { isMaster: false, isCoMaster: false, isVirtual: true, - SlaveLagSeconds: 0, + ReplicationLagSeconds: 0, SecondsSinceLastSeen: 0 } normalizeInstanceProblem(virtualInstance); @@ -944,7 +944,7 @@ function renderInstanceElement(popoverElement, instance, renderType) { if (instance.renderHint != "") { popoverElement.find("h3").addClass("label-" + instance.renderHint); } - var statusMessage = formattedInterval(instance.SlaveLagSeconds.Int64) + ' lag'; + var statusMessage = formattedInterval(instance.ReplicationLagSeconds.Int64) + ' lag'; if (indicateLastSeenInStatus) { statusMessage = 'seen ' + formattedInterval(instance.SecondsSinceLastSeen.Int64) + ' ago'; } From 4390100ac1b59a9bfb88fb28f5d39a9e17b589f9 Mon Sep 17 00:00:00 2001 From: Shlomi Noach <2607934+shlomi-noach@users.noreply.github.com> Date: Tue, 9 Jun 2020 11:45:43 +0300 Subject: [PATCH 03/10] use of LogReplicationUpdatesEnabled --- docs/script-samples.md | 2 +- docs/using-the-web-api.md | 4 ++-- resources/public/js/cluster.js | 14 +++++++------- resources/public/js/orchestrator.js | 6 +++--- 4 files changed, 13 insertions(+), 13 deletions(-) diff --git a/docs/script-samples.md b/docs/script-samples.md index e56300607..d50435e15 100644 --- a/docs/script-samples.md +++ b/docs/script-samples.md @@ -141,7 +141,7 @@ $ orchestrator-client -c api -path instance/$master_host/3306 | jq . "Binlog_format": "ROW", "BinlogRowImage": "FULL", "LogBinEnabled": true, - "LogSlaveUpdatesEnabled": true, + "LogReplicationUpdatesEnabled": true, "SelfBinlogCoordinates": { "LogFile": "mysql-bin.000002", "LogPos": 333006336, diff --git a/docs/using-the-web-api.md b/docs/using-the-web-api.md index bd3221556..9af93d9cb 100644 --- a/docs/using-the-web-api.md +++ b/docs/using-the-web-api.md @@ -46,7 +46,7 @@ This sample is followed by a field breakdown: "ReadOnly": false, "Binlog_format": "ROW", "LogBinEnabled": true, - "LogSlaveUpdatesEnabled": true, + "LogReplicationUpdatesEnabled": true, "SelfBinlogCoordinates": { "LogFile": "mysql-bin.015656", "LogPos": 15082, @@ -117,7 +117,7 @@ The structure of an Instance evolves and documentation will always fall behind. * `ReadOnly`: the global `read_only` boolean value * `Binlog_format`: the global `binlog_format` MySQL param * `LogBinEnabled`: whether binary logs are enabled -* `LogSlaveUpdatesEnabled`: whether `log_slave_updates` MySQL param is enabled +* `LogReplicationUpdatesEnabled`: whether `log_slave_updates` MySQL param is enabled * `SelfBinlogCoordinates`: binary log file & position this instance write to (as in `SHOW MASTER STATUS`) * `MasterKey`: hostname & port of master, if any * `Slave_SQL_Running`: direct mapping from `SHOW SLAVE STATUS`'s `Slave_SQL_Running` diff --git a/resources/public/js/cluster.js b/resources/public/js/cluster.js index 1e41bf3f5..b67b3e087 100644 --- a/resources/public/js/cluster.js +++ b/resources/public/js/cluster.js @@ -441,7 +441,7 @@ function Cluster() { } if (droppableNode.MasterKey.Hostname && droppableNode.MasterKey.Hostname != "_") { // droppableNode has master - if (!droppableNode.LogSlaveUpdatesEnabled) { + if (!droppableNode.LogReplicationUpdatesEnabled) { // Obviously can't handle. return { accept: false @@ -518,7 +518,7 @@ function Cluster() { } if (droppableNode.MasterKey.Hostname && droppableNode.MasterKey.Hostname != "_") { // droppableNode has master - if (!droppableNode.LogSlaveUpdatesEnabled) { + if (!droppableNode.LogReplicationUpdatesEnabled) { // Obviously can't handle. return { accept: false @@ -624,7 +624,7 @@ function Cluster() { }; } if (instancesAreSiblings(node, droppableNode)) { - if (node.hasProblem || droppableNode.hasProblem || droppableNode.isAggregate || !droppableNode.LogSlaveUpdatesEnabled) { + if (node.hasProblem || droppableNode.hasProblem || droppableNode.isAggregate || !droppableNode.LogReplicationUpdatesEnabled) { return { accept: false }; @@ -787,7 +787,7 @@ function Cluster() { } if (droppableNode.MasterKey.Hostname && droppableNode.MasterKey.Hostname != "_") { // droppableNode has master - if (!droppableNode.LogSlaveUpdatesEnabled) { + if (!droppableNode.LogReplicationUpdatesEnabled) { // Obviously can't handle. return { accept: false @@ -842,7 +842,7 @@ function Cluster() { } if (droppableNode.MasterKey.Hostname && droppableNode.MasterKey.Hostname != "_") { // droppableNode has master - if (!droppableNode.LogSlaveUpdatesEnabled) { + if (!droppableNode.LogReplicationUpdatesEnabled) { // Obviously can't handle. return { accept: false @@ -1553,7 +1553,7 @@ function Cluster() { if (replica.SQLDelay > 0) { return } - if (!replica.LogSlaveUpdatesEnabled) { + if (!replica.LogReplicationUpdatesEnabled) { return } if (replica.lastCheckInvalidProblem()) { @@ -1580,7 +1580,7 @@ function Cluster() { if (!sibling.LogBinEnabled) { return } - if (!sibling.LogSlaveUpdatesEnabled) { + if (!sibling.LogReplicationUpdatesEnabled) { return } if (sibling.lastCheckInvalidProblem()) { diff --git a/resources/public/js/orchestrator.js b/resources/public/js/orchestrator.js index fb8b658cf..704032f04 100644 --- a/resources/public/js/orchestrator.js +++ b/resources/public/js/orchestrator.js @@ -333,7 +333,7 @@ function openNodeModal(node) { format = format + "/" + node.BinlogRowImage; } addNodeModalDataAttribute("Binlog format", format); - var td = addNodeModalDataAttribute("Logs slave updates", booleanString(node.LogSlaveUpdatesEnabled)); + var td = addNodeModalDataAttribute("Logs slave updates", booleanString(node.LogReplicationUpdatesEnabled)); $('#node_modal button[data-btn=take-siblings]').appendTo(td.find("div")) } @@ -551,7 +551,7 @@ function openNodeModal(node) { }); $('#node_modal button[data-btn=take-siblings]').hide(); - if (node.LogBinEnabled && node.LogSlaveUpdatesEnabled) { + if (node.LogBinEnabled && node.LogReplicationUpdatesEnabled) { $('#node_modal button[data-btn=take-siblings]').show(); } $('#node_modal button[data-btn=take-siblings]').click(function() { @@ -905,7 +905,7 @@ function renderInstanceElement(popoverElement, instance, renderType) { if (instance.SemiSyncReplicaStatus) { popoverElement.find("h3 div.pull-right").prepend(' '); } - if (instance.LogBinEnabled && instance.LogSlaveUpdatesEnabled) { + if (instance.LogBinEnabled && instance.LogReplicationUpdatesEnabled) { popoverElement.find("h3 div.pull-right").prepend(' '); } if (instance.IsCandidate) { From ec3bba21f96cd1c85f7c5113def094be20512b0b Mon Sep 17 00:00:00 2001 From: Shlomi Noach <2607934+shlomi-noach@users.noreply.github.com> Date: Tue, 9 Jun 2020 11:48:07 +0300 Subject: [PATCH 04/10] UI language --- resources/public/js/orchestrator.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/resources/public/js/orchestrator.js b/resources/public/js/orchestrator.js index 704032f04..f60d10d84 100644 --- a/resources/public/js/orchestrator.js +++ b/resources/public/js/orchestrator.js @@ -333,7 +333,7 @@ function openNodeModal(node) { format = format + "/" + node.BinlogRowImage; } addNodeModalDataAttribute("Binlog format", format); - var td = addNodeModalDataAttribute("Logs slave updates", booleanString(node.LogReplicationUpdatesEnabled)); + var td = addNodeModalDataAttribute("Logs replication updates", booleanString(node.LogReplicationUpdatesEnabled)); $('#node_modal button[data-btn=take-siblings]').appendTo(td.find("div")) } @@ -906,7 +906,7 @@ function renderInstanceElement(popoverElement, instance, renderType) { popoverElement.find("h3 div.pull-right").prepend(' '); } if (instance.LogBinEnabled && instance.LogReplicationUpdatesEnabled) { - popoverElement.find("h3 div.pull-right").prepend(' '); + popoverElement.find("h3 div.pull-right").prepend(' '); } if (instance.IsCandidate) { popoverElement.find("h3 div.pull-right").prepend(' '); From 57d856b9c91aee1e95eff4368c6b7474e802575e Mon Sep 17 00:00:00 2001 From: Shlomi Noach <2607934+shlomi-noach@users.noreply.github.com> Date: Tue, 9 Jun 2020 11:50:58 +0300 Subject: [PATCH 05/10] use of ReplicationSQLThreadRuning --- docs/script-samples.md | 2 +- docs/using-the-web-api.md | 4 ++-- resources/bin/orchestrator-client | 4 ++-- resources/public/js/orchestrator.js | 6 +++--- 4 files changed, 8 insertions(+), 8 deletions(-) diff --git a/docs/script-samples.md b/docs/script-samples.md index d50435e15..0fffdea2c 100644 --- a/docs/script-samples.md +++ b/docs/script-samples.md @@ -152,7 +152,7 @@ $ orchestrator-client -c api -path instance/$master_host/3306 | jq . "Port": 0 }, "IsDetachedMaster": false, - "Slave_SQL_Running": false, + "ReplicationSQLThreadRuning": false, "Slave_IO_Running": false, "HasReplicationFilters": false, "GTIDMode": "OFF", diff --git a/docs/using-the-web-api.md b/docs/using-the-web-api.md index 9af93d9cb..d48018442 100644 --- a/docs/using-the-web-api.md +++ b/docs/using-the-web-api.md @@ -56,7 +56,7 @@ This sample is followed by a field breakdown: "Hostname": "mysql.01.instance.com", "Port": 3306 }, - "Slave_SQL_Running": true, + "ReplicationSQLThreadRuning": true, "Slave_IO_Running": true, "HasReplicationFilters": false, "SupportsOracleGTID": true, @@ -120,7 +120,7 @@ The structure of an Instance evolves and documentation will always fall behind. * `LogReplicationUpdatesEnabled`: whether `log_slave_updates` MySQL param is enabled * `SelfBinlogCoordinates`: binary log file & position this instance write to (as in `SHOW MASTER STATUS`) * `MasterKey`: hostname & port of master, if any -* `Slave_SQL_Running`: direct mapping from `SHOW SLAVE STATUS`'s `Slave_SQL_Running` +* `ReplicationSQLThreadRuning`: direct mapping from `SHOW SLAVE STATUS`'s `Slave_SQL_Running` * `Slave_IO_Running`: direct mapping from `SHOW SLAVE STATUS`'s `Slave_IO_Running` * `HasReplicationFilters`: true if there's any replication filter * `SupportsOracleGTID`: true if cnfigured with `gtid_mode` (Oracle MySQL >= 5.6) diff --git a/resources/bin/orchestrator-client b/resources/bin/orchestrator-client index 9465e6b30..b68f884a0 100755 --- a/resources/bin/orchestrator-client +++ b/resources/bin/orchestrator-client @@ -313,11 +313,11 @@ function filter_keys { } function filter_broken_replicas { - cat - | jq '.[] | select((.Slave_SQL_Running == false or .Slave_IO_Running == false) and (.LastSQLError != "" or .LastIOError != "")) | [.]' + cat - | jq '.[] | select((.ReplicationSQLThreadRuning == false or .Slave_IO_Running == false) and (.LastSQLError != "" or .LastIOError != "")) | [.]' } function filter_running_replicas { - cat - | jq '.[] | select(.Slave_SQL_Running == true and .Slave_IO_Running == true) | [.]' + cat - | jq '.[] | select(.ReplicationSQLThreadRuning == true and .Slave_IO_Running == true) | [.]' } function print_key { diff --git a/resources/public/js/orchestrator.js b/resources/public/js/orchestrator.js index f60d10d84..312c30b2c 100644 --- a/resources/public/js/orchestrator.js +++ b/resources/public/js/orchestrator.js @@ -514,7 +514,7 @@ function openNodeModal(node) { } else if (!node.replicationRunning) { $('#node_modal button[data-btn=start-replica]').show(); } - if (!node.Slave_SQL_Running && node.LastSQLError) { + if (!node.ReplicationSQLThreadRuning && node.LastSQLError) { $('#node_modal button[data-btn=skip-query]').show(); } } @@ -603,8 +603,8 @@ function normalizeInstance(instance) { instance.masterId = getInstanceId(instance.MasterKey.Hostname, instance.MasterKey.Port); - instance.replicationRunning = instance.Slave_SQL_Running && instance.Slave_IO_Running; - instance.replicationAttemptingToRun = instance.Slave_SQL_Running || instance.Slave_IO_Running; + instance.replicationRunning = instance.ReplicationSQLThreadRuning && instance.Slave_IO_Running; + instance.replicationAttemptingToRun = instance.ReplicationSQLThreadRuning || instance.Slave_IO_Running; instance.replicationLagReasonable = Math.abs(instance.ReplicationLagSeconds.Int64 - instance.SQLDelay) <= 10; instance.isSeenRecently = instance.SecondsSinceLastSeen.Valid && instance.SecondsSinceLastSeen.Int64 <= 3600; instance.supportsGTID = instance.SupportsOracleGTID || instance.UsingMariaDBGTID; From 9a215e5a4b3c853e48ab81b250dba204fe5e049f Mon Sep 17 00:00:00 2001 From: Shlomi Noach <2607934+shlomi-noach@users.noreply.github.com> Date: Tue, 9 Jun 2020 11:52:30 +0300 Subject: [PATCH 06/10] use of ReplicationIOThreadRuning --- docs/script-samples.md | 2 +- docs/using-the-web-api.md | 4 ++-- resources/bin/orchestrator-client | 4 ++-- resources/public/js/orchestrator.js | 4 ++-- 4 files changed, 7 insertions(+), 7 deletions(-) diff --git a/docs/script-samples.md b/docs/script-samples.md index 0fffdea2c..a516ecf12 100644 --- a/docs/script-samples.md +++ b/docs/script-samples.md @@ -153,7 +153,7 @@ $ orchestrator-client -c api -path instance/$master_host/3306 | jq . }, "IsDetachedMaster": false, "ReplicationSQLThreadRuning": false, - "Slave_IO_Running": false, + "ReplicationIOThreadRuning": false, "HasReplicationFilters": false, "GTIDMode": "OFF", "SupportsOracleGTID": false, diff --git a/docs/using-the-web-api.md b/docs/using-the-web-api.md index d48018442..c989de022 100644 --- a/docs/using-the-web-api.md +++ b/docs/using-the-web-api.md @@ -57,7 +57,7 @@ This sample is followed by a field breakdown: "Port": 3306 }, "ReplicationSQLThreadRuning": true, - "Slave_IO_Running": true, + "ReplicationIOThreadRuning": true, "HasReplicationFilters": false, "SupportsOracleGTID": true, "UsingOracleGTID": true, @@ -121,7 +121,7 @@ The structure of an Instance evolves and documentation will always fall behind. * `SelfBinlogCoordinates`: binary log file & position this instance write to (as in `SHOW MASTER STATUS`) * `MasterKey`: hostname & port of master, if any * `ReplicationSQLThreadRuning`: direct mapping from `SHOW SLAVE STATUS`'s `Slave_SQL_Running` -* `Slave_IO_Running`: direct mapping from `SHOW SLAVE STATUS`'s `Slave_IO_Running` +* `ReplicationIOThreadRuning`: direct mapping from `SHOW SLAVE STATUS`'s `Slave_IO_Running` * `HasReplicationFilters`: true if there's any replication filter * `SupportsOracleGTID`: true if cnfigured with `gtid_mode` (Oracle MySQL >= 5.6) * `UsingOracleGTID`: true if replica replicates via Oracle GTID diff --git a/resources/bin/orchestrator-client b/resources/bin/orchestrator-client index b68f884a0..d68b6ee4c 100755 --- a/resources/bin/orchestrator-client +++ b/resources/bin/orchestrator-client @@ -313,11 +313,11 @@ function filter_keys { } function filter_broken_replicas { - cat - | jq '.[] | select((.ReplicationSQLThreadRuning == false or .Slave_IO_Running == false) and (.LastSQLError != "" or .LastIOError != "")) | [.]' + cat - | jq '.[] | select((.ReplicationSQLThreadRuning == false or .ReplicationIOThreadRuning == false) and (.LastSQLError != "" or .LastIOError != "")) | [.]' } function filter_running_replicas { - cat - | jq '.[] | select(.ReplicationSQLThreadRuning == true and .Slave_IO_Running == true) | [.]' + cat - | jq '.[] | select(.ReplicationSQLThreadRuning == true and .ReplicationIOThreadRuning == true) | [.]' } function print_key { diff --git a/resources/public/js/orchestrator.js b/resources/public/js/orchestrator.js index 312c30b2c..40d5dd440 100644 --- a/resources/public/js/orchestrator.js +++ b/resources/public/js/orchestrator.js @@ -603,8 +603,8 @@ function normalizeInstance(instance) { instance.masterId = getInstanceId(instance.MasterKey.Hostname, instance.MasterKey.Port); - instance.replicationRunning = instance.ReplicationSQLThreadRuning && instance.Slave_IO_Running; - instance.replicationAttemptingToRun = instance.ReplicationSQLThreadRuning || instance.Slave_IO_Running; + instance.replicationRunning = instance.ReplicationSQLThreadRuning && instance.ReplicationIOThreadRuning; + instance.replicationAttemptingToRun = instance.ReplicationSQLThreadRuning || instance.ReplicationIOThreadRuning; instance.replicationLagReasonable = Math.abs(instance.ReplicationLagSeconds.Int64 - instance.SQLDelay) <= 10; instance.isSeenRecently = instance.SecondsSinceLastSeen.Valid && instance.SecondsSinceLastSeen.Int64 <= 3600; instance.supportsGTID = instance.SupportsOracleGTID || instance.UsingMariaDBGTID; From 322e5671385a5c065ae303650675cb44000b1963 Mon Sep 17 00:00:00 2001 From: Shlomi Noach <2607934+shlomi-noach@users.noreply.github.com> Date: Tue, 9 Jun 2020 11:55:06 +0300 Subject: [PATCH 07/10] use of Replicas --- docs/script-samples.md | 6 +++--- docs/using-the-web-api.md | 6 +++--- resources/public/js/audit-failure-detection.js | 4 ++-- resources/public/js/audit-recovery.js | 4 ++-- resources/public/js/orchestrator.js | 4 ++-- 5 files changed, 12 insertions(+), 12 deletions(-) diff --git a/docs/script-samples.md b/docs/script-samples.md index a516ecf12..0cf53e78f 100644 --- a/docs/script-samples.md +++ b/docs/script-samples.md @@ -189,7 +189,7 @@ $ orchestrator-client -c api -path instance/$master_host/3306 | jq . "Int64": 0, "Valid": true }, - "SlaveHosts": [ + "Replicas": [ { "Hostname": "mysql-2222.dc1.domain.net", "Port": 3306 @@ -286,14 +286,14 @@ mysql-00ff.dc1.domain.net #### How many replicas to a specific instance? ```shell -$ orchestrator-client -c api -path instance/$master_host/3306 | jq '.SlaveHosts | length' +$ orchestrator-client -c api -path instance/$master_host/3306 | jq '.Replicas | length' 3 ``` #### How many replicas to each of a cluster's members? ```shell -$ orchestrator-client -c api -path cluster/alias/mycluster | jq '.[].SlaveHosts | length' +$ orchestrator-client -c api -path cluster/alias/mycluster | jq '.[].Replicas | length' 3 0 2 diff --git a/docs/using-the-web-api.md b/docs/using-the-web-api.md index c989de022..e522d2a48 100644 --- a/docs/using-the-web-api.md +++ b/docs/using-the-web-api.md @@ -90,7 +90,7 @@ This sample is followed by a field breakdown: "Int64": 0, "Valid": true }, - "SlaveHosts": [ ], + "Replicas": [ ], "ClusterName": "mysql.01.instance.com:3306", "DataCenter": "", "PhysicalEnvironment": "", @@ -137,7 +137,7 @@ The structure of an Instance evolves and documentation will always fall behind. * `SQLDelay`: the configured `MASTER_DELAY` * `ExecutedGtidSet`: if using Oracle GTID, the executed GTID set * `ReplicationLagSeconds`: when `ReplicationLagQuery` provided, the computed replica lag; otherwise same as `SecondsBehindMaster` -* `SlaveHosts`: list of MySQL replicas _hostname & port_) +* `Replicas`: list of MySQL replicas _hostname & port_) * `ClusterName`: name of cluster this instance is associated with; uniquely identifies cluster * `DataCenter`: (metadata) name of data center, infered by `DataCenterPattern` config variable * `PhysicalEnvironment`: (metadata) name of environment, infered by `PhysicalEnvironmentPattern` config variable @@ -191,5 +191,5 @@ curl -s "http://my.orchestrator.service.com/api/instance-replicas/${master}" | j - Find all intermediate masters in `my_cluster`: ``` -curl -s "http://my.orchestrator.service.com/api/cluster/alias/my_cluster" | jq '.[] | select(.MasterKey.Hostname!="") | select(.SlaveHosts!=[]) .Key.Hostname' +curl -s "http://my.orchestrator.service.com/api/cluster/alias/my_cluster" | jq '.[] | select(.MasterKey.Hostname!="") | select(.Replicas!=[]) .Key.Hostname' ``` diff --git a/resources/public/js/audit-failure-detection.js b/resources/public/js/audit-failure-detection.js index 7c35a69bc..f8533be39 100644 --- a/resources/public/js/audit-failure-detection.js +++ b/resources/public/js/audit-failure-detection.js @@ -52,9 +52,9 @@ $(document).ready(function() { var moreInfo = ""; moreInfo += '
Detected: ' + audit.RecoveryStartTimestamp + '
'; - if (audit.AnalysisEntry.SlaveHosts.length > 0) { + if (audit.AnalysisEntry.Replicas.length > 0) { moreInfo += '
' + audit.AnalysisEntry.CountReplicas + ' replicating hosts :
"; diff --git a/resources/public/js/audit-recovery.js b/resources/public/js/audit-recovery.js index d45f83e7e..2461a350c 100644 --- a/resources/public/js/audit-recovery.js +++ b/resources/public/js/audit-recovery.js @@ -46,9 +46,9 @@ $(document).ready(function() { }); moreInfo += ""; } - if (audit.AnalysisEntry.SlaveHosts.length > 0) { + if (audit.AnalysisEntry.Replicas.length > 0) { moreInfo += '
' + audit.AnalysisEntry.CountReplicas + ' replicating hosts :
"; diff --git a/resources/public/js/orchestrator.js b/resources/public/js/orchestrator.js index 40d5dd440..ecaadd177 100644 --- a/resources/public/js/orchestrator.js +++ b/resources/public/js/orchestrator.js @@ -315,7 +315,7 @@ function openNodeModal(node) { if (node.LogBinEnabled) { addNodeModalDataAttribute("Self coordinates", node.SelfBinlogCoordinates.LogFile + ":" + node.SelfBinlogCoordinates.LogPos); } - var td = addNodeModalDataAttribute("Num replicas", node.SlaveHosts.length); + var td = addNodeModalDataAttribute("Num replicas", node.Replicas.length); $('#node_modal button[data-btn=regroup-replicas]').appendTo(td.find("div")) addNodeModalDataAttribute("Server ID", node.ServerID); if (node.ServerUUID) { @@ -536,7 +536,7 @@ function openNodeModal(node) { } $('#node_modal button[data-btn=regroup-replicas]').hide(); - if (node.SlaveHosts.length > 1) { + if (node.Replicas.length > 1) { $('#node_modal button[data-btn=regroup-replicas]').show(); } $('#node_modal button[data-btn=regroup-replicas]').click(function() { From 92b8bed42fa4869a97cd3b6d6ab2587d5cf0b974 Mon Sep 17 00:00:00 2001 From: Shlomi Noach <2607934+shlomi-noach@users.noreply.github.com> Date: Tue, 9 Jun 2020 11:56:10 +0300 Subject: [PATCH 08/10] use of Replicas --- tests/integration/instance_dao_test.go | 383 ------------------ .../co-master-failover/05-count-replicas/run | 2 +- .../03-count-replicas/run | 2 +- .../03-count-replicas/run | 2 +- .../03-count-replicas/run | 2 +- .../03-count-replicas/run | 2 +- .../master-failover/03-count-replicas/run | 2 +- 7 files changed, 6 insertions(+), 389 deletions(-) delete mode 100644 tests/integration/instance_dao_test.go diff --git a/tests/integration/instance_dao_test.go b/tests/integration/instance_dao_test.go deleted file mode 100644 index 751fe92ac..000000000 --- a/tests/integration/instance_dao_test.go +++ /dev/null @@ -1,383 +0,0 @@ -/* - Copyright 2014 Outbrain Inc. - - Licensed under the Apache License, Version 2.0 (the "License"); - you may not use this file except in compliance with the License. - You may obtain a copy of the License at - - http://www.apache.org/licenses/LICENSE-2.0 - - Unless required by applicable law or agreed to in writing, software - distributed under the License is distributed on an "AS IS" BASIS, - WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - See the License for the specific language governing permissions and - limitations under the License. -*/ - -package inst - -import ( - "github.com/openark/orchestrator/go/config" - "github.com/openark/orchestrator/go/db" - . "gopkg.in/check.v1" - "math/rand" - "testing" - "time" -) - -func Test(t *testing.T) { TestingT(t) } - -type TestSuite struct{} - -var _ = Suite(&TestSuite{}) - -// This test suite assumes one master and three direct replicas, as follows; -// This was setup with mysqlsandbox (using MySQL 5.5.32, not that it matters) via: -// $ make_replication_sandbox --how_many_nodes=3 --replication_directory=55orchestrator /path/to/sandboxes/5.5.32 -// modify below to fit your own environment -var masterKey = InstanceKey{ - Hostname: "127.0.0.1", - Port: 22987, -} -var slave1Key = InstanceKey{ - Hostname: "127.0.0.1", - Port: 22988, -} -var slave2Key = InstanceKey{ - Hostname: "127.0.0.1", - Port: 22989, -} -var slave3Key = InstanceKey{ - Hostname: "127.0.0.1", - Port: 22990, -} - -func clearTestMaintenance() { - _, _ = db.ExecOrchestrator("update database_instance_maintenance set maintenance_active=null, end_timestamp=NOW() where owner = ?", "unittest") -} - -// The test also assumes one backend MySQL server. -func (s *TestSuite) SetUpSuite(c *C) { - config.Config.MySQLTopologyUser = "msandbox" - config.Config.MySQLTopologyPassword = "msandbox" - config.Config.MySQLOrchestratorHost = "127.0.0.1" - config.Config.MySQLOrchestratorPort = 5622 - config.Config.MySQLOrchestratorDatabase = "orchestrator" - config.Config.MySQLOrchestratorUser = "msandbox" - config.Config.MySQLOrchestratorPassword = "msandbox" - config.Config.DiscoverByShowSlaveHosts = true - - _, _ = db.ExecOrchestrator("delete from database_instance where hostname = ? and port = ?", masterKey.Hostname, masterKey.Port) - _, _ = db.ExecOrchestrator("delete from database_instance where hostname = ? and port = ?", slave1Key.Hostname, slave1Key.Port) - _, _ = db.ExecOrchestrator("delete from database_instance where hostname = ? and port = ?", slave2Key.Hostname, slave2Key.Port) - _, _ = db.ExecOrchestrator("delete from database_instance where hostname = ? and port = ?", slave3Key.Hostname, slave3Key.Port) - - ExecInstance(&masterKey, "drop database if exists orchestrator_test") - ExecInstance(&masterKey, "create database orchestrator_test") - ExecInstance(&masterKey, `create table orchestrator_test.test_table( - name varchar(128) charset ascii not null primary key, - value varchar(128) charset ascii not null - )`) - rand.Seed(time.Now().UTC().UnixNano()) -} - -func (s *TestSuite) TestReadTopologyMaster(c *C) { - key := masterKey - i, _ := ReadTopologyInstance(&key) - - c.Assert(i.Key.Hostname, Equals, key.Hostname) - c.Assert(i.IsReplica(), Equals, false) - c.Assert(len(i.SlaveHosts), Equals, 3) - c.Assert(len(i.SlaveHosts.GetInstanceKeys()), Equals, len(i.SlaveHosts)) -} - -func (s *TestSuite) TestReadTopologySlave(c *C) { - key := slave3Key - i, _ := ReadTopologyInstance(&key) - c.Assert(i.Key.Hostname, Equals, key.Hostname) - c.Assert(i.IsReplica(), Equals, true) - c.Assert(len(i.SlaveHosts), Equals, 0) -} - -func (s *TestSuite) TestReadTopologyAndInstanceMaster(c *C) { - i, _ := ReadTopologyInstance(&masterKey) - iRead, found, _ := ReadInstance(&masterKey) - c.Assert(found, Equals, true) - c.Assert(iRead.Key.Hostname, Equals, i.Key.Hostname) - c.Assert(iRead.Version, Equals, i.Version) - c.Assert(len(iRead.SlaveHosts), Equals, len(i.SlaveHosts)) -} - -func (s *TestSuite) TestReadTopologyAndInstanceSlave(c *C) { - i, _ := ReadTopologyInstance(&slave1Key) - iRead, found, _ := ReadInstance(&slave1Key) - c.Assert(found, Equals, true) - c.Assert(iRead.Key.Hostname, Equals, i.Key.Hostname) - c.Assert(iRead.Version, Equals, i.Version) -} - -func (s *TestSuite) TestGetMasterOfASlave(c *C) { - i, err := ReadTopologyInstance(&slave1Key) - c.Assert(err, IsNil) - master, err := GetInstanceMaster(i) - c.Assert(err, IsNil) - c.Assert(master.IsReplica(), Equals, false) - c.Assert(master.Key.Port, Equals, 22987) -} - -func (s *TestSuite) TestSlavesAreSiblings(c *C) { - i0, _ := ReadTopologyInstance(&slave1Key) - i1, _ := ReadTopologyInstance(&slave2Key) - c.Assert(InstancesAreSiblings(i0, i1), Equals, true) -} - -func (s *TestSuite) TestNonSiblings(c *C) { - i0, _ := ReadTopologyInstance(&masterKey) - i1, _ := ReadTopologyInstance(&slave1Key) - c.Assert(InstancesAreSiblings(i0, i1), Not(Equals), true) -} - -func (s *TestSuite) TestInstanceIsMasterOf(c *C) { - i0, _ := ReadTopologyInstance(&masterKey) - i1, _ := ReadTopologyInstance(&slave1Key) - c.Assert(InstanceIsMasterOf(i0, i1), Equals, true) -} - -func (s *TestSuite) TestStopStartSlave(c *C) { - - i, _ := ReadTopologyInstance(&slave1Key) - c.Assert(i.ReplicaRunning(), Equals, true) - i, _ = StopSlaveNicely(&i.Key, 0) - - c.Assert(i.ReplicaRunning(), Equals, false) - c.Assert(i.SQLThreadUpToDate(), Equals, true) - - i, _ = StartSlave(&i.Key) - c.Assert(i.ReplicaRunning(), Equals, true) -} - -func (s *TestSuite) TestReadTopologyUnexisting(c *C) { - key := InstanceKey{ - Hostname: "127.0.0.1", - Port: 22999, - } - _, err := ReadTopologyInstance(&key) - - c.Assert(err, Not(IsNil)) -} - -func (s *TestSuite) TestMoveBelowAndBack(c *C) { - clearTestMaintenance() - // become child - slave1, err := MoveBelow(&slave1Key, &slave2Key) - c.Assert(err, IsNil) - - c.Assert(slave1.MasterKey.Equals(&slave2Key), Equals, true) - c.Assert(slave1.ReplicaRunning(), Equals, true) - - // And back; keep topology intact - slave1, _ = MoveUp(&slave1Key) - slave2, _ := ReadTopologyInstance(&slave2Key) - - c.Assert(InstancesAreSiblings(slave1, slave2), Equals, true) - c.Assert(slave1.ReplicaRunning(), Equals, true) - -} - -func (s *TestSuite) TestMoveBelowAndBackComplex(c *C) { - clearTestMaintenance() - - // become child - slave1, _ := MoveBelow(&slave1Key, &slave2Key) - - c.Assert(slave1.MasterKey.Equals(&slave2Key), Equals, true) - c.Assert(slave1.ReplicaRunning(), Equals, true) - - // Now let's have fun. Stop replica2 (which is now parent of replica1), execute queries on master, - // move s1 back under master, start all, verify queries. - - _, err := StopSlave(&slave2Key) - c.Assert(err, IsNil) - - randValue := rand.Int() - _, err = ExecInstance(&masterKey, `replace into orchestrator_test.test_table (name, value) values ('TestMoveBelowAndBackComplex', ?)`, randValue) - c.Assert(err, IsNil) - master, err := ReadTopologyInstance(&masterKey) - c.Assert(err, IsNil) - - // And back; keep topology intact - slave1, err = MoveUp(&slave1Key) - c.Assert(err, IsNil) - _, err = MasterPosWait(&slave1Key, &master.SelfBinlogCoordinates) - c.Assert(err, IsNil) - slave2, err := ReadTopologyInstance(&slave2Key) - c.Assert(err, IsNil) - _, err = MasterPosWait(&slave2Key, &master.SelfBinlogCoordinates) - c.Assert(err, IsNil) - // Now check for value! - var value1, value2 int - ScanInstanceRow(&slave1Key, `select value from orchestrator_test.test_table where name='TestMoveBelowAndBackComplex'`, &value1) - ScanInstanceRow(&slave2Key, `select value from orchestrator_test.test_table where name='TestMoveBelowAndBackComplex'`, &value2) - - c.Assert(InstancesAreSiblings(slave1, slave2), Equals, true) - c.Assert(value1, Equals, randValue) - c.Assert(value2, Equals, randValue) -} - -func (s *TestSuite) TestFailMoveBelow(c *C) { - clearTestMaintenance() - _, _ = ExecInstance(&slave2Key, `set global binlog_format:='ROW'`) - _, err := MoveBelow(&slave1Key, &slave2Key) - _, _ = ExecInstance(&slave2Key, `set global binlog_format:='STATEMENT'`) - c.Assert(err, Not(IsNil)) -} - -func (s *TestSuite) TestMakeCoMasterAndBack(c *C) { - clearTestMaintenance() - - slave1, err := MakeCoMaster(&slave1Key) - c.Assert(err, IsNil) - - // Now master & replica1 expected to be co-masters. Check! - master, _ := ReadTopologyInstance(&masterKey) - c.Assert(master.IsReplicaOf(slave1), Equals, true) - c.Assert(slave1.IsReplicaOf(master), Equals, true) - - // reset - restore to original state - master, err = ResetSlaveOperation(&masterKey) - slave1, _ = ReadTopologyInstance(&slave1Key) - c.Assert(err, IsNil) - c.Assert(master.MasterKey.Hostname, Equals, "_") -} - -func (s *TestSuite) TestFailMakeCoMaster(c *C) { - clearTestMaintenance() - _, err := MakeCoMaster(&masterKey) - c.Assert(err, Not(IsNil)) -} - -func (s *TestSuite) TestMakeCoMasterAndBackAndFailOthersToBecomeCoMasters(c *C) { - clearTestMaintenance() - - slave1, err := MakeCoMaster(&slave1Key) - c.Assert(err, IsNil) - - // Now master & replica1 expected to be co-masters. Check! - master, _, _ := ReadInstance(&masterKey) - c.Assert(master.IsReplicaOf(slave1), Equals, true) - c.Assert(slave1.IsReplicaOf(master), Equals, true) - - // Verify can't have additional co-masters - _, err = MakeCoMaster(&masterKey) - c.Assert(err, Not(IsNil)) - _, err = MakeCoMaster(&slave1Key) - c.Assert(err, Not(IsNil)) - _, err = MakeCoMaster(&slave2Key) - c.Assert(err, Not(IsNil)) - - // reset replica - restore to original state - master, err = ResetSlaveOperation(&masterKey) - c.Assert(err, IsNil) - c.Assert(master.MasterKey.Hostname, Equals, "_") -} - -func (s *TestSuite) TestDiscover(c *C) { - var err error - _, err = db.ExecOrchestrator("delete from database_instance where hostname = ? and port = ?", masterKey.Hostname, masterKey.Port) - _, err = db.ExecOrchestrator("delete from database_instance where hostname = ? and port = ?", slave1Key.Hostname, slave1Key.Port) - _, err = db.ExecOrchestrator("delete from database_instance where hostname = ? and port = ?", slave2Key.Hostname, slave2Key.Port) - _, err = db.ExecOrchestrator("delete from database_instance where hostname = ? and port = ?", slave3Key.Hostname, slave3Key.Port) - _, found, _ := ReadInstance(&masterKey) - c.Assert(found, Equals, false) - _, _ = ReadTopologyInstance(&slave1Key) - _, found, err = ReadInstance(&slave1Key) - c.Assert(found, Equals, true) - c.Assert(err, IsNil) -} - -func (s *TestSuite) TestForgetMaster(c *C) { - _, _ = ReadTopologyInstance(&masterKey) - _, found, _ := ReadInstance(&masterKey) - c.Assert(found, Equals, true) - ForgetInstance(&masterKey) - _, found, _ = ReadInstance(&masterKey) - c.Assert(found, Equals, false) -} - -func (s *TestSuite) TestBeginMaintenance(c *C) { - clearTestMaintenance() - _, _ = ReadTopologyInstance(&masterKey) - _, err := BeginMaintenance(&masterKey, "unittest", "TestBeginMaintenance") - - c.Assert(err, IsNil) -} - -func (s *TestSuite) TestBeginEndMaintenance(c *C) { - clearTestMaintenance() - _, _ = ReadTopologyInstance(&masterKey) - k, err := BeginMaintenance(&masterKey, "unittest", "TestBeginEndMaintenance") - c.Assert(err, IsNil) - err = EndMaintenance(k) - c.Assert(err, IsNil) -} - -func (s *TestSuite) TestFailBeginMaintenanceTwice(c *C) { - clearTestMaintenance() - _, _ = ReadTopologyInstance(&masterKey) - _, err := BeginMaintenance(&masterKey, "unittest", "TestFailBeginMaintenanceTwice") - c.Assert(err, IsNil) - _, err = BeginMaintenance(&masterKey, "unittest", "TestFailBeginMaintenanceTwice") - c.Assert(err, Not(IsNil)) -} - -func (s *TestSuite) TestFailEndMaintenanceTwice(c *C) { - clearTestMaintenance() - _, _ = ReadTopologyInstance(&masterKey) - k, err := BeginMaintenance(&masterKey, "unittest", "TestFailEndMaintenanceTwice") - c.Assert(err, IsNil) - err = EndMaintenance(k) - c.Assert(err, IsNil) - err = EndMaintenance(k) - c.Assert(err, Not(IsNil)) -} - -func (s *TestSuite) TestFailMoveBelowUponMaintenance(c *C) { - clearTestMaintenance() - _, _ = ReadTopologyInstance(&slave1Key) - k, err := BeginMaintenance(&slave1Key, "unittest", "TestBeginEndMaintenance") - c.Assert(err, IsNil) - - _, err = MoveBelow(&slave1Key, &slave2Key) - c.Assert(err, Not(IsNil)) - - err = EndMaintenance(k) - c.Assert(err, IsNil) -} - -func (s *TestSuite) TestFailMoveBelowUponSlaveStopped(c *C) { - clearTestMaintenance() - - slave1, _ := ReadTopologyInstance(&slave1Key) - c.Assert(slave1.ReplicaRunning(), Equals, true) - slave1, _ = StopSlaveNicely(&slave1.Key, 0) - c.Assert(slave1.ReplicaRunning(), Equals, false) - - _, err := MoveBelow(&slave1Key, &slave2Key) - c.Assert(err, Not(IsNil)) - - _, _ = StartSlave(&slave1.Key) -} - -func (s *TestSuite) TestFailMoveBelowUponOtherSlaveStopped(c *C) { - clearTestMaintenance() - - slave1, _ := ReadTopologyInstance(&slave1Key) - c.Assert(slave1.ReplicaRunning(), Equals, true) - slave1, _ = StopSlaveNicely(&slave1.Key, 0) - c.Assert(slave1.ReplicaRunning(), Equals, false) - - _, err := MoveBelow(&slave2Key, &slave1Key) - c.Assert(err, Not(IsNil)) - - _, _ = StartSlave(&slave1.Key) -} diff --git a/tests/system/co-master-failover/05-count-replicas/run b/tests/system/co-master-failover/05-count-replicas/run index 36af9bf53..3a2d764d3 100644 --- a/tests/system/co-master-failover/05-count-replicas/run +++ b/tests/system/co-master-failover/05-count-replicas/run @@ -1,3 +1,3 @@ cluster_master="$(orchestrator-client -c which-cluster-master -alias ci)" cluster_master_path="$(echo $cluster_master | tr ':' '/')" -orchestrator-client -c api -path instance/$cluster_master_path | jq '.SlaveHosts | length' +orchestrator-client -c api -path instance/$cluster_master_path | jq '.Replicas | length' diff --git a/tests/system/master-failover-candidate-lag/03-count-replicas/run b/tests/system/master-failover-candidate-lag/03-count-replicas/run index 36af9bf53..3a2d764d3 100644 --- a/tests/system/master-failover-candidate-lag/03-count-replicas/run +++ b/tests/system/master-failover-candidate-lag/03-count-replicas/run @@ -1,3 +1,3 @@ cluster_master="$(orchestrator-client -c which-cluster-master -alias ci)" cluster_master_path="$(echo $cluster_master | tr ':' '/')" -orchestrator-client -c api -path instance/$cluster_master_path | jq '.SlaveHosts | length' +orchestrator-client -c api -path instance/$cluster_master_path | jq '.Replicas | length' diff --git a/tests/system/master-failover-candidate/03-count-replicas/run b/tests/system/master-failover-candidate/03-count-replicas/run index 36af9bf53..3a2d764d3 100644 --- a/tests/system/master-failover-candidate/03-count-replicas/run +++ b/tests/system/master-failover-candidate/03-count-replicas/run @@ -1,3 +1,3 @@ cluster_master="$(orchestrator-client -c which-cluster-master -alias ci)" cluster_master_path="$(echo $cluster_master | tr ':' '/')" -orchestrator-client -c api -path instance/$cluster_master_path | jq '.SlaveHosts | length' +orchestrator-client -c api -path instance/$cluster_master_path | jq '.Replicas | length' diff --git a/tests/system/master-failover-fail-promotion-lag-minutes-success/03-count-replicas/run b/tests/system/master-failover-fail-promotion-lag-minutes-success/03-count-replicas/run index 36af9bf53..3a2d764d3 100644 --- a/tests/system/master-failover-fail-promotion-lag-minutes-success/03-count-replicas/run +++ b/tests/system/master-failover-fail-promotion-lag-minutes-success/03-count-replicas/run @@ -1,3 +1,3 @@ cluster_master="$(orchestrator-client -c which-cluster-master -alias ci)" cluster_master_path="$(echo $cluster_master | tr ':' '/')" -orchestrator-client -c api -path instance/$cluster_master_path | jq '.SlaveHosts | length' +orchestrator-client -c api -path instance/$cluster_master_path | jq '.Replicas | length' diff --git a/tests/system/master-failover-lost-replicas/03-count-replicas/run b/tests/system/master-failover-lost-replicas/03-count-replicas/run index 36af9bf53..3a2d764d3 100644 --- a/tests/system/master-failover-lost-replicas/03-count-replicas/run +++ b/tests/system/master-failover-lost-replicas/03-count-replicas/run @@ -1,3 +1,3 @@ cluster_master="$(orchestrator-client -c which-cluster-master -alias ci)" cluster_master_path="$(echo $cluster_master | tr ':' '/')" -orchestrator-client -c api -path instance/$cluster_master_path | jq '.SlaveHosts | length' +orchestrator-client -c api -path instance/$cluster_master_path | jq '.Replicas | length' diff --git a/tests/system/master-failover/03-count-replicas/run b/tests/system/master-failover/03-count-replicas/run index 36af9bf53..3a2d764d3 100644 --- a/tests/system/master-failover/03-count-replicas/run +++ b/tests/system/master-failover/03-count-replicas/run @@ -1,3 +1,3 @@ cluster_master="$(orchestrator-client -c which-cluster-master -alias ci)" cluster_master_path="$(echo $cluster_master | tr ':' '/')" -orchestrator-client -c api -path instance/$cluster_master_path | jq '.SlaveHosts | length' +orchestrator-client -c api -path instance/$cluster_master_path | jq '.Replicas | length' From 10fb798f0eeef15a9c9825d44b60034b43dd0d70 Mon Sep 17 00:00:00 2001 From: Shlomi Noach <2607934+shlomi-noach@users.noreply.github.com> Date: Tue, 9 Jun 2020 12:01:36 +0300 Subject: [PATCH 09/10] typo --- go/inst/instance.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/go/inst/instance.go b/go/inst/instance.go index 3569567a1..ca98aa5be 100644 --- a/go/inst/instance.go +++ b/go/inst/instance.go @@ -202,7 +202,7 @@ func (this *Instance) IsSmallerMajorVersion(other *Instance) bool { return IsSmallerMajorVersion(this.Version, other.Version) } -// IsSmallerMajorVersionByString cehcks if this instance has a smaller major version number than given one +// IsSmallerMajorVersionByString checks if this instance has a smaller major version number than given one func (this *Instance) IsSmallerMajorVersionByString(otherVersion string) bool { return IsSmallerMajorVersion(this.Version, otherVersion) } From 22c18182390e0388d0bd74a25586e05a4ecb6e6c Mon Sep 17 00:00:00 2001 From: Shlomi Noach <2607934+shlomi-noach@users.noreply.github.com> Date: Tue, 9 Jun 2020 13:20:31 +0300 Subject: [PATCH 10/10] Adding API tests for .Replicas --- tests/system/all-instances/{ => 01-instances}/expect_output | 0 tests/system/all-instances/{ => 01-instances}/run | 0 tests/system/all-instances/02-replicas/expect_output | 4 ++++ tests/system/all-instances/02-replicas/run | 1 + tests/system/all-instances/skip_run | 0 5 files changed, 5 insertions(+) rename tests/system/all-instances/{ => 01-instances}/expect_output (100%) rename tests/system/all-instances/{ => 01-instances}/run (100%) create mode 100644 tests/system/all-instances/02-replicas/expect_output create mode 100644 tests/system/all-instances/02-replicas/run create mode 100644 tests/system/all-instances/skip_run diff --git a/tests/system/all-instances/expect_output b/tests/system/all-instances/01-instances/expect_output similarity index 100% rename from tests/system/all-instances/expect_output rename to tests/system/all-instances/01-instances/expect_output diff --git a/tests/system/all-instances/run b/tests/system/all-instances/01-instances/run similarity index 100% rename from tests/system/all-instances/run rename to tests/system/all-instances/01-instances/run diff --git a/tests/system/all-instances/02-replicas/expect_output b/tests/system/all-instances/02-replicas/expect_output new file mode 100644 index 000000000..8a673e262 --- /dev/null +++ b/tests/system/all-instances/02-replicas/expect_output @@ -0,0 +1,4 @@ +3 +0 +0 +0 diff --git a/tests/system/all-instances/02-replicas/run b/tests/system/all-instances/02-replicas/run new file mode 100644 index 000000000..5739cf49f --- /dev/null +++ b/tests/system/all-instances/02-replicas/run @@ -0,0 +1 @@ +orchestrator-client -c api -path all-instances | jq '.[] | .Replicas | length' diff --git a/tests/system/all-instances/skip_run b/tests/system/all-instances/skip_run new file mode 100644 index 000000000..e69de29bb