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
add backup rs tests #1473
base: master
Are you sure you want to change the base?
add backup rs tests #1473
Conversation
time.Sleep(time.Second * 20) | ||
|
||
return nil | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
need new line (\n) in the end file
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
done
tests_func/helpers/mongo.go
Outdated
@@ -534,12 +534,34 @@ func (mc *MongoCtl) StartMongod() error { | |||
return err | |||
} | |||
|
|||
|
|||
func (mc *MongoCtl) FetchLogs(text string) (string, error) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
may be we can name function as GrepLogs? =) Fetch is similar git fetch - extract some inforation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
done
tests_func/helpers/mongo.go
Outdated
|
||
func (mc *MongoCtl) FetchLogs(text string) (string, error) { | ||
exc, err := mc.runCmd("grep", fmt.Sprintf("\"%s\"", text), "/var/log/mongodb/mongod.log") | ||
tracelog.ErrorLogger.Printf("Command failed %s", exc.Stderr()) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
log error every time? may be it need if err != nil?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
done
tracelog.ErrorLogger.Printf("Command failed %s", exc.Stderr()) | ||
|
||
if err != nil{ | ||
if exc.ExitCode == 1 { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I spend some time to understand why =)
Can we add comment like - we don't find any text, so we should return empty line as result
?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
done
@@ -98,3 +100,87 @@ func (tctx *TestContext) restoreMongoBinaryBackup(backupNumber int, container st | |||
|
|||
return nil | |||
} | |||
|
|||
|
|||
func (tctx *TestContext) restoreMongoReplSetBinaryBackupAsNonInitialized(backupNumber int, containers string) error { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
why does the function have suffix "AsNonInitialized"? we do initialization in this function =)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
removed initialization from function
return tctx.restoreMongoReplSetBinaryBackup(backupNumber, containerNames) | ||
} | ||
|
||
func (tctx *TestContext) restoreMongoReplSetBinaryBackup(backupNumber int, containerNames []string) error { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
very big function, need to split on multiple logical functions
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
done
} | ||
} | ||
|
||
for _, mongoCtl := range mongoCtlList { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
may be we can union with previous loop?
for i, container := range containerNames {
walg[i]...
mongoCtl[i]...
if i == 0 {
tctx.initiateReplSet(container)
}
}
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
firstly backup, lately start mongo, otherwise it's wrong
} | ||
|
||
for _, container := range containerNames { | ||
if err := tctx.initiateReplSet(container); err != nil { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
hm... we need initiate only for one mongodb =)
may be it works, because of in InitReplSet function check IsMaster return master
anyway see previous comment, lets union in single loop
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
removed it
} | ||
|
||
// time for sync | ||
time.Sleep(time.Second * 20) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
sleep with big time is bad architecture =)
we need loop with check and sleep small time. but the best solution - we need use steps in feature files 'Then mongodb role is primary on mongodb01' and 'And mongodb role is secondary on mongodb02'
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
removed it, added func waitSecondariesSync
tests_func/mongo_steps.go
Outdated
ctx.Step(`^at least one oplog archive exists in storage$`, tctx.oplogArchiveIsNotEmpty) | ||
ctx.Step(`^we purge oplog archives via ([^\s]*)$`, tctx.purgeOplogArchives) | ||
ctx.Step(`^oplog archiving is enabled on ([^\s]*)$`, tctx.enableOplogPush) | ||
ctx.Step(`^we restore from #(\d+) backup to "([^"]*)" timestamp to ([^\s]*)$`, tctx.replayOplog) | ||
|
||
ctx.Step(`^mongodb not has initial sync on ([^\s]+)$`, tctx.checkInitialSync) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
may be: not has -> doesn't have
?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
done
Mongodb
Pull request description
Describe what this PR fix
New tests was added for describing of restoring replica set from binary backup.