github.com/coreos/mantle@v0.13.0/kola/tests/docker/torcx_docker_flag.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 docker 16 17 import ( 18 "regexp" 19 20 "github.com/coreos/mantle/kola/cluster" 21 "github.com/coreos/mantle/kola/register" 22 "github.com/coreos/mantle/platform" 23 "github.com/coreos/mantle/platform/conf" 24 ) 25 26 func init() { 27 register.Register(®ister.Test{ 28 Run: dockerTorcxFlagFile, 29 ClusterSize: 1, 30 Name: "docker.torcx-flag-file", 31 UserData: conf.ContainerLinuxConfig(` 32 storage: 33 files: 34 - filesystem: root 35 path: /etc/coreos/docker-1.12 36 contents: 37 inline: yes 38 mode: 0644 39 `), 40 Distros: []string{"cl"}, 41 }) 42 register.Register(®ister.Test{ 43 Run: dockerTorcxFlagFileCloudConfig, 44 ClusterSize: 1, 45 Name: "docker.torcx-flag-file.cloud-config", 46 UserData: conf.CloudConfig(` 47 #cloud-config 48 write_files: 49 - path: "/etc/coreos/docker-1.12" 50 content: yes 51 `), 52 Distros: []string{"cl"}, 53 ExcludePlatforms: []string{"qemu-unpriv"}, 54 }) 55 } 56 57 func dockerTorcxFlagFile(c cluster.TestCluster) { 58 m := c.Machines()[0] 59 60 // flag=yes 61 checkTorcxDockerVersions(c, m, `^1\.12$`, `^1\.12\.`) 62 63 // flag=no 64 c.MustSSH(m, "echo no | sudo tee /etc/coreos/docker-1.12") 65 if err := m.Reboot(); err != nil { 66 c.Fatalf("could not reboot: %v", err) 67 } 68 c.MustSSH(m, `sudo rm -rf /var/lib/docker`) 69 checkTorcxDockerVersions(c, m, `^1[7-9]\.`, `^1[7-9]\.`) 70 } 71 72 func dockerTorcxFlagFileCloudConfig(c cluster.TestCluster) { 73 m := c.Machines()[0] 74 75 // cloudinit runs after torcx 76 if err := m.Reboot(); err != nil { 77 c.Fatalf("couldn't reboot: %v", err) 78 } 79 80 // flag=yes 81 checkTorcxDockerVersions(c, m, `^1\.12$`, `^1\.12\.`) 82 } 83 84 func checkTorcxDockerVersions(c cluster.TestCluster, m platform.Machine, expectedRefRE, expectedVerRE string) { 85 ref := getTorcxDockerReference(c, m) 86 if !regexp.MustCompile(expectedRefRE).MatchString(ref) { 87 c.Errorf("reference %s did not match %q", ref, expectedRefRE) 88 } 89 90 ver := getDockerServerVersion(c, m) 91 if !regexp.MustCompile(expectedVerRE).MatchString(ver) { 92 c.Errorf("version %s did not match %q", ver, expectedVerRE) 93 } 94 }