Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
38 commits
Select commit Hold shift + click to select a range
82137f7
saving current status before refactor (which is a draft but works)
nicob87 Mar 19, 2020
a07fb9a
a little bit more human readable
nicob87 Mar 19, 2020
1a2f6c5
draft ci, just to see whawt happend
nicob87 Mar 19, 2020
1e45513
missing setup and teardown
nicob87 Mar 19, 2020
c05f929
running smoke tests
nicob87 Mar 20, 2020
230fadb
?
nicob87 Mar 20, 2020
cbfa4ca
docker in docker?
nicob87 Mar 20, 2020
94d4749
installing kubectl
nicob87 Mar 20, 2020
de26304
user permission fixed?
nicob87 Mar 20, 2020
9476ff3
more junk
nicob87 Mar 20, 2020
d3a8910
other try
nicob87 Mar 20, 2020
9c76c38
just another test
nicob87 Mar 20, 2020
0d33eab
retrigger ci
nicob87 Mar 20, 2020
5a90981
explicit smoke_test build
nicob87 Mar 20, 2020
372cee3
testing google kubernetes engine orbe
nicob87 Mar 20, 2020
c300899
just install?
nicob87 Mar 20, 2020
439eee0
putting version
nicob87 Mar 20, 2020
755eae9
no install for now
nicob87 Mar 20, 2020
89eb694
using google cloud?
nicob87 Mar 20, 2020
b1836f1
using full vm runner
nicob87 Mar 21, 2020
82c4b07
trying to fix compiling
nicob87 Mar 21, 2020
3234b58
printing more debug info
nicob87 Mar 21, 2020
20769c9
forcing latest ubuntu
nicob87 Mar 21, 2020
b22fd39
and now?
nicob87 Mar 21, 2020
5808a8b
testing the cluster part
nicob87 Mar 21, 2020
ab99a3c
kubectl not installed correct
nicob87 Mar 21, 2020
d0076e7
installing go 1.13?
nicob87 Mar 21, 2020
4ae48dc
installing go 1.13?
nicob87 Mar 21, 2020
1eb71f3
running tests?!
nicob87 Mar 21, 2020
1966874
minor refactor, this workis using port forwarding
nicob87 Mar 22, 2020
c17388c
give time to port forwarding to start
nicob87 Mar 22, 2020
ced08fa
just retrigger
nicob87 Mar 22, 2020
b0c5193
created a couple packages
nicob87 Mar 23, 2020
6145054
rollback debug trash
nicob87 Mar 23, 2020
813272d
bugfix
nicob87 Mar 23, 2020
7f479f6
using interface
nicob87 Mar 23, 2020
7327e07
bugfix
nicob87 Mar 23, 2020
f9b609e
bug bugfix
nicob87 Mar 23, 2020
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
73 changes: 58 additions & 15 deletions .circleci/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -39,41 +39,34 @@ yaml-templates:
root: .
paths:
- dist

orbs:
gke: circleci/gcp-gke@x.y.z

workflows:
version: 2
build-workflow:
jobs:
- build-linux-386:
<<: *release_filters
- build-linux-amd64:
<<: *branch_filters
- build-darwin-386:
<<: *release_filters
- build-darwin-amd64:
<<: *branch_filters
<<: *release_filters
- build-windows-386:
<<: *release_filters
- build-windows-amd64:
<<: *branch_filters
- build-linux-arm:
<<: *release_filters
- build-linux-arm64:
<<: *release_filters
- test:
<<: *branch_filters
- smoke_test:
<<: *branch_filters

- publish-github-release:
<<: *release_filters
requires:
- build-linux-386
- build-linux-amd64
- build-darwin-386
- build-darwin-amd64
- build-windows-386
- build-windows-amd64
- build-linux-arm
- build-linux-arm64
- test
- smoke_test

jobs:
build-linux-amd64: &go_build
Expand Down Expand Up @@ -153,6 +146,56 @@ jobs:
name: Run Tests
command: go test ./...

smoke_test:
machine: true
environment: &environment
steps:
- run:
name: export
command: |
echo 'export KUBECONFIG=/home/circleci/.kube/config' >> $BASH_ENV
echo 'export GOROOT=/usr/local/go' >> $BASH_ENV
echo 'export GOPATH=$HOME/Projects/Proj1' >> $BASH_ENV
echo 'export PATH=$GOPATH/bin:$GOROOT/bin:$PATH' >> $BASH_ENV
source $BASH_ENV
- checkout
- run:
name: print environment
command: printenv
- run:
name: uname
command: uname -a
- run:
name: print go version
command: go version
- run:
name: install go 1.13
command: |
wget https://dl.google.com/go/go1.13.3.linux-amd64.tar.gz
sudo tar -xvf go1.13.3.linux-amd64.tar.gz
sudo rm -rf /usr/local/go && sudo mv go /usr/local
- run:
name: print go version
command: go version
- run:
name: get kind
command: env GO111MODULE=off go get sigs.k8s.io/kind
- run:
name: compile
command: make
- run:
name: Create kind clusterr
command: kind create cluster --wait 30m #bla
- run:
name: trying to install kubectl
command: curl -Lo kubectl https://storage.googleapis.com/kubernetes-release/release/v1.17.4/bin/linux/amd64/kubectl && mkdir -p ~/bin && mv kubectl ~/bin/ && chmod +x ~/bin/kubectl
- run:
name: print cluster info
command: kubectl cluster-info
- run:
name: Run Tests
command: ./skupper_smoke #set kubeconfig as parameter if needed

publish-github-release:
docker:
- image: cibuilds/github:0.10
Expand Down
1 change: 1 addition & 0 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ all: build

