-
Notifications
You must be signed in to change notification settings - Fork 179
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
Windows support for Service tool added. #3573
base: main
Are you sure you want to change the base?
Conversation
5678bbc
to
2f38007
Compare
lisa/base_tools/service.py
Outdated
def _check_exists(self) -> bool: | ||
return True | ||
|
||
def restart_service(self, name: str, ignore_exit_code: int = 0) -> None: |
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.
Move public methods above private methods.
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.
Fixed
lisa/schema.py
Outdated
@@ -431,6 +431,16 @@ class DiskType(str, Enum): | |||
] | |||
|
|||
|
|||
class WindowsServiceStatus(int, Enum): |
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.
Move it along in to the service class.
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.
Fixed
lisa/base_tools/service.py
Outdated
self._log.debug( | ||
f"service '{name}' is not ready yet, retrying... after 3 seconds" | ||
) | ||
sleep(3) |
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.
Change the interval to 0.5 second.
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.
Fixed
lisa/base_tools/service.py
Outdated
self.wait_for_service_start(name) | ||
|
||
def wait_for_service_start(self, name: str) -> None: | ||
for _ in range(10): |
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.
Create a builtin Timer by create_timer
to count the timeout by seconds, instead of count by times.
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.
Fixed
lisa/base_tools/service.py
Outdated
): | ||
return | ||
|
||
self._log.debug( |
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.
Output before the waiting once, not output during waiting.
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.
Fixed
lisa/base_tools/service.py
Outdated
) | ||
sleep(3) | ||
|
||
raise LisaException(f"service '{name}' failed to start") |
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.
Give more details, like wait 30 seconds timeout, it's still in NNN status.
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.
Fixed
lisa/base_tools/service.py
Outdated
output_json=True, | ||
fail_on_error=False, | ||
) | ||
if not service_status: |
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.
Use above fail_on_error, instead of custom 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.
Fixed
lisa/base_tools/service.py
Outdated
|
||
def wait_for_service_start(self, name: str) -> None: | ||
for _ in range(10): | ||
service_status = self._powershell.run_cmdlet( |
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.
Use the _get_status
, not to implement it again.
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.
Fixed
lisa/base_tools/service.py
Outdated
raise LisaException(f"service '{name}' does not exist") | ||
return schema.WindowsServiceStatus(service_status["Status"]) | ||
|
||
def stop_service(self, name: str) -> None: |
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.
Wait on stop too.
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.
Fixed
lisa/base_tools/service.py
Outdated
) | ||
assert_that(self._get_status(name)).described_as( | ||
f"Failed to stop service {name}" | ||
).is_not_equal_to(schema.WindowsServiceStatus.RUNNING) |
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.
It doesn't make sense, why stop service expect the service status is running?
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.
Fixed
lisa/base_tools/service.py
Outdated
).is_not_equal_to(schema.WindowsServiceStatus.RUNNING) | ||
|
||
def enable_service(self, name: str) -> None: | ||
raise NotImplementedError() |
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.
use pass
instead of raise exception.
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.
Fixed
lisa/base_tools/service.py
Outdated
raise NotImplementedError() | ||
|
||
|
||
class WindowsService(Tool): |
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.
Move Windows class to the end like other tools.
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.
Fixed
9cfc7ab
to
727572d
Compare
5b555e0
to
72582c5
Compare
This pull request adds Windows support for the Service tool.
72582c5
to
30a8249
Compare
This pull request adds Windows support for the Service tool.