common

package
v0.13.1 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Apr 15, 2021 License: Apache-2.0 Imports: 30 Imported by: 0

Documentation

Overview

Copyright 2021 k0s authors

Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at

http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.

Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at

http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.

Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at

http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.

Index

Constants

View Source
const DefaultTimeout = 9 * time.Minute // The default golang test timeout is 10mins

DefaultTimeout defines the default timeout for triggering custom teardown functionality

Variables

This section is empty.

Functions

func WaitForCalicoReady

func WaitForCalicoReady(kc *kubernetes.Clientset) error

WaitForCalicoReady waits to see all calico pods healthy

func WaitForDaemonSet added in v0.13.0

func WaitForDaemonSet(kc *kubernetes.Clientset, name string) error

WaitForDaemonSet waits for daemon set be ready

func WaitForKubeRouterReady added in v0.13.0

func WaitForKubeRouterReady(kc *kubernetes.Clientset) error

WaitForKubeRouterReady waits to see all kube-router pods healthy

func WaitForMetricsReady added in v0.12.0

func WaitForMetricsReady(c *rest.Config) error

func WaitForPod added in v0.13.0

func WaitForPod(kc *kubernetes.Clientset, name string) error

WaitForPod waits for pod be running

Types

type FootlooseSuite

type FootlooseSuite struct {
	suite.Suite

	Cluster *cluster.Cluster

	ControllerCount       int
	WorkerCount           int
	KubeAPIExternalPort   int
	K0sAPIExternalPort    int
	KonnectivityAgentPort int
	KonnectivityAdminPort int
	WithLB                bool

	ExtraVolumes []config.Volume
	// contains filtered or unexported fields
}

FootlooseSuite defines all the common stuff we need to be able to run k0s testing on footloose

func (*FootlooseSuite) ControllerNode added in v0.12.1

func (s *FootlooseSuite) ControllerNode(idx int) string

ControllerNode gets the node name of given controller index

func (*FootlooseSuite) GetControllerIPAddress added in v0.13.0

func (s *FootlooseSuite) GetControllerIPAddress(idx int) string

GetMainIPAddress returns controller ip address

func (*FootlooseSuite) GetFileFromController

func (s *FootlooseSuite) GetFileFromController(controllerIdx int, path string) string

GetFile gets file from the controller with given index

func (*FootlooseSuite) GetHTTPStatus added in v0.12.1

func (s *FootlooseSuite) GetHTTPStatus(node string, port int, path string) (int, error)

func (*FootlooseSuite) GetJoinToken

func (s *FootlooseSuite) GetJoinToken(role string, extraArgs ...string) (string, error)

GetJoinToken generates join token for the asked role

func (*FootlooseSuite) GetKubeConfig added in v0.12.1

func (s *FootlooseSuite) GetKubeConfig(node string, k0sKubeconfigArgs ...string) (*rest.Config, error)

KubeClient return kube client by loading the admin access config from given node

func (*FootlooseSuite) GetNodeLabels added in v0.11.0

func (s *FootlooseSuite) GetNodeLabels(node string, kc *kubernetes.Clientset) (map[string]string, error)

GetNodeLabels return the labels of given node

func (*FootlooseSuite) InitController added in v0.12.1

func (s *FootlooseSuite) InitController(idx int, k0sArgs ...string) error

InitController initializes a controller

func (*FootlooseSuite) KubeClient

func (s *FootlooseSuite) KubeClient(node string, k0sKubeconfigArgs ...string) (*kubernetes.Clientset, error)

KubeClient return kube client by loading the admin access config from given node

func (*FootlooseSuite) MachineForName

func (s *FootlooseSuite) MachineForName(name string) (*cluster.Machine, error)

MachineForName gets the named machine details

func (*FootlooseSuite) PutFile added in v0.12.1

func (s *FootlooseSuite) PutFile(node, path, content string)

PutFile writes content to file on given node

func (*FootlooseSuite) RunWorkers

func (s *FootlooseSuite) RunWorkers(args ...string) error

