Skip to content

Commit

Permalink
Adding an interactive mode, and fixed travisCI and added some more ya…
Browse files Browse the repository at this point in the history
…ml2cluster tests (#7)

Adding an interactive mode, and fixed travisCI and added some more yaml2cluster tests
  • Loading branch information
joshuacox authored Mar 15, 2018
1 parent 41dad82 commit 2c0212e
Show file tree
Hide file tree
Showing 10 changed files with 328 additions and 36 deletions.
1 change: 1 addition & 0 deletions .fails.bats → .ci/.fails.bats
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
#!/usr/bin/env bats
PATH=/home/travis/build/joshuacox/kubash/bin:/home/travis/.kubash/bin:$PATH

@test "checkbashisms kubash" {
result="$(checkbashisms -xnfp ./bin/kubash)"
Expand Down
82 changes: 82 additions & 0 deletions .ci/.tests.bats
Original file line number Diff line number Diff line change
@@ -0,0 +1,82 @@
#!/usr/bin/env bats
PATH=/home/travis/build/joshuacox/kubash/bin:/home/travis/.kubash/bin:$PATH
setup () {
#MY_TMP=$(mktemp --suffix=cluster -d -p clusters exampleXXX )
MY_TMP=exampleOWFjMGQ4ZjMtest
}

@test "yaml2cluster test" {
rm -Rf clusters/$MY_TMP
yamlresult="$(kubash yaml2cluster examples/example-cluster.yaml -n $MY_TMP)"
cp $HOME/.kube/config clusters/$MY_TMP/
[ -e "clusters/$MY_TMP/provision.csv" ]
}

@test "minikube config" {
result="$(cp $HOME/.kube/config clusters/$MY_TMP/)"
[ -e "clusters/$MY_TMP/config" ]
}

@test "yaml2cluster primary_master" {
result="$(cut -f2 -d, clusters/$MY_TMP/provision.csv|head -n1)"
[ "$result" = 'primary_master' ]
}

@test "yaml2cluster cpu" {
result="$(cut -f3 -d, clusters/$MY_TMP/provision.csv|head -n1)"
[ "$result" -eq 1 ]
}

@test "yaml2cluster memory" {
result="$(cut -f4 -d, clusters/$MY_TMP/provision.csv|head -n1)"
[ "$result" -eq 1100 ]
}

@test "yaml2cluster network" {
result="$(cut -f5 -d, clusters/$MY_TMP/provision.csv|head -n1)"
[ "$result" = 'network=default' ]
}

@test "yaml2cluster mac" {
result="$(cut -f6 -d, clusters/$MY_TMP/provision.csv|head -n1)"
[ "$result" = '52:54:00:e2:8a:11' ]
}

@test "yaml2cluster dhcp" {
result="$(cut -f7 -d, clusters/$MY_TMP/provision.csv|head -n1)"
[ "$result" = 'dhcp' ]
}

@test "yaml2cluster localhost" {
result="$(cut -f8 -d, clusters/$MY_TMP/provision.csv|head -n1)"
[ "$result" = 'localhost' ]
}

@test "yaml2cluster root" {
result="$(cut -f9 -d, clusters/$MY_TMP/provision.csv|head -n1)"
[ "$result" = 'root' ]
}

@test "yaml2cluster 22" {
result="$(cut -f10 -d, clusters/$MY_TMP/provision.csv|head -n1)"
[ "$result" -eq 22 ]
}

@test "yaml2cluster libvirt" {
result="$(cut -f11 -d, clusters/$MY_TMP/provision.csv|head -n1)"
[ "$result" = '/var/lib/libvirt/images' ]
}

@test "yaml2cluster kubeadm" {
result="$(cut -f12 -d, clusters/$MY_TMP/provision.csv|head -n1)"
[ "$result" = 'kubeadm' ]
}

@test "yaml2cluster qemu" {
result="$(cut -f13 -d, clusters/$MY_TMP/provision.csv|head -n1)"
[ "$result" = 'qemu' ]
}
@test "rm cluster test dir" {
run rm -Rf clusters/$MY_TMP
[ "$status" -eq 0 ]
}
6 changes: 0 additions & 6 deletions .tests.bats

This file was deleted.

45 changes: 43 additions & 2 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,16 +9,23 @@ matrix:
directories:
- $HOME/.minikube
- $HOME/.kube
- $HOME/.kubash
- $HOME/.local/bin
- .git
- /usr/local
env:
- MINIKUBE_MEMORY=7777
- MINIKUBE_CPU=4
- MINIKUBE_DRIVER=none
- HELM_INSTALL_DIR=$HOME/.local/bin
- NVM_DIR="$HOME/.nvm"

<<<<<<< HEAD
language: node
nodejs:
=======
language: node_js
node_js:
>>>>>>> travis
- "8"

addons:
Expand All @@ -32,20 +39,54 @@ addons:
- ansible
- parallel
- golang
- nmap
- python-pip

before_install:
# install nsenter which is required for port forwarding
- if [[ "$TRAVIS_OS_NAME" == "linux" ]]; then .ci/ubuntu-compile-nsenter.sh && sudo cp .tmp/util-linux-2.30.2/nsenter /usr/local/bin; fi
- npm i -g yaml2json
- ln -s $(pwd) /home/travis/.kubash
- make bats
<<<<<<< HEAD
- bash scripts/dotfiles
- bash scripts/chkdirs
- /usr/bin/time -v make -e linuxreqs

script:
=======
- make ct

script:
- ls -alh /home/travis
- ls -alh /home/travis/.kubash
- ls -alh /home/travis/.kubash/bin
- if [[ ! -e "$HOME/.local/bin/nsenter" ]]; then .ci/ubuntu-compile-nsenter.sh && sudo cp .tmp/util-linux-2.30.2/nsenter $HOME/.local/bin; fi
- curl -sL --silent https://raw.githubusercontent.com/kubernetes/helm/master/scripts/get|bash
- bash scripts/dotfiles
- bash scripts/chkdirs
>>>>>>> travis
- sudo chown -R $USER /usr/local
- sudo mkdir -p /etc/kubernetes
- sudo chown -R $USER /etc/kubernetes
- /bin/bash -l -c "/usr/bin/time -v make -e ci"
<<<<<<< HEAD
- bin/kubash yaml2cluster -n default $(KUBASH_DIR)/examples/example-cluster.yaml
- /bin/bash -l -c "echo kubash openebs"
- bats .tests.bats
=======
- env
- pwd
- mkdir -p clusters/default
- cp $HOME/.kube/config clusters/default/
- /bin/bash -l -c "kubash openebs"
- /bin/bash -l -c "w8s/generic.w8 openebs-provisioner default"
- bats .ci/.tests.bats
- /bin/bash -l -c "kubash demo"
# too much memory usage so we will end it there and destroy the VM
# as the next though successful take too long
#- /bin/bash -l -c "kubash demo"
#- /bin/bash -l -c "w8s/generic.w8 percona default"
#- /bin/bash -l -c "w8s/generic.w8 pgset-0 default"
#- /bin/bash -l -c "w8s/generic.w8 rabbitmq-0 default"
#- /bin/bash -l -c "w8s/generic.w8 mongo-0 default"
>>>>>>> travis
27 changes: 27 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -43,13 +43,31 @@ $(eval PROMETHEUS_ALERTMANAGER_PERSISTENTVOLUME_SUBPATH := "")
# Helm settings
$(eval HELM_INSTALL_DIR := "$(KUBASH_BIN)")

all: $(KUBASH_BIN)/kush $(KUBASH_BIN)/kzsh $(KUBASH_BIN)/kudash reqs anaconda nvm

reqs: linuxreqs

<<<<<<< HEAD
linuxreqs: $(KUBASH_BIN) kubectl helm minikube jinja2 submodules/openebs yaml2json
=======
linuxreqs: kubectl helm minikube jinja2 submodules/openebs yaml2json ct
>>>>>>> travis

helm: $(KUBASH_BIN)
@scripts/kubashnstaller helm

$(KUBASH_BIN)/kush:
echo '#!/usr/bin/env sh' > $(KUBASH_BIN)/kush
tail -n +2 "$(KUBASH_BIN)/kubash" >> $(KUBASH_BIN)/kush

$(KUBASH_BIN)/kzsh:
echo '#!/usr/bin/env zsh' > $(KUBASH_BIN)/kzsh
tail -n +2 "$(KUBASH_BIN)/kubash" >> $(KUBASH_BIN)/kzsh

$(KUBASH_BIN)/kudash:
echo '#!/usr/bin/env dash' > $(KUBASH_BIN)/kudash
tail -n +2 "$(KUBASH_BIN)/kubash" >> $(KUBASH_BIN)/kudash

$(KUBASH_BIN)/helm: SHELL:=/bin/bash
$(KUBASH_BIN)/helm:
@echo 'Installing helm'
Expand Down Expand Up @@ -313,3 +331,12 @@ cfssl:

jinja2:
pip install jinja2 jinja2-cli

anaconda: $(KUBASH_BIN)/Anaconda.sh
bash $(KUBASH_BIN)/Anaconda.sh

$(KUBASH_BIN)/Anaconda.sh:
wget -c -O $(KUBASH_BIN)/Anaconda.sh https://repo.continuum.io/archive/Anaconda3-5.1.0-Linux-x86_64.sh

nvm:
curl --silent -o- https://raw.githubusercontent.com/creationix/nvm/v0.33.8/install.sh | bash
33 changes: 32 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,12 @@
Build, provision, initialize, add common components, and tear down a cluster PDQ.

[![Build Status](https://travis-ci.org/kubash/kubash.svg?branch=master)](https://travis-ci.org/kubash/kubash)
<<<<<<< HEAD
=======
[![Waffle.io - Columns and their card count](https://badge.waffle.io/kubash/kubash.svg?columns=all)](https://waffle.io/kubash/kubash)

old waffle (still has quite a backlog)
>>>>>>> travis
[![Waffle.io - Columns and their card count](https://badge.waffle.io/joshuacox/kubash.svg?columns=all)](https://waffle.io/joshuacox/kubash)

Dev [![Build Status](https://travis-ci.org/joshuacox/kubash.svg?branch=master)](https://travis-ci.org/joshuacox/kubash)
Expand Down Expand Up @@ -203,9 +206,37 @@ And you can also add a debug flag:
kubash --debug --verbosity 100 init
```


try `kubash COMMAND --help`

### Interactive Mode

`kubash` -- alone will invoke an interactive shell (or if you prefer
`kubash interactive`)

```
### Kubash, by Josh Cox
---------------------------------------------------------------------------------------------------------------
Interactive Kubash Shell Enter 'help' for help, or 'quit' to quit
working with the default kubash cluster, or set with 'clustername'
---------------------------------------------------------------------------------------------------------------
K8$
```

At this prompt you can invoke all the kubash commands in a read loop,
this can eliminate alot of typing while interacting with a cluster.
There are a few special commands that you can invoke in the interactive
shell. `name EXAMPLE` will set the name of the cluster that you are
interacting with. `verbosity 10` will set the verbosity to 10. `v` will
increment the verbosity up one.

### Parallel jobs

To set the number of concurrent jobs export PARALLEL_JOBS e.g.

```
export PARALLEL_JOBS=10
```

### [GNU Parallel](https://www.gnu.org/software/parallel/)

This project takes advantage of [GNU Parallel](https://www.gnu.org/software/parallel/) gnu parallel and so should you, for more info see:
Expand Down
4 changes: 4 additions & 0 deletions bin/.gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -9,3 +9,7 @@ cfssl
cfssljson
crictl
ct
kzsh
kudash
kush
minikube
Loading

0 comments on commit 2c0212e

Please sign in to comment.