github.com/coreos/mantle@v0.13.0/kola/tests/ignition/execution.go (about)

     1  // Copyright 2017 CoreOS, Inc.
     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  	"github.com/coreos/mantle/kola/cluster"
    19  	"github.com/coreos/mantle/kola/register"
    20  	"github.com/coreos/mantle/platform/conf"
    21  )
    22  
    23  func init() {
    24  	register.Register(&register.Test{
    25  		Name:        "cl.ignition.v1.once",
    26  		Run:         runsOnce,
    27  		ClusterSize: 1,
    28  		UserData: conf.Ignition(`{
    29                               "ignitionVersion": 1,
    30                               "storage": {
    31                                 "filesystems": [
    32                                   {
    33                                     "device": "/dev/disk/by-partlabel/ROOT",
    34                                     "format": "ext4",
    35                                     "files": [
    36                                       {
    37                                         "path": "/etc/ignition-ran",
    38                                         "contents": "Ignition ran.",
    39                                         "mode": 420
    40                                       }
    41                                     ]
    42                                   }
    43                                 ]
    44                               }
    45                             }`),
    46  		Distros: []string{"cl"},
    47  	})
    48  	register.Register(&register.Test{
    49  		Name:        "coreos.ignition.once",
    50  		Run:         runsOnce,
    51  		ClusterSize: 1,
    52  		UserData: conf.Ignition(`{
    53                               "ignition": { "version": "2.0.0" },
    54                               "storage": {
    55                                 "files": [
    56                                   {
    57                                     "filesystem": "root",
    58                                     "path": "/etc/ignition-ran",
    59                                     "contents": {
    60                                       "source": "data:,Ignition%20ran."
    61                                     },
    62                                     "mode": 420
    63                                   }
    64                                 ]
    65                               }
    66                             }`),
    67  		UserDataV3: conf.Ignition(`{
    68                               "ignition": { "version": "3.0.0" },
    69                               "storage": {
    70                                 "files": [
    71                                   {
    72                                     "path": "/etc/ignition-ran",
    73                                     "contents": {
    74                                       "source": "data:,Ignition%20ran."
    75                                     },
    76                                     "mode": 420
    77                                   }
    78                                 ]
    79                               }
    80                             }`),
    81  		Distros: []string{"cl", "fcos", "rhcos"},
    82  	})
    83  }
    84  
    85  func runsOnce(c cluster.TestCluster) {
    86  	m := c.Machines()[0]
    87  
    88  	// remove file created by Ignition; fail if it doesn't exist
    89  	c.MustSSH(m, "sudo rm /etc/ignition-ran")
    90  
    91  	err := m.Reboot()
    92  	if err != nil {
    93  		c.Fatalf("Couldn't reboot machine: %v", err)
    94  	}
    95  
    96  	// make sure file hasn't been recreated
    97  	c.MustSSH(m, "test ! -e /etc/ignition-ran")
    98  }