github.com/apprenda/kismatic@v1.12.0/integration-tests/hosts_file_test.go (about)

     1  package integration_tests
     2  
     3  import (
     4  	"fmt"
     5  	"os"
     6  	"time"
     7  
     8  	. "github.com/onsi/ginkgo"
     9  )
    10  
    11  var _ = Describe("hosts file modification feature", func() {
    12  	BeforeEach(func() {
    13  		dir := setupTestWorkingDir()
    14  		os.Chdir(dir)
    15  	})
    16  
    17  	Describe("enabling the hosts file modification feature", func() {
    18  		ItOnAWS("should result in a functional cluster [slow]", func(aws infrastructureProvisioner) {
    19  			WithInfrastructure(NodeCount{1, 1, 4, 0, 0}, Ubuntu1604LTS, aws, func(nodes provisionedNodes, sshKey string) {
    20  				By("Setting the hostnames to be different than the actual ones")
    21  
    22  				// test hostname feature and unusual hostname formats
    23  				loadBalancer := nodes.master[0].PublicIP
    24  				nodes.etcd[0].Hostname = "etcd01"
    25  				nodes.master[0].Hostname = "MASTER01"
    26  				nodes.worker[0].Hostname = "WORKER01"
    27  				nodes.worker[1].Hostname = "worker02.test"
    28  				nodes.worker[2].Hostname = "Worker-03"
    29  				nodes.worker[3].Hostname = "WORKER04"
    30  				// change the hostnames on the machines
    31  				for _, n := range nodes.allNodes() {
    32  					err := runViaSSH([]string{fmt.Sprintf("sudo hostnamectl set-hostname %s", n.Hostname)}, []NodeDeets{n}, sshKey, 1*time.Minute)
    33  					FailIfError(err, "Could not set change firewall")
    34  				}
    35  
    36  				plan := PlanAWS{
    37  					Etcd:             nodes.etcd,
    38  					Master:           nodes.master,
    39  					LoadBalancer:     loadBalancer,
    40  					Worker:           nodes.worker[0:3],
    41  					Ingress:          nodes.worker[0:3],
    42  					Storage:          nodes.worker[0:3],
    43  					SSHKeyFile:       sshKey,
    44  					SSHUser:          nodes.master[0].SSHUser,
    45  					ModifyHostsFiles: true,
    46  				}
    47  
    48  				By("Installing kismatic with bogus hostnames that are added to hosts files")
    49  				err := installKismaticWithPlan(plan)
    50  				FailIfError(err)
    51  
    52  				By("Adding a worker with a bogus hostname that is added to hosts files")
    53  				err = addNodeToCluster(nodes.worker[3], sshKey, []string{}, []string{})
    54  				FailIfError(err)
    55  			})
    56  		})
    57  	})
    58  })