RunWorkers joins all the workers to the cluster

func (*FootlooseSuite) RunWorkersWithToken added in v0.13.0

func (s *FootlooseSuite) RunWorkersWithToken(token string, args ...string) error

func (*FootlooseSuite) SSH

func (s *FootlooseSuite) SSH(node string) (*SSHConnection, error)

SSH establishes an SSH connection to the node

func (*FootlooseSuite) SetupSuite

func (s *FootlooseSuite) SetupSuite()

SetupSuite does all the setup work, namely boots up footloose cluster

func (*FootlooseSuite) TearDownSuite

func (s *FootlooseSuite) TearDownSuite()

TearDownSuite does the cleanup work, namely destroy the footloose boxes

func (*FootlooseSuite) WaitForKubeAPI

func (s *FootlooseSuite) WaitForKubeAPI(node string, k0sKubeconfigArgs ...string) error

WaitForKubeAPI waits until we see kube API online on given node. Timeouts with error return in 5 mins

func (*FootlooseSuite) WaitForNodeReady

func (s *FootlooseSuite) WaitForNodeReady(node string, kc *kubernetes.Clientset) error

WaitForNodeReady wait that we see the given node in "Ready" state in kubernetes API

func (*FootlooseSuite) WaitJoinAPI added in v0.12.1

func (s *FootlooseSuite) WaitJoinAPI(node string) error

WaitJoinApi waits untill we see k0s join api up-and-running on a given node Timeouts with error return in 5 mins

func (*FootlooseSuite) WorkerNode added in v0.12.1

func (s *FootlooseSuite) WorkerNode(idx int) string

WorkerNode gets the node name of given worker index

type SSHConnection

type SSHConnection struct {
	Address string
	User    string
	Port    int
	KeyPath string
	// contains filtered or unexported fields
}

SSHConnection describes an SSH connection

func (*SSHConnection) Connect

func (c *SSHConnection) Connect() error

Connect opens the SSH connection

func (*SSHConnection) Disconnect

func (c *SSHConnection) Disconnect()

Disconnect closes the SSH connection

func (*SSHConnection) ExecWithOutput

func (c *SSHConnection) ExecWithOutput(cmd string) (string, error)

ExecWithOutput execs a command on the host and returns its output

type TerraformMachineData

type TerraformMachineData struct {
	Controllers struct {
		IP []string `json:"value"`
	} `json:"controller_external_ip"`
	Workers struct {
		IP []string `json:"value"`
	} `json:"worker_external_ip"`
}

TerraformMachineData is the Golang representation of the terraform output

type VMSuite

type VMSuite struct {
	suite.Suite

	ControllerIP string
	WorkerIPs    []string
	// contains filtered or unexported fields
}

VMSuite

func (*VMSuite) GetConfig

func (s *VMSuite) GetConfig()

func (*VMSuite) GetJoinToken

func (s *VMSuite) GetJoinToken(role string) (string, error)

GetJoinToken generates join token for the asked role

func (*VMSuite) InitMainController

func (s *VMSuite) InitMainController() error

InitMainController inits first controller assuming it's first controller in the cluster

func (*VMSuite) KubeClient

func (s *VMSuite) KubeClient(node string) (*kubernetes.Clientset, error)

KubeClient return kube client by loading the admin access config from given node

func (*VMSuite) RunWorkers

func (s *VMSuite) RunWorkers() error

RunWorkers joins all the workers to the cluster

func (*VMSuite) SSH

func (s *VMSuite) SSH(ip string) (*SSHConnection, error)

SSH establishes an SSH connection to the node

func (*VMSuite) WaitForKubeAPI

func (s *VMSuite) WaitForKubeAPI(node string) error

WaitForKubeAPI waits until we see kube API online on given node. Timeouts with error return in 5 mins

func (*VMSuite) WaitForNodeReady

func (s *VMSuite) WaitForNodeReady(node string, kc *kubernetes.Clientset) error

WaitForNodeReady wait that we see the given node in "Ready" state in kubernetes API

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL