Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix slave_info miss label values #383

Merged
merged 7 commits into from
May 13, 2020
Merged

Fix slave_info miss label values #383

merged 7 commits into from
May 13, 2020

Conversation

yz1509
Copy link
Contributor

@yz1509 yz1509 commented May 8, 2020

No description provided.

@coveralls
Copy link

coveralls commented May 8, 2020

Coverage Status

Coverage remained the same at 82.384% when pulling 33a5def on yz1509:master into 086de91 on oliver006:master.

@codecov
Copy link

codecov bot commented May 8, 2020

Codecov Report

Merging #383 into master will decrease coverage by 0.04%.
The diff coverage is n/a.

Impacted file tree graph

@@            Coverage Diff             @@
##           master     #383      +/-   ##
==========================================
- Coverage   78.94%   78.90%   -0.05%     
==========================================
  Files           2        2              
  Lines         912      910       -2     
==========================================
- Hits          720      718       -2     
  Misses        157      157              
  Partials       35       35              
Impacted Files Coverage Δ
exporter.go 88.53% <ø> (-0.03%) ⬇️

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 086de91...33a5def. Read the comment docs.

@oliver006
Copy link
Owner

Good catch, thanks for the PR!

Can you please add tests around this scenario so this won't happen again in the future?

@oliver006
Copy link
Owner

Adding @jtorkkel to the conversation to see if he has suggestions as to what a test could look like, he added the master_host|port labels in the first place.

exporter_test.go Outdated
@@ -1325,6 +1325,14 @@ func TestClusterSlave(t *testing.T) {
t.Errorf("Did not find key [%s] \nbody: %s", want, body)
}
}
for _, unwanted := range []string{
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can we invert this test and check for presence of expected values?

Copy link
Contributor

@jtorkkel jtorkkel May 11, 2020

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hi, did not fully understood the question. In order to create and run multimaster tests you need to have KeyDB installed or you needs to include mock "info replication" for multimaster test cases. Redis OSS does not support multimaster, only simgle master nad multiple replicas. Redis EE, support active-active which is similar but not sure if same fields exposed through info.

The following info replication mock could be used for multimaster. Master 0 and 1 are up, Master 2 down.

127.0.0.1:8881> info replication
# Replication
role:active-replica
Master 0:
master_host:127.0.0.1
master_port:8882
master_link_status:up
master_last_io_seconds_ago:6
master_sync_in_progress:0
slave_repl_offset:16291
Master 1:
master_host:127.0.0.1
master_port:8883
master_link_status:up
master_last_io_seconds_ago:6
master_sync_in_progress:0
slave_repl_offset:16513
Master 2:
master_host:127.0.0.1
master_port:8884
master_link_status:down
master_last_io_seconds_ago:-1
master_sync_in_progress:0
slave_repl_offset:12740
master_link_down_since_seconds:62
slave_priority:100
slave_read_only:0
connected_slaves:2
slave0:ip=127.0.0.1,port=8882,state=online,offset=24123,lag=1
slave1:ip=127.0.0.1,port=8883,state=online,offset=24123,lag=1
master_replid:b11b52dc9c93567be5c05b1bee23d2c73c694457
master_replid2:0000000000000000000000000000000000000000
master_repl_offset:24123
second_repl_offset:-1
repl_backlog_active:1
repl_backlog_size:1048576
repl_backlog_first_byte_offset:1
repl_backlog_histlen:24123
127.0.0.1:8881>

Copy link
Contributor Author

@yz1509 yz1509 May 11, 2020

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

In the current implementation, slaveInfo["master_host"] and slaveInfo["master_port"] are always empty.

Copy link
Contributor

@jtorkkel jtorkkel May 11, 2020

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Seem that same variable used in slave showing master address and in multimaster other masters.
Removing "continue" seems to fix the issue based on my testing and not breaking multimaster.

OSS slave:

127.0.0.1:8882> info replication
# Replication
role:slave
master_host:127.0.0.1
master_port:8881
master_link_status:up
master_last_io_seconds_ago:8
master_sync_in_progress:0
slave_repl_offset:308
slave_priority:100
slave_read_only:1
connected_slaves:0
master_port:8881

Copy link
Owner

@oliver006 oliver006 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

One minor comment, this is almost ready to go.

exporter_test.go Outdated Show resolved Hide resolved
@@ -1325,9 +1326,13 @@ func TestClusterSlave(t *testing.T) {
t.Errorf("Did not find key [%s] \nbody: %s", want, body)
}
}
hostReg, _ := regexp.Compile(`master_host="([0,1]?\d{1,2}|2([0-4][0-9]|5[0-5]))(\.([0,1]?\d{1,2}|2([0-4][0-9]|5[0-5]))){3}"`)
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

regular expressions seem to work

Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👍

@oliver006
Copy link
Owner

Thanks!

@oliver006 oliver006 merged commit 34c779d into oliver006:master May 13, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants