Skip to content
Snippets Groups Projects
Commit dda3d6d3 authored by Zygmunt Krynicki's avatar Zygmunt Krynicki
Browse files

service: load maker, model and stream from config


For the longest time, we used stub values for the maker, model and stream
properties. With the recent drive to complete the online side of SystemOTA
we are now able to load the values from the configuration system at
startup.

Tests are adjusted to use the test-* prefix for the values, in order to
avoid missing stub values anywhere. Integration tests are modified to
measure the values which are now set in the prepare logic of the test
suite.

There's a missing bit of integration between the writable update stream
property and the configuration system. At the moment changes to that
property are lost.

The update server is not used yet. It is also not exposed in the API,
on purpose, so that it cannot be modified or even read before the
interface between the client and the server is implemented.

Signed-off-by: default avatarZygmunt Krynicki <zygmunt.krynicki@huawei.com>
parent dfe99c8f
No related branches found
No related tags found
No related merge requests found
NAME TYPE SIGNATURE RESULT/VALUE FLAGS
org.freedesktop.DBus.Introspectable interface - - -
.Introspect method - s -
org.freedesktop.DBus.ObjectManager interface - - -
.GetManagedObjects method - a{oa{sa{sv}}} -
.InterfacesAdded signal oa{sa{sv}} - -
.InterfacesRemoved signal oas - -
org.freedesktop.DBus.Properties interface - - -
.Get method ss v -
.GetAll method s a{sv} -
.Set method ssv - -
.PropertiesChanged signal sa{sv}as - -
org.oniroproject.sysota1.BootLoader interface - - -
.CancelSwitch method - - -
.CommitSwitch method - - -
.QueryActive method - s -
.QueryInactive method - s -
.Reboot method u - -
.TrySwitch method s - -
org.oniroproject.sysota1.RAUC interface - - -
.GetPrimary method - s -
.GetState method s s -
.PostInstall method as - -
.PreInstall method as - -
.SetPrimary method s - -
.SetState method ss - -
org.oniroproject.sysota1.Service interface - - -
.UpdateDevice method a{ss} o -
.UpdateStreams method - - -
.Maker property s "dummy-maker" const
.Model property s "dummy-model" const
.Stream property s "dummy-stream" emits-change writable
NAME TYPE SIGNATURE RESULT/VALUE FLAGS
org.freedesktop.DBus.Introspectable interface - - -
.Introspect method - s -
org.freedesktop.DBus.ObjectManager interface - - -
.GetManagedObjects method - a{oa{sa{sv}}} -
.InterfacesAdded signal oa{sa{sv}} - -
.InterfacesRemoved signal oas - -
org.freedesktop.DBus.Properties interface - - -
.Get method ss v -
.GetAll method s a{sv} -
.Set method ssv - -
.PropertiesChanged signal sa{sv}as - -
org.oniroproject.sysota1.BootLoader interface - - -
.CancelSwitch method - - -
.CommitSwitch method - - -
.QueryActive method - s -
.QueryInactive method - s -
.Reboot method u - -
.TrySwitch method s - -
org.oniroproject.sysota1.RAUC interface - - -
.GetPrimary method - s -
.GetState method s s -
.PostInstall method as - -
.PreInstall method as - -
.SetPrimary method s - -
.SetState method ss - -
org.oniroproject.sysota1.Service interface - - -
.UpdateDevice method a{ss} o -
.UpdateStreams method - - -
.Maker property s "test-maker" const
.Model property s "test-model" const
.Stream property s "test-stream" emits-change writable
NAME TYPE SIGNATURE RESULT/VALUE FLAGS
org.freedesktop.DBus.Introspectable interface - - -
.Introspect method - s -
org.freedesktop.DBus.ObjectManager interface - - -
.GetManagedObjects method - a{oa{sa{sv}}} -
.InterfacesAdded signal oa{sa{sv}} - -
.InterfacesRemoved signal oas - -
org.freedesktop.DBus.Properties interface - - -
.Get method ss v -
.GetAll method s a{sv} -
.Set method ssv - -
.PropertiesChanged signal sa{sv}as - -
org.oniroproject.sysota1.RAUC interface - - -
.GetPrimary method - s -
.GetState method s s -
.PostInstall method as - -
.PreInstall method as - -
.SetPrimary method s - -
.SetState method ss - -
org.oniroproject.sysota1.Service interface - - -
.UpdateDevice method a{ss} o -
.UpdateStreams method - - -
.Maker property s "dummy-maker" const
.Model property s "dummy-model" const
.Stream property s "dummy-stream" emits-change writable
NAME TYPE SIGNATURE RESULT/VALUE FLAGS
org.freedesktop.DBus.Introspectable interface - - -
.Introspect method - s -
org.freedesktop.DBus.ObjectManager interface - - -
.GetManagedObjects method - a{oa{sa{sv}}} -
.InterfacesAdded signal oa{sa{sv}} - -
.InterfacesRemoved signal oas - -
org.freedesktop.DBus.Properties interface - - -
.Get method ss v -
.GetAll method s a{sv} -
.Set method ssv - -
.PropertiesChanged signal sa{sv}as - -
org.oniroproject.sysota1.RAUC interface - - -
.GetPrimary method - s -
.GetState method s s -
.PostInstall method as - -
.PreInstall method as - -
.SetPrimary method s - -
.SetState method ss - -
org.oniroproject.sysota1.Service interface - - -
.UpdateDevice method a{ss} o -
.UpdateStreams method - - -
.Maker property s "test-maker" const
.Model property s "test-model" const
.Stream property s "test-stream" emits-change writable
......@@ -8,11 +8,9 @@ environment:
BOOT_API_DEBUG/off: "false"
EXPECTED/off: introspection-expected-production.txt
prepare: |
# We are not expecting a config file since we are clobbering things below.
test ! -e /etc/sysota/sysotad.conf
systemctl stop sysotad.service
cat <<SYSOTAD_CONF >/etc/sysota/sysotad.conf
mkdir -p /run/sysota
cat <<SYSOTAD_CONF >/run/sysota/sysotad.conf
[Debug]
BootAPI = $BOOT_API_DEBUG
SYSOTAD_CONF
......@@ -21,5 +19,4 @@ execute: |
diff -u introspection-actual.txt "$EXPECTED"
restore: |
rm -f introspection-actual.txt
rm -f /etc/sysota/sysotad.conf
systemctl stop sysotad.service
......@@ -4,12 +4,12 @@
summary: Initial smoke tests
execute: |
# The three properties can be read
test "$(busctl get-property org.oniroproject.sysota1 /org/oniroproject/sysota1/Service org.oniroproject.sysota1.Service Maker)" = 's "dummy-maker"'
test "$(busctl get-property org.oniroproject.sysota1 /org/oniroproject/sysota1/Service org.oniroproject.sysota1.Service Model)" = 's "dummy-model"'
test "$(busctl get-property org.oniroproject.sysota1 /org/oniroproject/sysota1/Service org.oniroproject.sysota1.Service Stream)" = 's "dummy-stream"'
test "$(busctl get-property org.oniroproject.sysota1 /org/oniroproject/sysota1/Service org.oniroproject.sysota1.Service Maker)" = 's "test-maker"'
test "$(busctl get-property org.oniroproject.sysota1 /org/oniroproject/sysota1/Service org.oniroproject.sysota1.Service Model)" = 's "test-model"'
test "$(busctl get-property org.oniroproject.sysota1 /org/oniroproject/sysota1/Service org.oniroproject.sysota1.Service Stream)" = 's "test-stream"'
# The 'Stream' property can be written as well
test "$(busctl get-property org.oniroproject.sysota1 /org/oniroproject/sysota1/Service org.oniroproject.sysota1.Service Stream)" = 's "dummy-stream"'
test "$(busctl get-property org.oniroproject.sysota1 /org/oniroproject/sysota1/Service org.oniroproject.sysota1.Service Stream)" = 's "test-stream"'
test "$(busctl set-property org.oniroproject.sysota1 /org/oniroproject/sysota1/Service org.oniroproject.sysota1.Service Stream s custom)" = ''
test "$(busctl get-property org.oniroproject.sysota1 /org/oniroproject/sysota1/Service org.oniroproject.sysota1.Service Stream)" = 's "custom"'
......
......@@ -120,9 +120,9 @@ func New(config *ota.Config, state *ota.SystemState, conn *dbus.Conn) (*Service,
}
// Configure and add the update service.
svc.updateService.maker = "dummy-maker"
svc.updateService.model = "dummy-model"
svc.updateService.stream = "dummy-stream"
svc.updateService.maker = config.DeviceMaker
svc.updateService.model = config.DeviceModel
svc.updateService.stream = config.UpdateStream
svc.sh.AddHostedService(&svc.updateService)
// Configure and add the RAUC service
......
......@@ -62,7 +62,11 @@ func (s *serviceSuite) EnsureService(c *C) {
}
func (s *serviceSuite) SetUpTest(c *C) {
s.config = ota.Config{}
s.config = ota.Config{
DeviceMaker: "test-maker",
DeviceModel: "test-model",
UpdateStream: "test-stream",
}
s.state = ota.SystemState{}
}
......@@ -217,15 +221,15 @@ func (s *serviceSuite) TestAccessPropertiesAcrossDBus(c *C) {
err := svcObject.Call("org.freedesktop.DBus.Properties.Get", 0, "org.oniroproject.sysota1.Service", "Maker").Store(&propValue)
c.Assert(err, IsNil)
c.Check(propValue, Equals, dbus.MakeVariant("dummy-maker"))
c.Check(propValue, Equals, dbus.MakeVariant("test-maker"))
err = svcObject.Call("org.freedesktop.DBus.Properties.Get", 0, "org.oniroproject.sysota1.Service", "Model").Store(&propValue)
c.Assert(err, IsNil)
c.Check(propValue, Equals, dbus.MakeVariant("dummy-model"))
c.Check(propValue, Equals, dbus.MakeVariant("test-model"))
err = svcObject.Call("org.freedesktop.DBus.Properties.Get", 0, "org.oniroproject.sysota1.Service", "Stream").Store(&propValue)
c.Assert(err, IsNil)
c.Check(propValue, Equals, dbus.MakeVariant("dummy-stream"))
c.Check(propValue, Equals, dbus.MakeVariant("test-stream"))
err = svcObject.Call("org.freedesktop.DBus.Properties.Get", 0, "org.oniroproject.sysota1.Service", "Potato").Store(&propValue)
c.Assert(err, ErrorMatches, `org.freedesktop.DBus.Properties.Error.PropertyNotFound`)
......@@ -238,9 +242,9 @@ func (s *serviceSuite) TestAccessPropertiesAcrossDBus(c *C) {
err = svcObject.Call("org.freedesktop.DBus.Properties.GetAll", 0, "org.oniroproject.sysota1.Service").Store(&propMap)
c.Assert(err, IsNil)
c.Check(propMap, DeepEquals, map[string]dbus.Variant{
"Maker": dbus.MakeVariant("dummy-maker"),
"Model": dbus.MakeVariant("dummy-model"),
"Stream": dbus.MakeVariant("dummy-stream"),
"Maker": dbus.MakeVariant("test-maker"),
"Model": dbus.MakeVariant("test-model"),
"Stream": dbus.MakeVariant("test-stream"),
})
err = svcObject.Call("org.freedesktop.DBus.Properties.GetAll", 0, "org.oniroproject.sysota1.Potato").Store(&propMap)
......@@ -274,9 +278,9 @@ func (s *serviceSuite) TestAccessPropertiesLocally(c *C) {
s.EnsureService(c)
// Properties can be read locally.
c.Check(s.svc.Maker(), Equals, "dummy-maker")
c.Check(s.svc.Model(), Equals, "dummy-model")
c.Check(s.svc.Stream(), Equals, "dummy-stream")
c.Check(s.svc.Maker(), Equals, "test-maker")
c.Check(s.svc.Model(), Equals, "test-model")
c.Check(s.svc.Stream(), Equals, "test-stream")
// Stream can be changed.
// TODO(zyga): observe the property changed signal.
......
......@@ -87,9 +87,18 @@ suites:
summary: integration tests for sysotad (service)
prepare-each: |
mkdir -p /etc/sysota
mkdir -p /run/sysota
cat <<SYSOTAD_CONF >/etc/sysota/sysotad.conf
[Device]
Maker=test-maker
Model=test-model
[Update]
Stream=test-stream
SYSOTAD_CONF
restore-each: |
# Remove any configuration changes.
rm -f /etc/sysota/sysotad.conf
rm -f /run/sysota/sysotad.conf
rmdir /etc/sysota
rm -rf /run/sysotad
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment