chipsenkbeil / service-manager-rs

Provides adapters to communicate with various operating system service managers like launchd and systemd
Apache License 2.0
179 stars 15 forks source link

Improve the system-tests #3

Open Lyamc opened 1 year ago

Lyamc commented 1 year ago

So I ran the test on Windows, I understand it does the following:

1) Install a service com.example.echo 2) Start the service com.example.echo 2a) The service will execute %service-manager-rs-PATH%\target\debug\system-tests.exe listen 127.0.0.1:0 --log-file %TEMP%\com.example.echo.log 2b) The system-tests.exe will create a log file next to it called system-tests.exe.log

The problem is the test doesn't check service stopping, restarting or uninstalling the service. I did see a run_test_n where n is a step, not sure how to use it though. Event viewer can be used to check whether the Service was installed/started/stopped/uninstalled.

I also noticed some errors in the Windows Event Log from when I tried to restart the service.

Activation context generation failed for "C:\Build\service-manager-rs\target\debug\system-tests.exe".Error in manifest or policy file "C:\Build\service-manager-rs\target\debug\system-tests.exe.Config" on line 0. Invalid Xml syntax.
chipsenkbeil commented 1 year ago

Hm, I wonder if this is the design of the windows service used for the test. I know that I'm able to start and stop distant as a service without issue, although there may still be errors in the Windows Event Log.

I tried pulling up the log on my test vm and could not find a reference to my service, though. The tests simply verify that executing the commands do not fail, otherwise the test itself would fail. So this implies that sc.exe is not reporting a failure exit status for stopping or uninstalling the service, which are the final two steps in the test runner.

My knowledge on windows services is fairly limited, so once I got something working for my use case (distant), I moved forward. Would love any PR you'd like to offer to resolve these problems, @Lyamc! 😄

chipsenkbeil commented 1 year ago

Oh, and the run_test_n is used to repeat the test n times. By default, it installs, starts, communicates, stops, and uninstalls three times to ensure that a service can be reinstalled properly and still work.