-
Notifications
You must be signed in to change notification settings - Fork 501
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
tests: refactor fault trigger #896
Merged
Merged
Changes from 6 commits
Commits
Show all changes
32 commits
Select commit
Hold shift + click to select a range
689aa7c
refactor fault trigger
xiaojingchen 8a7e6a1
fix config.yaml
xiaojingchen f836536
address comment
xiaojingchen 8648f7e
Merge branch 'master' into agent-support-qm
xiaojingchen 1721243
address comment
xiaojingchen 7d1b2e1
Merge branch 'agent-support-qm' of https://github.com/xiaojingchen/ti…
xiaojingchen 7b79f2c
fix unit tests
xiaojingchen b5bc4e0
fix bugs
xiaojingchen c6449e6
fix
xiaojingchen 82cafca
Merge branch 'master' into agent-support-qm
xiaojingchen 14e76a8
fix compatibility bug
xiaojingchen f39f241
Merge branch 'master' into agent-support-qm
cofyc ac4070a
add test name
xiaojingchen b09c8b1
Merge branch 'agent-support-qm' of https://github.com/xiaojingchen/ti…
xiaojingchen a3faa0e
refactor fault trigger
xiaojingchen 54709e4
fix config.yaml
xiaojingchen 68ddae7
address comment
xiaojingchen 5753e98
address comment
xiaojingchen 2cd1da6
fix unit tests
xiaojingchen 3da2da4
fix bugs
xiaojingchen 1f8a921
fix
xiaojingchen f697e92
fix compatibility bug
xiaojingchen 466a0f4
add test name
xiaojingchen b48c82a
add apiserver fault trigger and check
xiaojingchen 027eea8
fix
xiaojingchen f9dbde8
Merge branch 'master' into agent-support-qm
xiaojingchen 6afcd3b
Merge branch 'master' into agent-support-qm
xiaojingchen ed5c31a
fix
xiaojingchen 556238a
Merge branch 'master' into agent-support-qm
cofyc 04af526
fix lint error
xiaojingchen 16e083e
Merge branch 'master' into agent-support-qm
xiaojingchen 1f4bd01
Merge branch 'agent-support-qm' of https://github.com/xiaojingchen/ti…
xiaojingchen File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -15,36 +15,26 @@ package manager | |
|
||
import ( | ||
"fmt" | ||
"sync" | ||
|
||
"github.com/pingcap/tidb-operator/tests/slack" | ||
) | ||
|
||
// Manager to manager fault trigger | ||
type Manager struct { | ||
sync.RWMutex | ||
vmCache map[string]string | ||
VMManager | ||
} | ||
|
||
// NewManager returns a manager instance | ||
func NewManager() *Manager { | ||
return &Manager{ | ||
vmCache: make(map[string]string), | ||
func NewManager(vmManagerName string) *Manager { | ||
var vmManager VMManager | ||
if vmManagerName == "qm" { | ||
vmManager = &QMVMManager{} | ||
} else if vmManagerName == "virsh" { | ||
vmManager = &VirshVMManager{} | ||
} else { | ||
slack.NotifyAndPanic(fmt.Errorf("stability test have not supported the vm manager:[%s],please choose [qm] or [virsh].", vmManagerName)) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. in fault-trigger, slack.Webhook endpoint is not provided. IMO a simple fatal error is enough. |
||
} | ||
} | ||
|
||
func (m *Manager) setVMCache(key, val string) { | ||
m.Lock() | ||
m.vmCache[key] = val | ||
m.Unlock() | ||
} | ||
|
||
func (m *Manager) getVMCache(key string) (string, error) { | ||
m.RLock() | ||
defer m.RUnlock() | ||
|
||
val, ok := m.vmCache[key] | ||
if !ok { | ||
return "", fmt.Errorf("vm %s not in cache", key) | ||
return &Manager{ | ||
vmManager, | ||
} | ||
|
||
return val, nil | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.
better not to allow invalid
--vm-manager
value, we can initialize vm manager and handle errors here, e.g.if some users configured an invalid value, but our program still works, this will confuse people because they don't know what virtual manager we use from the command-line flags unless they know implementation details