github.com/coreos/mantle@v0.13.0/kola/tests/ignition/systemd.go (about) 1 // Copyright 2018 Red Hat 2 // 3 // Licensed under the Apache License, Version 2.0 (the "License"); 4 // you may not use this file except in compliance with the License. 5 // You may obtain a copy of the License at 6 // 7 // http://www.apache.org/licenses/LICENSE-2.0 8 // 9 // Unless required by applicable law or agreed to in writing, software 10 // distributed under the License is distributed on an "AS IS" BASIS, 11 // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 // See the License for the specific language governing permissions and 13 // limitations under the License. 14 15 package ignition 16 17 import ( 18 "strings" 19 20 "github.com/coreos/mantle/kola/cluster" 21 "github.com/coreos/mantle/kola/register" 22 "github.com/coreos/mantle/platform/conf" 23 ) 24 25 func init() { 26 register.Register(®ister.Test{ 27 Name: "coreos.ignition.systemd.enable-service", 28 Run: enableSystemdService, 29 ClusterSize: 1, 30 // enable nfs-server, touch /etc/exports as it doesn't exist by default on Container Linux, 31 // and touch /var/lib/nfs/etab (https://bugzilla.redhat.com/show_bug.cgi?id=1394395) for RHCOS 32 UserData: conf.Ignition(`{ 33 "ignition": {"version": "2.2.0"}, 34 "systemd": { 35 "units": [{ 36 "name":"nfs-server.service", 37 "enabled":true 38 }] 39 }, 40 "storage": { 41 "files": [{ 42 "filesystem":"root", 43 "path":"/etc/exports" 44 }, 45 { 46 "filesystem":"root", 47 "path":"/var/lib/nfs/etab" 48 }] 49 } 50 }`), 51 UserDataV3: conf.Ignition(`{ 52 "ignition": {"version": "3.0.0"}, 53 "systemd": { 54 "units": [{ 55 "name":"nfs-server.service", 56 "enabled":true 57 }] 58 }, 59 "storage": { 60 "files": [{ 61 "path":"/etc/exports" 62 }, 63 { 64 "path":"/var/lib/nfs/etab" 65 }] 66 } 67 }`), 68 // https://github.com/coreos/mantle/issues/999 69 // On the qemu-unpriv platform the DHCP provides no data, pre-systemd 241 the DHCP server sending 70 // no routes to the link to spin in the configuring state. nfs-server.service pulls in the network-online 71 // target which causes the basic machine checks to fail 72 ExcludePlatforms: []string{"qemu-unpriv"}, 73 // FCOS just ships the client (see 74 // https://github.com/coreos/fedora-coreos-tracker/issues/121). 75 // Should probably just pick a different unit to test with, though 76 // testing the NFS workflow is useful for RHCOS/CL. 77 ExcludeDistros: []string{"fcos"}, 78 }) 79 } 80 81 func enableSystemdService(c cluster.TestCluster) { 82 m := c.Machines()[0] 83 84 out := c.MustSSH(m, "systemctl status nfs-server.service") 85 if strings.Contains(string(out), "inactive") { 86 c.Fatalf("service was not enabled or systemd-presets did not run") 87 } 88 }