forked from zstackio/zstack
-
Notifications
You must be signed in to change notification settings - Fork 0
<feature>[kvm]: add kvmagent auto-restart window config #3863
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
Open
zstack-robot-2
wants to merge
1
commit into
5.5.16
Choose a base branch
from
sync/jin.ma/feat/kvmagent-autorestart-window
base: 5.5.16
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
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 hidden or 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 hidden or 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 hidden or 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 hidden or 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
59 changes: 59 additions & 0 deletions
59
test/src/test/groovy/org/zstack/test/unittest/utils/KVMAutoRestartWindowCase.java
This file contains hidden or 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 |
|---|---|---|
| @@ -0,0 +1,59 @@ | ||
| package org.zstack.test.unittest.utils; | ||
|
|
||
| import org.junit.Test; | ||
| import org.zstack.kvm.KVMHostFactory; | ||
|
|
||
| import java.time.LocalTime; | ||
|
|
||
| import static org.junit.Assert.assertFalse; | ||
| import static org.junit.Assert.assertTrue; | ||
|
|
||
| public class KVMAutoRestartWindowCase { | ||
|
|
||
| private boolean inWindow(String configValue, String now) { | ||
| return KVMHostFactory.isNowInAutoRestartWindow(configValue, LocalTime.parse(now)); | ||
| } | ||
|
|
||
| @Test | ||
| public void emptyOrNullValueAlwaysAllowed() { | ||
| assertTrue(inWindow("", "00:00")); | ||
| assertTrue(inWindow("", "12:00")); | ||
| assertTrue(inWindow("", "23:59")); | ||
| assertTrue(inWindow(null, "12:00")); | ||
| assertTrue(inWindow(" ", "12:00")); | ||
| } | ||
|
|
||
| @Test | ||
| public void normalWindowMembership() { | ||
| assertTrue(inWindow("02:00-04:00", "02:30")); | ||
| assertTrue(inWindow("02:00-04:00", "03:59")); | ||
| assertFalse(inWindow("02:00-04:00", "00:00")); | ||
| assertFalse(inWindow("02:00-04:00", "14:00")); | ||
| } | ||
|
|
||
| @Test | ||
| public void normalWindowBoundary() { | ||
| assertTrue(inWindow("02:00-04:00", "02:00")); | ||
| assertFalse(inWindow("02:00-04:00", "04:00")); | ||
| assertTrue(inWindow("02:00-04:00", "03:59")); | ||
| } | ||
|
|
||
| @Test | ||
| public void crossMidnightWindowMembership() { | ||
| assertTrue(inWindow("22:00-02:00", "23:30")); | ||
| assertTrue(inWindow("22:00-02:00", "22:00")); | ||
| assertTrue(inWindow("22:00-02:00", "00:30")); | ||
| assertTrue(inWindow("22:00-02:00", "01:59")); | ||
| assertFalse(inWindow("22:00-02:00", "14:00")); | ||
| assertFalse(inWindow("22:00-02:00", "02:00")); | ||
| assertFalse(inWindow("22:00-02:00", "21:59")); | ||
| } | ||
|
|
||
| @Test | ||
| public void wholeDayMinusOneMinute() { | ||
| assertTrue(inWindow("00:00-23:59", "00:00")); | ||
| assertTrue(inWindow("00:00-23:59", "12:00")); | ||
| assertTrue(inWindow("00:00-23:59", "23:58")); | ||
| assertFalse(inWindow("00:00-23:59", "23:59")); | ||
| } | ||
| } |
This file contains hidden or 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
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.
Comment from jin.ma:
已修复,commit 2d6e1b0。
裸
@GlobalConfigValidation默认notEmpty=true,会在installValidateExtension之前拒空值,与本字段"空值=任意时间允许"的语义冲突。改为@GlobalConfigValidation(notEmpty = false),把空值放行给已注册的扩展校验器(KVMHostFactory#start 中对 null/empty 直接 return 通过)。