Remove old scripts, modify manual syncing doc script (#1549)

Maintenance!

Removes all the old scripts now used, and adds a "manual" doc sync
maintenance script which we have yet to automate.

Signed-off-by: Charlie Drage <charlie@charliedrage.com>

Signed-off-by: Charlie Drage <charlie@charliedrage.com>
This commit is contained in:
Charlie Drage 2023-01-12 15:37:58 -05:00 committed by GitHub
parent 2ad5745d58
commit e85329f330
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
40 changed files with 4 additions and 4659 deletions

View File

@ -1,38 +0,0 @@
#!/bin/bash
# Copyright 2017 The Kubernetes Authors All rights reserved.
#
# 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.
# This checks if all go source files in current directory are format using gofmt
GO_FILES=$(find . -path ./vendor -prune -o -name '*.go' -print )
for file in $GO_FILES; do
gofmtOutput=$(gofmt -l "$file")
if [ "$gofmtOutput" ]; then
errors+=("$gofmtOutput")
fi
done
if [ ${#errors[@]} -eq 0 ]; then
echo "gofmt OK"
else
echo "gofmt ERROR - These files are not formatted by gofmt:"
for err in "${errors[@]}"; do
echo "$err"
done
exit 1
fi

View File

Binary file not shown.

View File

@ -1,47 +0,0 @@
#!/bin/sh
DATE=`date --iso-8601=date`
TIME=`date --iso-8601=seconds`
# GITHUB_PULL_REQUEST MUST be set by your own hands.
# See: https://github.com/actions/checkout/issues/58
cat > "./.bintray.json" <<EOF
{
"package": {
"name": "kompose",
"repo": "kompose",
"subject": "kompose",
"desc": "Go from Docker Compose to Kubernetes",
"website_url": "https://github.com/kubernetes/kompose",
"issue_tracker_url": "https://github.com/kubernetes/komposeissues",
"vcs_url": "https://github.com/kubernetes/kompose",
"licenses": ["Apache-2.0"],
"public_download_numbers": false,
"public_stats": false
},
"version": {
"name": "latest",
"desc": "Kompose build from master branch",
"released": "${DATE}",
"vcs_tag": "${GITHUB_SHA}",
"attributes": [{"name": "GITHUB_RUN_NUMBER", "values" : ["${GITHUB_RUN_NUMBER}"], "type": "string"},
{"name": "GITHUB_RUN_ID", "values" : ["${GITHUB_RUN_ID}"], "type": "string"},
{"name": "GITHUB_SHA", "values" : ["${GITHUB_SHA}"], "type": "string"},
{"name": "GITHUB_REF", "values" : ["${GITHUB_REF}"], "type": "string"},
{"name": "GITHUB_PULL_REQUEST", "values" : ["${GITHUB_PULL_REQUEST}"], "type": "string"},
{"name": "date", "values" : ["${TIME}"], "type": "date"}],
"gpgSign": false
},
"files":
[
{"includePattern": "bin/(.*)",
"uploadPattern": "./latest/\$1",
"matrixParams": {"override": 1 }
}
],
"publish": true
}
EOF

View File

@ -1,13 +1,11 @@
#!/usr/bin/env bash
## README:
## This script is ran by running:
## cd script
## ./manual-docs-sync.sh
##
## This will take all documentation from the /docs folder of the master dir, add jekyll-related-metadata
## and push to the gh-pages branch.
## This will take all documentation from the /docs folder of the master dir and push to the gh-pages branch (granted you have access)
DOCS_REPO_NAME="kompose"
DOCS_REPO_URL="git@github.com:kubernetes/kompose.git"
@ -24,49 +22,9 @@ cd "$DOCS_REPO_NAME"
git checkout gh-pages
git checkout master docs
# Remove README.md from docs folder as it isn't relevant
rm docs/README.md
# Use introduction.md instead as the main index page
mv docs/introduction.md index.md
# Check that index.md has the appropriate Jekyll format
index="index.md"
if cat $index | head -n 1 | grep "\-\-\-";
then
echo "index.md already contains Jekyll format"
else
# Remove ".md" from the name
name=${index::-3}
echo "Adding Jekyll file format to $index"
jekyll="---
layout: default
---
"
echo -e "$jekyll\n$(cat $index)" > $index
fi
# clean-up the docs and convert to jekyll-friendly docs
cd docs
for filename in *.md; do
if cat $filename | head -n 1 | grep "\-\-\-";
then
echo "$filename already contains Jekyll format"
else
# Remove ".md" from the name
name=${filename::-3}
echo "Adding Jekyll file format to $filename"
jekyll="---
layout: default
permalink: /$name/
redirect_from:
- /docs/$name.md/
---
"
echo -e "$jekyll\n$(cat $filename)" > $filename
fi
done
cd ..
# Copy it all over to the current directory
cp -r docs/* .
rm -r docs
git add --all

View File

@ -1,84 +0,0 @@
#!/usr/bin/env bash
DOCS_REPO_NAME="kompose"
DOCS_REPO_URL="git@github.com:kubernetes/kompose.git"
DOCS_KEY="script/deploy_key"
DOCS_USER="komposebot"
DOCS_EMAIL="cdrage+kompose@redhat.com"
DOCS_BRANCH="gh-pages"
DOCS_FOLDER="docs"
# decrypt the private key
openssl aes-256-cbc -K $encrypted_b1c51b116939_key -iv $encrypted_b1c51b116939_iv -in "$DOCS_KEY.enc" -out "$DOCS_KEY" -d
chmod 600 "$DOCS_KEY"
eval `ssh-agent -s`
ssh-add "$DOCS_KEY"
# clone the repo
git clone "$DOCS_REPO_URL" "$DOCS_REPO_NAME"
# change to that directory (to prevent accidental pushing to master, etc.)
cd "$DOCS_REPO_NAME"
# switch to gh-pages and grab the docs folder from master
git checkout gh-pages
git checkout master docs
# Remove README.md from docs folder as it isn't relevant
rm docs/README.md
# Use introduction.md instead as the main index page
mv docs/introduction.md index.md
# Check that index.md has the appropriate Jekyll format
index="index.md"
if cat $index | head -n 1 | grep "\-\-\-";
then
echo "index.md already contains Jekyll format"
else
# Remove ".md" from the name
name=${index::-3}
echo "Adding Jekyll file format to $index"
jekyll="---
layout: default
---
"
echo -e "$jekyll\n$(cat $index)" > $index
fi
# clean-up the docs and convert to jekyll-friendly docs
cd docs
for filename in *.md; do
if cat $filename | head -n 1 | grep "\-\-\-";
then
echo "$filename already contains Jekyll format"
else
# Remove ".md" from the name
name=${filename::-3}
echo "Adding Jekyll file format to $filename"
jekyll="---
layout: default
permalink: /$name/
redirect_from:
- /docs/$name.md/
---
"
echo -e "$jekyll\n$(cat $filename)" > $filename
fi
done
cd ..
# add relevant user information
git config user.name "$DOCS_USER"
# email assigned to @komposebot
git config user.email "$DOCS_EMAIL"
git add --all
# Check if anything changed, and if it's the case, push to origin/master.
if git commit -m 'Update docs' -m "Commit: https://github.com/kubernetes/kompose/commit/$GITHUB_SHA" ; then
git push
fi
# cd back to the original root folder
cd ..

View File

@ -1,46 +0,0 @@
# Functional tests for Kompose on OpenShift
## Introduction
The functional tests for Kompose on OpenShift cluster leverages `oc cluster up` to bring a single-cluster OpenShift instance. The test scripts
are hosted under script/test_in_openshift.
The directory structure is as below:
```
script/test_in_openshift/
├── compose-files
│ └── docker-compose-command.yml
├── lib.sh
├── run.sh
└── tests
├── buildconfig.sh
├── entrypoint-command.sh
├── etherpad.sh
└── redis-replica-2.sh
└── ..
```
- [run.sh](/script/test_in_openshift/run.sh) is the master script which executes all the tests.
- [lib.sh](/script/test_in_openshift/lib.sh) consists of helper functions for `kompose up` and `kompose down` checks.
- [tests/](/script/test_in_openshift/tests) directory contains the test scripts.
- [compose-files/](/script/test_in_openshift/compose-files/) directory contains the docker compose file used by the test scripts.
- The scripts use [`oc cluster up`](https://github.com/openshift/origin/blob/master/docs/cluster_up_down.md) for setting up a single-machine OpenShift cluster. It exits if oc binaries are not installed.
- Docker Compose examples are available under [examples/](/examples] or [/script/test/fixtures](/script/test/fixtures).
## Running OpenShift tests
### Deploy `oc cluster up`
The scripts use [`oc cluster up`](https://github.com/openshift/origin/blob/master/docs/cluster_up_down.md) for setting up a single-machine OpenShift cluster. Installing oc binary is a pre-requisite for running these tests.
Use `make test-openshift` to run the OpenShift tests.
## Adding OpenShift tests
* You can add the OpenShift tests by adding your script under [script/test_in_openshift/tests](/script/test_in_openshift/tests).

View File

@ -1,24 +0,0 @@
version: '3'
services:
backend-server:
image: "172.30.1.1:5000/myproject/test-image"
build:
context: ../server
dockerfile: Dockerfile
env_file:
- ../docker_env.list
ports:
- 5000:4000
front-end:
image: "172.30.1.1:5000/myproject/test-image"
build:
context: ../web
dockerfile: Dockerfile
env_file:
- ../docker_env.list
ports:
- 8080:8080
depends_on:
- backend-server

View File

@ -1,3 +0,0 @@
FROM busybox:1.26.2
RUN touch /test

View File

@ -1,3 +0,0 @@
FROM busybox:1.26.2
RUN touch /test

View File

@ -1,3 +0,0 @@
FROM busybox:1.26.2
RUN touch /test

View File

@ -1,7 +0,0 @@
version: "2"
services:
foo:
build: "./build"
image: "172.30.1.1:5000/myproject/test-image"
command: sleep 100

View File

@ -1,6 +0,0 @@
version: "2"
services:
foo:
build: "./build"
command: sleep 100

View File

@ -1,8 +0,0 @@
version: "2"
services:
foo:
build:
context: "../../../examples/buildconfig/build"
dockerfile: "Dockerfile"
command: "sleep 3600"

View File

@ -1,10 +0,0 @@
version: '2'
services:
base1:
image: busybox
command: ['sleep','10000']
base2:
image: busybox
entrypoint: ['sleep','10000']

View File

@ -1,7 +0,0 @@
version: '2'
services:
pival:
image: perl
command: ["perl", "-Mbignum=bpi", "-wle", "print bpi(2000)"]
restart: "always"

View File

@ -1,17 +0,0 @@
version: "2"
services:
web:
ports:
- "5000:5000"
depends_on:
- redis
- web
redis:
image: redis:${TAG}
ports:
- "6379"
web:
image: tuna/docker-counter23

View File

@ -1,8 +0,0 @@
version: '3'
services:
pival:
image: perl
command: ["perl", "-Mbignum=bpi", "-wle", "print bpi(2000)"]
restart: "always"

View File

@ -1,14 +0,0 @@
version: "3"
services:
web:
image: tuna/docker-counter23
ports:
- "5000:5000"
links:
- redis
redis:
image: redis:3.0
ports:
- "6379"

View File

@ -1,17 +0,0 @@
version: "3"
services:
web:
ports:
- "5000:5000"
depends_on:
- redis
- web
redis:
image: redis:${TAG}
ports:
- "6379"
web:
image: tuna/docker-counter23

View File

@ -1,18 +0,0 @@
version: "3"
services:
web:
image: tuna/docker-counter23
ports:
- "5000:5000"
links:
- redis
deploy:
replicas: 5
redis:
image: redis:3.0
ports:
- "6379"
deploy:
replicas: 5

View File

@ -1,232 +0,0 @@
#!/bin/bash
# Copyright 2017 The Kubernetes Authors All rights reserved.
#
# 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.
function convert::print_msg () {
echo ""
tput setaf 4
tput bold
echo -e "$@"
tput sgr0
echo ""
}
function install_oc_client () {
# TODO: Confirm that this is valid for GitHub Actions.
# Valid only for Travis
convert::print_msg "Installing oc client binary ..."
sudo sed -i 's:DOCKER_OPTS=":DOCKER_OPTS="--insecure-registry 172.30.0.0/16 :g' /etc/default/docker
sudo mv /bin/findmnt /bin/findmnt.backup
sudo /etc/init.d/docker restart
# FIXME
wget https://github.com/openshift/origin/releases/download/v1.5.0/openshift-origin-client-tools-v1.5.0-031cbe4-linux-64bit.tar.gz -O /tmp/oc.tar.gz 2> /dev/null > /dev/null
mkdir /tmp/ocdir && cd /tmp/ocdir && tar -xvvf /tmp/oc.tar.gz > /dev/null
sudo mv /tmp/ocdir/*/oc /usr/bin/
}
function convert::oc_cluster_up () {
oc cluster up; exit_status=$?
if [ $exit_status -ne 0 ]; then
FAIL_MSGS=$FAIL_MSGS"exit status: $exit_status\n";
convert::print_fail "oc cluster up failed.\n"
exit $exit_status
fi
convert::run_cmd "oc login -u system:admin"
}
function convert::oc_registry_login () {
# wait for the registry to become available
local counter=0
while ! curl --fail --silent http://172.30.1.1:5000/healthz; do
counter=$(($counter + 1))
if [ $counter = 48 ]; then
echo "Registry did not become available in time"
break
fi
sleep 5
done
oc serviceaccounts get-token builder \
| docker login --password-stdin -u builder 172.30.1.1:5000
}
function convert::oc_cluster_down () {
convert::run_cmd "oc cluster down"
exit_status=$?
if [ $exit_status -ne 0 ]; then
FAIL_MSGS=$FAIL_MSGS"exit status: $exit_status\n"
exit $exit_status
fi
}
function convert::kompose_up_check () {
# A function to check if the pods are up in 'Running' state
# WARNING: This function has a limitation that it works only for 2 pods.
# TODO: Make this function work for any no. of pods
# Usage: -p for pod name, -r replica count
local retry_up=0
while getopts ":p:r:" opt; do
case $opt in
p ) pod=$OPTARG;;
r ) replica=$OPTARG;;
esac
done
if [ -z $replica ]; then
replica_1=1
replica_2=1
else
replica_1=$replica
replica_2=$replica
fi
pod_1=$( echo $pod | awk '{ print $1 }')
pod_2=$( echo $pod | awk '{ print $2 }')
query_1='grep ${pod_1} | grep -v deploy'
query_2='grep ${pod_2} | grep -v deploy'
query_1_status='Running'
query_2_status='Running'
is_buildconfig=$(oc get builds --no-headers | wc -l)
if [ $is_buildconfig -gt 0 ]; then
query_1='grep ${pod_1} | grep -v deploy | grep -v build'
query_2='grep build | grep -v deploy'
query_2_status='Completed'
replica_2=1
fi
convert::print_msg "Waiting for the pods to come up ..."
# FIXME: Make this generic to cover all cases
while [ $(oc get pods | eval ${query_1} | awk '{ print $3 }' | \
grep ${query_1_status} | wc -l) -ne $replica_1 ] ||
[ $(oc get pods | eval ${query_2} | awk '{ print $3 }' | \
grep ${query_2_status} | wc -l) -ne $replica_2 ]; do
if [ $retry_up -lt 240 ]; then
retry_up=$(($retry_up + 1))
sleep 1
else
convert::print_fail "kompose up has failed to bring the pods up\n"
oc get pods
exit 1
fi
done
# Wait
sleep 2
# If pods are up, print a success message
if [ $(oc get pods | eval ${query_1} | awk '{ print $3 }' | \
grep ${query_1_status} | wc -l) -eq $replica_1 ] &&
[ $(oc get pods | eval ${query_2} | awk '{ print $3 }' | \
grep ${query_2_status} | wc -l) -eq $replica_2 ]; then
oc get pods
convert::print_pass "All pods are Running now. kompose up is successful.\n"
fi
}
function convert::kompose_down_check () {
# Checks if the pods have been successfully deleted
# with 'kompose down'.
# Usage: convert::kompose_down_check <num_of_pods>
local retry_down=0
local pod_count=$1
convert::print_msg "Waiting for the pods to go down ..."
while [ $(oc get pods | wc -l ) != 0 ] &&
[ $(oc get pods | grep -v deploy | grep 'Terminating' | wc -l ) != $pod_count ]; do
if [ $retry_down -lt 120 ]; then
retry_down=$(($retry_down + 1))
sleep 1
else
convert::print_fail "kompose down has failed\n"
oc get pods
exit 1
fi
done
# Wait
sleep 2
# Print a message if all the pods are down
if [ $(oc get pods | wc -l ) == 0 ] ||
[ $(oc get pods | grep -v deploy | grep 'Terminating' | wc -l ) == $pod_count ]; then
convert::print_pass "All pods are down now. kompose down successful.\n"
oc get pods
fi
}
function convert::oc_cleanup () {
oc delete bc,rc,rs,svc,is,dc,deploy,ds,builds,route --all > /dev/null
}
function convert::oc_check_route () {
local route_key=$1
if [ $route_key == 'true' ]; then
route_key='nip.io'
fi
if [ $(oc get route | grep ${route_key} | wc -l ) -gt 0 ]; then
convert::print_pass "Route *.${route_key} has been exposed\n"
else
convert::print_fail "Route *.${route_key} has not been exposed\n"
fi
echo ""
oc get route
}
function convert::kompose_up () {
# Function for running 'kompose up'
# Usage: convert::kompose_up <docker_compose_file>
local compose_file=$1
convert::print_msg "Running kompose up ..."
./kompose up --provider=openshift --volumes emptyDir -f $compose_file
exit_status=$?
if [ $exit_status -ne 0 ]; then
convert::print_fail "kompose up has failed\n"
exit 1
fi
}
function convert::kompose_down () {
# Function for running 'kompose down'
# Usage: convert::kompose_down <docker_compose_file>
local compose_file=$1
convert::print_msg "Running kompose down ..."
./kompose --provider=openshift -f $compose_file down
exit_status=$?
if [ $exit_status -ne 0 ]; then
convert::print_fail "kompose down has failed\n"
exit 1
fi
}

View File

@ -1,57 +0,0 @@
#!/bin/bash
# Copyright 2017 The Kubernetes 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.
# Test case for kompose up/down with etherpad
KOMPOSE_ROOT=$(readlink -f $(dirname "${BASH_SOURCE}")/../../..)
source $KOMPOSE_ROOT/kompose/script/test/cmd/lib.sh
source $KOMPOSE_ROOT/script/test_in_openshift/lib.sh
openshift_exit_status=0
convert::start_test "Functional tests on OpenShift"
if [[ -n "${CI}" ]]; then
install_oc_client
fi
if [ -z $(whereis oc | awk '{ print $2 }') ]; then
convert::print_fail "Please install the oc binary to run tests\n"
exit 1
fi
convert::oc_cluster_up
convert::oc_registry_login
if [ -z $1 ]; then
for test_case in $KOMPOSE_ROOT/script/test_in_openshift/tests/*.sh; do
$test_case; exit_status=$?
if [ $exit_status -ne 0 ]; then
openshift_exit_status=1
fi
convert::oc_cleanup
done
else
# Run individual test scripts
test_to_run=$1
$test_to_run; exit_status=$?
if [ $exit_status -ne 0 ]; then
openshift_exit_status=1
fi
fi
convert::oc_cluster_down
exit $openshift_exit_status

View File

@ -1,30 +0,0 @@
#!/bin/bash
# Copyright 2017 The Kubernetes 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.
KOMPOSE_ROOT=$(readlink -f $(dirname "${BASH_SOURCE}")/../../..)
source $KOMPOSE_ROOT/script/test/cmd/lib.sh
source $KOMPOSE_ROOT/script/test_in_openshift/lib.sh
convert::print_msg "Running tests for build+push"
docker_compose_file="${KOMPOSE_ROOT}/script/test_in_openshift/compose-files/buildconfig/docker-compose-build-image.yml"
convert::kompose_up $docker_compose_file
convert::kompose_down $docker_compose_file
docker_compose_file="${KOMPOSE_ROOT}/script/test_in_openshift/compose-files/buildconfig-relative-dirs/docker/docker-compose-build-image.yml"
convert::kompose_up $docker_compose_file
convert::kompose_down $docker_compose_file

View File

@ -1,35 +0,0 @@
#!/bin/bash
# Copyright 2017 The Kubernetes 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.
KOMPOSE_ROOT=$(readlink -f $(dirname "${BASH_SOURCE}")/../../..)
source $KOMPOSE_ROOT/script/test/cmd/lib.sh
source $KOMPOSE_ROOT/script/test_in_openshift/lib.sh
convert::print_msg "Running tests with entrypoint/command option"
docker_compose_file="${KOMPOSE_ROOT}/script/test_in_openshift/compose-files/docker-compose-command.yml"
# Run kompose up
convert::kompose_up $docker_compose_file
convert::kompose_up_check -p 'base1 base2'
# Run Kompose down
convert::kompose_down $docker_compose_file
convert::kompose_down_check 2

View File

@ -1,39 +0,0 @@
#!/bin/bash
# Copyright 2017 The Kubernetes 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.
# Test case for kompose up/down with etherpad
KOMPOSE_ROOT=$(readlink -f $(dirname "${BASH_SOURCE}")/../../..)
source $KOMPOSE_ROOT/script/test/cmd/lib.sh
source $KOMPOSE_ROOT/script/test_in_openshift/lib.sh
convert::print_msg "Testing kompose up/down with etherpad docker-compose file"
# Env variables for etherpad
export $(cat ${KOMPOSE_ROOT}/script/test/fixtures/etherpad/envs)
docker_compose_file="${KOMPOSE_ROOT}/script/test/fixtures/etherpad/docker-compose.yml"
# Run kompose up
convert::kompose_up $docker_compose_file
# Check if the pods are up
convert::kompose_up_check -p "etherpad mariadb"
# Run Kompose down
convert::kompose_down $docker_compose_file
convert::kompose_down_check 2

View File

@ -1,40 +0,0 @@
#!/bin/bash
# Copyright 2017 The Kubernetes 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.
# Test case for checking replicas option with kompose
KOMPOSE_ROOT=$(readlink -f $(dirname "${BASH_SOURCE}")/../../..)
source $KOMPOSE_ROOT/script/test/cmd/lib.sh
source $KOMPOSE_ROOT/script/test_in_openshift/lib.sh
convert::print_msg "Running tests for replica option"
# Run kompose up
./kompose up --provider=openshift --volumes emptyDir --replicas 2 -f ${KOMPOSE_ROOT}/examples/docker-compose-counter.yaml; exit_status=$?
if [ $exit_status -ne 0 ]; then
convert::print_fail "kompose up has failed"
exit 1
fi
# Check if redis and web pods are up. Replica count: 2
convert::kompose_up_check -p "redis web" -r 2
# Run Kompose down
convert::kompose_down ${KOMPOSE_ROOT}/examples/docker-compose-counter.yaml
convert::kompose_down_check 4

View File

@ -1,50 +0,0 @@
#!/bin/bash
# Copyright 2017 The Kubernetes 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.
KOMPOSE_ROOT=$(readlink -f $(dirname "${BASH_SOURCE}")/../../..)
source $KOMPOSE_ROOT/script/test/cmd/lib.sh
source $KOMPOSE_ROOT/script/test_in_openshift/lib.sh
convert::print_msg "Testing restart: 'always'"
docker_compose_file="${KOMPOSE_ROOT}/script/test_in_openshift/compose-files/docker-compose-restart-always.yml"
# Run kompose up
convert::kompose_up $docker_compose_file
# Check if the pods are up
retry_up=0
while [ $(oc get pods --no-headers | wc -l ) -ne 1 ] ||
[ $(oc get pods --no-headers | awk '{ print $4 }') -eq 0 ]; do
if [ $retry_up -lt 240 ]; then
retry_up=$(($retry_up + 1))
sleep 1
else
exit 1
fi
done
if [ $(oc get pods --no-headers | awk '{ print $4 }') > 0 ]; then
convert::print_pass "restart option set to 'always' is working as expected\n"
oc get pods
fi
# Run Kompose down
convert::kompose_down $docker_compose_file
convert::kompose_down_check 1

View File

@ -1,40 +0,0 @@
#!/bin/bash
# Copyright 2017 The Kubernetes 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.
# Test case for checking kompose.service.expose label in kompose
KOMPOSE_ROOT=$(readlink -f $(dirname "${BASH_SOURCE}")/../../..)
source $KOMPOSE_ROOT/script/test/cmd/lib.sh
source $KOMPOSE_ROOT/script/test_in_openshift/lib.sh
docker_compose_file="${KOMPOSE_ROOT}/script/test/fixtures/expose-service/compose-files/docker-compose-expose-hostname.yml"
convert::print_msg "Testing kompose-specific label:kompose.service.expose=hostname "
# Run kompose up
convert::kompose_up $docker_compose_file
# Check if the pods are up
convert::kompose_up_check -p "web redis"
# Check if the service has been exposed
convert::oc_check_route "batman.example.com"
# Run Kompose down
convert::kompose_down $docker_compose_file
# Check if the pods have been terminated
convert::kompose_down_check 2

View File

@ -1,40 +0,0 @@
#!/bin/bash
# Copyright 2017 The Kubernetes 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.
# Test case for checking routes construct with kompose
KOMPOSE_ROOT=$(readlink -f $(dirname "${BASH_SOURCE}")/../../..)
source $KOMPOSE_ROOT/script/test/cmd/lib.sh
source $KOMPOSE_ROOT/script/test_in_openshift/lib.sh
docker_compose_file="${KOMPOSE_ROOT}/script/test/fixtures/expose-service/compose-files/docker-compose-expose-true.yml"
convert::print_msg "Running tests for kompose-specific labels: 'kompose.service.expose:True'"
# Run kompose up
convert::kompose_up $docker_compose_file
# Check if the pods are up
convert::kompose_up_check -p "web redis"
# Check if the service has been exposed
convert::oc_check_route "true"
# Run Kompose down
convert::kompose_down $docker_compose_file
# Check if the pods have been term
convert::kompose_down_check 2

View File

@ -1,44 +0,0 @@
#!/bin/bash
# Copyright 2017 The Kubernetes 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.
KOMPOSE_ROOT=$(readlink -f $(dirname "${BASH_SOURCE}")/../../..)
source $KOMPOSE_ROOT/script/test/cmd/lib.sh
source $KOMPOSE_ROOT/script/test_in_openshift/lib.sh
convert::print_msg "Running tests for environment variable for docker compose v2"
docker_compose_file="${KOMPOSE_ROOT}/script/test_in_openshift/compose-files/v2-env.yaml"
# env variable
export TAG=3.0
# Run kompose up
convert::kompose_up $docker_compose_file
# Check if redis and web pods are up. Replica count: 2
convert::kompose_up_check -p "redis web"
if [ $(oc describe is/redis | grep "redis:3.0" | wc -l ) -eq 1 ]; then
convert::print_pass "Successfully set the environment variable"
else
convert::print_fail "Setting the environment variable has failed."
fi
# Run Kompose down
convert::kompose_down $docker_compose_file
convert::kompose_down_check 2

View File

@ -1,38 +0,0 @@
#!/bin/bash
# Copyright 2017 The Kubernetes 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.
KOMPOSE_ROOT=$(readlink -f $(dirname "${BASH_SOURCE}")/../../..)
source $KOMPOSE_ROOT/script/test/cmd/lib.sh
source $KOMPOSE_ROOT/script/test_in_openshift/lib.sh
convert::print_msg "Running tests for docker compose v3"
docker_compose_file="${KOMPOSE_ROOT}/script/test/fixtures/v3/docker-compose-deploy-mode.yaml"
# Run kompose up
convert::kompose_up $docker_compose_file
# Check if redis is up
# TODO: Fix Limitation of kompose_up_check :- kompose_up_check assumes that there are \
# 2 pods generated in every test. Here we are passing the same pod name twice \
# thereby fooling the function
convert::kompose_up_check -p "foo foo"
# Run Kompose down
convert::kompose_down $docker_compose_file
convert::kompose_down_check 1

View File

@ -1,44 +0,0 @@
#!/bin/bash
# Copyright 2017 The Kubernetes 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.
KOMPOSE_ROOT=$(readlink -f $(dirname "${BASH_SOURCE}")/../../..)
source $KOMPOSE_ROOT/script/test/cmd/lib.sh
source $KOMPOSE_ROOT/script/test_in_openshift/lib.sh
convert::print_msg "Running tests for environment variable for docker compose v3"
docker_compose_file="${KOMPOSE_ROOT}/script/test_in_openshift/compose-files/v3-env.yaml"
# env variable
export TAG=3.0
# Run kompose up
convert::kompose_up $docker_compose_file
# Check if redis and web pods are up. Replica count: 2
convert::kompose_up_check -p "redis web"
if [ $(oc describe is/redis | grep "redis:3.0" | wc -l ) -eq 1 ]; then
convert::print_pass "Successfully set the environment variable"
else
convert::print_fail "Setting the environment variable has failed."
fi
# Run Kompose down
convert::kompose_down $docker_compose_file
convert::kompose_down_check 2

View File

@ -1,35 +0,0 @@
#!/bin/bash
# Copyright 2017 The Kubernetes 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.
KOMPOSE_ROOT=$(readlink -f $(dirname "${BASH_SOURCE}")/../../..)
source $KOMPOSE_ROOT/script/test/cmd/lib.sh
source $KOMPOSE_ROOT/script/test_in_openshift/lib.sh
convert::print_msg "Running tests for docker compose v3 replica option"
docker_compose_file="${KOMPOSE_ROOT}/script/test_in_openshift/compose-files/v3-redis-replica.yaml"
# Run kompose up
convert::kompose_up $docker_compose_file
# Check if redis and web pods are up. Replica count: 2
convert::kompose_up_check -p "redis web" -r 5
# Run Kompose down
convert::kompose_down $docker_compose_file
convert::kompose_down_check 2

View File

@ -1,35 +0,0 @@
#!/bin/bash
# Copyright 2017 The Kubernetes 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.
KOMPOSE_ROOT=$(readlink -f $(dirname "${BASH_SOURCE}")/../../..)
source $KOMPOSE_ROOT/script/test/cmd/lib.sh
source $KOMPOSE_ROOT/script/test_in_openshift/lib.sh
convert::print_msg "Running tests for docker compose v3"
docker_compose_file="${KOMPOSE_ROOT}/script/test_in_openshift/compose-files/v3-docker-compose.yaml"
# Run kompose up
convert::kompose_up $docker_compose_file
# Check if redis and web pods are up. Replica count: 2
convert::kompose_up_check -p "redis web"
# Run Kompose down
convert::kompose_down $docker_compose_file
convert::kompose_down_check 2

View File

@ -1,50 +0,0 @@
#!/bin/bash
# Copyright 2017 The Kubernetes 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.
KOMPOSE_ROOT=$(readlink -f $(dirname "${BASH_SOURCE}")/../../..)
source $KOMPOSE_ROOT/script/test/cmd/lib.sh
source $KOMPOSE_ROOT/script/test_in_openshift/lib.sh
convert::print_msg "Testing restart: 'always' in v3 docker-compose file"
docker_compose_file="${KOMPOSE_ROOT}/script/test_in_openshift/compose-files/v3-docker-compose-restart-always.yml"
# Run kompose up
convert::kompose_up $docker_compose_file
# Check if the pods are up
retry_up=0
while [ $(oc get pods --no-headers | wc -l ) -ne 1 ] ||
[ $(oc get pods --no-headers | awk '{ print $4 }') -eq 0 ]; do
if [ $retry_up -lt 240 ]; then
retry_up=$(($retry_up + 1))
sleep 1
else
exit 1
fi
done
if [ $(oc get pods --no-headers | awk '{ print $4 }') > 0 ]; then
convert::print_pass "restart option set to 'always' is working as expected\n"
oc get pods
fi
# Run Kompose down
convert::kompose_down $docker_compose_file
convert::kompose_down_check 1

View File

@ -1,111 +0,0 @@
#!/bin/bash
RED='\033[0;31m'
NOCOLOR='\033[0m'
start_k8s() {
# Note: takes some time for the http server to pop up :)
# MINIMUM 15 seconds
echo "
##########
STARTING KUBERNETES
##########
"
if [ ! -f /usr/bin/kubectl ] && [ ! -f /usr/local/bin/kubectl ]; then
echo "No kubectl bin exists? Please install."
return 1
fi
if [ ! -f /usr/bin/kind ] && [ ! -f /usr/local/bin/kind ]; then
echo "No kind bin exists? Please install."
return 1
fi
kind create cluster --name kompose-test
kubectl cluster-info --context kind-kompose-test
# Set the appropriate .kube/config configuration
kubectl config set-cluster kind-kompose-test
kubectl config use-context kind-kompose-test
kubectl proxy --port=6443 &
# Debug info:
# cat ~/.kube/config
# Delay due to CI being a bit too slow when first starting k8s
sleep 5
}
stop_k8s() {
echo "
##########
STOPPING KUBERNETES
##########
"
kind delete cluster --name kompose-test
}
wait_k8s() {
echo "Waiting for k8s po/svc/rc to finish terminating..."
kubectl get po,svc,rc
sleep 3 # give kubectl chance to catch up to api call
while [ 1 ]
do
k8s=`kubectl get po,svc,rc | grep Terminating`
if [[ $k8s == "" ]]
then
echo "k8s po/svc/rc terminated!"
break
else
echo "..."
fi
sleep 1
done
}
test_k8s() {
for f in examples/*.yaml
do
echo -e "\n${RED}kompose up --server http://127.0.0.1:6443 -f $f ${NC}\n"
./kompose up --server http://127.0.0.1:6443 -f $f
sleep 2 # Sleep for k8s to catch up to deployment
echo -e "\n${RED}kompose down --server http://127.0.0.1:6443 -f $f ${NC}\n"
./kompose down --server http://127.0.0.1:6443 -f $f
echo -e "\nTesting controller=daemonset key\n"
echo -e "\n${RED}kompose up --server http://127.0.0.1:6443 -f $f --controller=daemonset ${NC}\n"
./kompose up --server http://127.0.0.1:6443 -f $f --controller=daemonset
sleep 2 # Sleep for k8s to catch up to deployment
echo -e "\n${RED}kompose down --server http://127.0.0.1:6443 -f $f --controller=daemonset ${NC}\n"
./kompose down --server http://127.0.0.1:6443 -f $f --controller=daemonset
echo -e "\nTesting controller=replicationcontroller key\n"
echo -e "\n${RED}kompose up --server http://127.0.0.1:6443 -f $f --controller=replicationcontroller ${NC}\n"
./kompose up --server http://127.0.0.1:6443 -f $f --controller=replicationcontroller
sleep 2 # Sleep for k8s to catch up to deployment
echo -e "\n${RED}kompose down --server http://127.0.0.1:6443 -f $f --controller=replicationcontroller ${NC}\n"
./kompose down --server http://127.0.0.1:6443 -f $f --controller=replicationcontroller
done
echo -e "\nTesting stdin to kompose\n"
echo -e "\n${RED}cat examples/docker-compose.yaml | ./kompose up --server http://127.0.0.1:6443 -f -${NC}\n"
cat examples/docker-compose.yaml | ./kompose up --server http://127.0.0.1:6443 -f -
sleep 2 # Sleep for k8s to catch up to deployment
echo -e "\n${RED}cat examples/docker-compose.yaml | ./kompose down --server http://127.0.0.1:6443 -f - ${NC}\n"
cat examples/docker-compose.yaml | ./kompose down --server http://127.0.0.1:6443 -f -
}
if [[ $1 == "start" ]]; then
start_k8s
elif [[ $1 == "stop" ]]; then
stop_k8s
elif [[ $1 == "wait" ]]; then
wait_k8s
elif [[ $1 == "test" ]]; then
test_k8s
else
echo $"Usage: kubernetes.sh {answers|start|stop|wait}"
fi

View File

@ -1,44 +0,0 @@
#!/bin/bash
# These tests will bring up a single-node Kubernetes cluster and test against examples
# WARNING: This will actively create Docker containers on your machine as well as remove them
# do not run this on a production cluster / machine.
# Check requirements!
if ! hash go 2>/dev/null; then
echo "ERROR: go required"
exit 1
fi
if ! hash docker 2>/dev/null; then
echo "ERROR: docker required"
exit 1
fi
if ! hash kubectl 2>/dev/null; then
echo "ERROR: kubectl required"
exit 1
fi
if ! hash kind 2>/dev/null; then
echo "ERROR: kind required"
exit 1
fi
# First off, we have to compile the latest binary
# We *assume* that the binary has already been built
# make bin
#####################
# KUBERNETES TESTS ##
#####################
# Now we can start our Kubernetes cluster!
./script/test_k8s/kubernetes.sh start
# And we're off! Let's test those example files
./script/test_k8s/kubernetes.sh test
# Stop our Kubernetes cluster
./script/test_k8s/kubernetes.sh stop

File diff suppressed because it is too large Load Diff