mirror of
https://github.com/siderolabs/talos.git
synced 2025-08-27 17:41:17 +02:00
This PR introduces dependencies between the services. Now each service has two virtual events associated with it: 'up' (running and healthy) and 'down' (finished or failed). These events are used to establish correct order via conditions abstraction. Service image unpacking was moved into 'pre' stage simplifying `init/main.go`, service images are now closer to the code which runs the service itself. Step 'pre' now runs after 'wait' step, and service dependencies are now mixed into other conditions of 'wait' step on startup. Signed-off-by: Andrey Smirnov <smirnov.andrey@gmail.com>
33 lines
908 B
Go
33 lines
908 B
Go
/* This Source Code Form is subject to the terms of the Mozilla Public
|
|
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
|
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
|
|
|
|
package system_test
|
|
|
|
import (
|
|
"testing"
|
|
"time"
|
|
|
|
"github.com/stretchr/testify/suite"
|
|
"github.com/talos-systems/talos/internal/app/init/pkg/system"
|
|
)
|
|
|
|
type SystemServicesSuite struct {
|
|
suite.Suite
|
|
}
|
|
|
|
func (suite *SystemServicesSuite) TestStartShutdown() {
|
|
system.Services(nil).Start(
|
|
&MockService{name: "containerd"},
|
|
&MockService{name: "proxyd", dependencies: []string{"containerd"}},
|
|
&MockService{name: "trustd", dependencies: []string{"containerd", "proxyd"}},
|
|
&MockService{name: "osd", dependencies: []string{"containerd"}},
|
|
)
|
|
time.Sleep(10 * time.Millisecond)
|
|
system.Services(nil).Shutdown()
|
|
}
|
|
|
|
func TestSystemServicesSuite(t *testing.T) {
|
|
suite.Run(t, new(SystemServicesSuite))
|
|
}
|