temp commit

This commit is contained in:
magicsong
2019-08-14 20:45:43 +08:00
parent 90fa38851f
commit 7314064e83
635 changed files with 116500 additions and 494 deletions

13
test/network/Dockerfile Normal file
View File

@@ -0,0 +1,13 @@
FROM golang:1.12
RUN apt-get update && apt-get install -y apt-transport-https jq openssl libltdl7 && \
go get -u github.com/onsi/ginkgo/ginkgo && \
curl -s https://api.github.com/repos/kubernetes-sigs/kustomize/releases/latest |\
grep browser_download |\
grep linux |\
cut -d '"' -f 4 |\
xargs curl -O -L && \
mv kustomize_*_linux_amd64 kustomize && \
chmod u+x kustomize && \
mv kustomize /usr/bin/

43
test/network/Jenkinsfile vendored Normal file
View File

@@ -0,0 +1,43 @@
pipeline {
agent {
docker {
image 'magicsong/nete2e:v0.0.1'
args '-v gomod:/go -v /var/run/docker.sock:/var/run/docker.sock -v /usr/bin/docker:/usr/bin/docker'
}
}
environment {
KUBECONFIG = "/root/.kube/config"
}
stages {
stage('set kubeconfig and secret'){
steps{
sh 'mkdir -p ~/.kube'
sh 'mkdir ./kustomize/network/etcd'
withCredentials([kubeconfigContent(credentialsId: 'net-kubeconfig', variable: 'KUBECONFIG_CONTENT'),
file(credentialsId: 'etcd-ca', variable: 'etcd-ca'),
file(credentialsId: 'etcd-crt', variable: 'etcd-crt'),
file(credentialsId: 'etcd-key', variable: 'etcd-key')]) {
sh 'echo "$KUBECONFIG_CONTENT" > ~/.kube/config'
sh "cp \${etcd-ca} ./kustomize/network/etcd/ca"
sh "cp \${etcd-key} ./kustomize/network/etcd/key"
sh "cp \${etcd-crt} ./kustomize/network/etcd/crt"
}
}
}
stage('testing') {
steps {
sh """
make network-e2e
"""
}
}
stage('cleanup'){
steps{
sh """
rm -rf ./kustomize/network/etcd
"""
}
}
}
}

View File

@@ -1,13 +1,11 @@
approvers:
- magicsong
- zryfish
- zheng1
reviewers:
- magicsong
- zheng1
- zryfish
labels:
- area/controller
- area/testing
- area/networking

View File

@@ -1,18 +1,15 @@
apiVersion: network.kubesphere.io/v1alpha1
kind: NamespaceNetworkPolicy
metadata:
name: allow-tcp-80
name: allow-icmp-only
namespace: production
spec:
selector: color == 'red'
ingress:
- action: Allow
protocol: TCP
protocol: ICMP
source:
selector: color == 'blue'
# destination:
# ports:
# - 80
selector: "all()"
---
apiVersion: apps/v1

67
test/network/test.sh Executable file
View File

@@ -0,0 +1,67 @@
#!/bin/bash
set -e
workspace=`pwd`
tag=`git rev-parse --short HEAD`
IMG=magicsong/ks-network:$tag
DEST=/tmp/manager.yaml
TEST_NS=network-test-$tag
SKIP_BUILD=no
export TEST_NAMESPACE=$TEST_NS
export YAML_PATH=$DEST
export CRD_PATH=$workspace/kustomize/crds
export DEPLOY_NAME=network-manager
while [[ $# -gt 0 ]]
do
key="$1"
case $key in
-s|--skip-build)
SKIP_BUILD=yes
shift # past argument
;;
-n|--NAMESPACE)
TEST_NS=$2
shift # past argument
shift # past value
;;
-t|--tag)
tag="$2"
shift # past argument
shift # past value
;;
--default)
DEFAULT=YES
shift # past argument
;;
*) # unknown option
POSITIONAL+=("$1") # save it in an array for later
shift # past argument
;;
esac
done
if [ $SKIP_BUILD == "no" ]; then
echo "Building binary"
hack/gobuild.sh cmd/ks-network
docker build -f build/ks-network/Dockerfile -t $IMG bin/cmd
echo "Push images"
docker push $IMG
fi
kustomize_dir="./kustomize/network"
if [ "$(uname)" == "Darwin" ]; then
sed -i '' -e 's/namespace: .*/namespace: '"${TEST_NS}"'/' $kustomize_dir/kustomization.yaml
sed -i '' -e 's/namespace: .*/namespace: '"${TEST_NS}"'/' $kustomize_dir/patch_role_binding.yaml
sed -i '' -e 's@image: .*@image: '"${IMG}"'@' $kustomize_dir/patch_image_name.yaml
else
sed -i -e 's/namespace: .*/namespace: '"${TEST_NS}"'/' $kustomize_dir/patch_role_binding.yaml
sed -i -e 's/namespace: .*/namespace: '"${TEST_NS}"'/' $kustomize_dir/kustomization.yaml
sed -i -e 's@image: .*@image: '"${IMG}"'@' $kustomize_dir/patch_image_name.yaml
fi
kustomize build $kustomize_dir -o $DEST
ginkgo -v ./test/e2e/...