build:
go build -ldflags="-X main.version=${VERSION}" -o skupper cmd/skupper/skupper.go
go build -ldflags="-X main.version=${VERSION}" -o skupper_smoke cmd/skupper_smoke/skupper_smoke.go

clean:
rm -rf skupper release
Expand Down
29 changes: 29 additions & 0 deletions cmd/skupper_smoke/skupper_smoke.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
package main

import (
"flag"
"path/filepath"

"k8s.io/client-go/util/homedir"

"github.com/skupperproject/skupper-cli/pkg/smoke"
"github.com/skupperproject/skupper-cli/pkg/smoke/tcp_echo"
)

func main() {
testRunners := []smoke.SmokeTestRunnerInterface{&tcp_echo.SmokeTestRunner{}}

defaultKubeConfig := filepath.Join(homedir.HomeDir(), ".kube", "config")

pub1Kubeconfig := flag.String("pub1kubeconfig", defaultKubeConfig, "(optional) absolute path to the kubeconfig file")
pub2Kubeconfig := flag.String("pub2kubeconfig", defaultKubeConfig, "(optional) absolute path to the kubeconfig file")
priv1Kubeconfig := flag.String("priv1kubeconfig", defaultKubeConfig, "(optional) absolute path to the kubeconfig file")
priv2Kubeconfig := flag.String("priv2kubeconfig", defaultKubeConfig, "(optional) absolute path to the kubeconfig file")

flag.Parse()

for _, testRunner := range testRunners {
testRunner.Build(*pub1Kubeconfig, *pub2Kubeconfig, *priv1Kubeconfig, *priv2Kubeconfig)
testRunner.Run()
}
}
128 changes: 128 additions & 0 deletions pkg/smoke/smoke_test_runner.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,128 @@
package smoke

import (
"fmt"
"log"
"os/exec"
"time"

apiv1 "k8s.io/api/core/v1"
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"

"k8s.io/client-go/kubernetes"
"k8s.io/client-go/tools/clientcmd"
)

type SmokeTestRunnerInterface interface {
Build(public1ConficFile, public2ConficFile, private1ConfigFile, private2ConfigFile string)
Run()
}

type SmokeTestRunnerBase struct {
Pub1Cluster *ClusterContext
Pub2Cluster *ClusterContext
Priv1Cluster *ClusterContext
Priv2Cluster *ClusterContext
}

func (r *SmokeTestRunnerBase) Build(public1ConficFile, public2ConficFile, private1ConfigFile, private2ConfigFile string) {
r.Pub1Cluster = BuildClusterContext("public1", public1ConficFile)
r.Pub2Cluster = BuildClusterContext("public2", public2ConficFile)
r.Priv1Cluster = BuildClusterContext("private1", private1ConfigFile)
r.Priv2Cluster = BuildClusterContext("private2", private2ConfigFile)
}

type ClusterContext struct {
Namespace string
ClusterConfigFile string
Clientset *kubernetes.Clientset
}

func BuildClusterContext(namespace string, configFile string) *ClusterContext {
cc := &ClusterContext{}
cc.Namespace = namespace
cc.ClusterConfigFile = configFile

config, err := clientcmd.BuildConfigFromFlags("", configFile)
if err != nil {
log.Panic(err.Error())
}

cc.Clientset, err = kubernetes.NewForConfig(config)
if err != nil {
log.Panic(err.Error())
}
return cc
}

func _exec(command string, wait bool) {
var output []byte
var err error
fmt.Println(command)
cmd := exec.Command("sh", "-c", command)
if wait {
output, err = cmd.CombinedOutput()
} else {
cmd.Start()
return
}
if err != nil {
panic(err)
}
fmt.Println(string(output))
}

func (cc *ClusterContext) exec(main_command string, sub_command string, wait bool) {
_exec("KUBECONFIG="+cc.ClusterConfigFile+" "+main_command+" "+cc.Namespace+" "+sub_command, wait)
}

func (cc *ClusterContext) SkupperExec(command string) {
cc.exec("./skupper -n ", command, true)
}

func (cc *ClusterContext) _kubectl_exec(command string, wait bool) {
cc.exec("kubectl -n ", command, wait)
}

func (cc *ClusterContext) KubectlExec(command string) {
cc._kubectl_exec(command, true)
}

func (cc *ClusterContext) KubectlExecAsync(command string) {
cc._kubectl_exec(command, false)
}

func (cc *ClusterContext) CreateNamespace() {
NsSpec := &apiv1.Namespace{ObjectMeta: metav1.ObjectMeta{Name: cc.Namespace}}
_, err := cc.Clientset.CoreV1().Namespaces().Create(NsSpec)
if err != nil {
log.Panic(err.Error())
}
}

func (cc *ClusterContext) DeleteNamespace() {
err := cc.Clientset.CoreV1().Namespaces().Delete(cc.Namespace, &metav1.DeleteOptions{})
if err != nil {
log.Panic(err.Error())
}
}

func (cc *ClusterContext) GetService(name string, timeout_S time.Duration) *apiv1.Service {
timeout := time.After(timeout_S * time.Second)
tick := time.Tick(3 * time.Second)
for {
select {
case <-timeout:
log.Panicln("Timed Out Waiting for service.")
case <-tick:
service, err := cc.Clientset.CoreV1().Services(cc.Namespace).Get(name, metav1.GetOptions{})
if err == nil {
return service
} else {
log.Println("Service not ready yet, current pods state: ")
cc.KubectlExec("get pods -o wide") //TODO use clientset
}

}
}
}
Loading