Skip to content

Commit

Permalink
test: add initial bdd tests for local secrets
Browse files Browse the repository at this point in the history
Signed-off-by: Cosmin Cojocar <[email protected]>
  • Loading branch information
ccojocar committed Aug 23, 2019
1 parent 2fff7e0 commit a661c90
Show file tree
Hide file tree
Showing 6 changed files with 156 additions and 0 deletions.
1 change: 1 addition & 0 deletions bdd/boot-local/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
## BDD test using JX Boot with Local secrets
66 changes: 66 additions & 0 deletions bdd/boot-local/ci.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,66 @@
#!/usr/bin/env bash
set -e
set -x

export GH_USERNAME="jenkins-x-bot-test"
export GH_EMAIL="[email protected]"
export GH_OWNER="cb-kubecd"

export GH_CREDS_PSW="$(jx step credential -s jenkins-x-bot-test-github)"
export JENKINS_CREDS_PSW="$(jx step credential -s test-jenkins-user)"
export GKE_SA="$(jx step credential -k bdd-credentials.json -s bdd-secret -f sa.json)"

# fix broken `BUILD_NUMBER` env var
export BUILD_NUMBER="$BUILD_ID"

JX_HOME="/tmp/jxhome"
KUBECONFIG="/tmp/jxhome/config"

mkdir -p $JX_HOME

jx --version
jx step git credentials

gcloud auth activate-service-account --key-file $GKE_SA

# lets setup git
git config --global --add user.name JenkinsXBot
git config --global --add user.email [email protected]

echo "running the BDD tests with JX_HOME = $JX_HOME"

# setup jx boot parameters
export JX_VALUE_ADMINUSER_PASSWORD="$JENKINS_CREDS_PSW"
export JX_VALUE_PIPELINEUSER_USERNAME="$GH_USERNAME"
export JX_VALUE_PIPELINEUSER_EMAIL="$GH_EMAIL"
export JX_VALUE_PIPELINEUSER_TOKEN="$GH_CREDS_PSW"
export JX_VALUE_PROW_HMACTOKEN="$GH_CREDS_PSW"

# TODO temporary hack until the batch mode in jx is fixed...
export JX_BATCH_MODE="true"

# prepare the BDD configuration
mkdir bdd-config
cp -rvf * bdd-config
cp bdd/boot-local/jx-requirements.yml bdd-config
cp bdd/boot-local/parameters.yaml bdd-config/env
cd bdd-config

# TODO hack until we fix boot to do this too!
helm init --client-only
helm repo add jenkins-x https://storage.googleapis.com/chartmuseum.jenkins-x.io

jx step bdd \
--use-revision \
--versions-repo https://github.com/jenkins-x/jenkins-x-versions.git \
--config bdd/boot-local/cluster.yaml \
--gopath /tmp \
--git-provider=github \
--git-username $GH_USERNAME \
--git-owner $GH_OWNER \
--git-api-token $GH_CREDS_PSW \
--default-admin-password $JENKINS_CREDS_PSW \
--no-delete-app \
--no-delete-repo \
--tests install \
--tests test-create-spring
18 changes: 18 additions & 0 deletions bdd/boot-local/cluster.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
clusters:
- name: boot-local
args:
- create
- cluster
- gke
- --project-id=jenkins-x-bdd2
- -m=n1-standard-2
- --min-num-nodes=3
- --max-num-nodes=5
- -z=europe-west1-c
- --skip-login
- --skip-installation
commands:
- command: jx
args:
- boot
- -b
37 changes: 37 additions & 0 deletions bdd/boot-local/jx-requirements.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
cluster:
clusterName: bdd-boot
environmentGitOwner: cb-kubecd
project: jenkins-x-bdd2
provider: gke
zone: europe-west1-c
environments:
- key: dev
owner: ""
repository: ""
- key: staging
owner: ""
repository: ""
- key: production
owner: ""
repository: ""
ingress:
domain: ""
externalDNS: false
tls:
email: ""
enabled: false
production: false
kaniko: true
secretStorage: local
storage:
logs:
enabled: false
url: ""
reports:
enabled: false
url: ""
repository:
enabled: false
url: ""
webhook: prow

10 changes: 10 additions & 0 deletions bdd/boot-local/parameters.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
adminUser:
username: admin
enableDocker: false
gitProvider: github
gpg: {}
pipelineUser:
github:
host: github.com
username: jenkins-x-bot-test
email: [email protected]
24 changes: 24 additions & 0 deletions jenkins-x-bdd-local.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
buildPack: none
pipelineConfig:
pipelines:
pullRequest:
pipeline:
options:
containerOptions:
resources:
limits:
cpu: 4
memory: 6144Mi
requests:
cpu: 1
memory: 2048Mi
environment:
- name: GOPROXY
value: http://jenkins-x-athens-proxy:80
agent:
image: gcr.io/jenkinsxio/builder-go-maven:0.1.645
stages:
- name: ci
steps:
- command: bdd/boot-local/ci.sh
name: runci

0 comments on commit a661c90

Please sign in to comment.