Skip to content

Commit

Permalink
Merge pull request #83 from cben/vcr-for-kubernetes-too
Browse files Browse the repository at this point in the history
VCR updates for tests in kubernetes repo
(cherry picked from commit 542fa53)

https://bugzilla.redhat.com/show_bug.cgi?id=1559544
  • Loading branch information
Mooli Tayer authored and simaishi committed Mar 22, 2018
1 parent 7b7dfea commit 75da912
Show file tree
Hide file tree
Showing 7 changed files with 1,926 additions and 1,854 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -118,14 +118,14 @@ def full_refresh_test
# using strings instead of actual model classes for compact rspec diffs
{
'ContainerProject' => 10,
'ContainerImage' => 43,
'ContainerRoute' => 4,
'ContainerImage' => 39,
'ContainerRoute' => 3,
'ContainerTemplate' => 20,
'ContainerTemplateParameter' => 210,
'ContainerReplicator' => 8,
'ContainerReplicator' => 5,
'ContainerBuild' => 3,
'ContainerBuildPod' => 3,
'CustomAttribute' => 622,
'CustomAttribute' => 596,
}
end

Expand Down

Large diffs are not rendered by default.

Large diffs are not rendered by default.

Large diffs are not rendered by default.

Large diffs are not rendered by default.

Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,13 @@ echo '===== Ensure API server ====='
if [ -z "$OPENSHIFT_MASTER_HOST" ]; then
echo "OPENSHIFT_MASTER_HOST unset, trying minishift"
if which minishift && minishift status | grep -i 'openshift:.*running'; then
export OPENSHIFT_MASTER_HOST="$(minishift ip)"
OPENSHIFT_MASTER_HOST="$(minishift ip)"
export OPENSHIFT_MASTER_HOST
eval $(minishift oc-env --shell bash) # Ensure oc in PATH
oc login -u system:admin # With minishift, we know we can just do this

echo "-- Deleting minishift PVs for a cleaner inventory --"
oc delete --ignore-not-found pv $(printf "pv%s " $(seq -w 0001 0100))
else
echo 'Either set $OPENSHIFT_MASTER_HOST and perform `oc login` with cluster-admin powers,'
echo 'or have minishift in $PATH and already started.'
Expand All @@ -19,7 +23,8 @@ if [ -z "$OPENSHIFT_MASTER_HOST" ]; then
fi

if [ -z "$OPENSHIFT_MANAGEMENT_ADMIN_TOKEN" ]; then
export OPENSHIFT_MANAGEMENT_ADMIN_TOKEN="$(oc sa get-token -n management-infra management-admin)"
OPENSHIFT_MANAGEMENT_ADMIN_TOKEN="$(oc sa get-token -n management-infra management-admin)"
export OPENSHIFT_MANAGEMENT_ADMIN_TOKEN
fi

cd "$(git rev-parse --show-toplevel)" # repo root
Expand All @@ -29,6 +34,7 @@ SPEC=./spec/models/manageiq/providers/openshift/container_manager/refresher_spec
echo; echo "===== Clean slate, create objects ====="

oc delete --ignore-not-found project my-project-{0,1,2}
oc delete --ignore-not-found persistentvolume my-persistentvolume-{0,1,2}

while oc get --show-all projects | grep my-project; do
echo "... waiting for projects to disappear ..."
Expand Down Expand Up @@ -63,8 +69,17 @@ describe_vcr () {
echo "== oc get all --show-all --all-namespaces -o wide --show-labels =="
oc get all --show-all --all-namespaces -o wide --show-labels
echo
echo "== oc get images =="
oc get images
echo "== oc get resourceQuotas --all-namespaces --show-kind --show-labels =="
oc get resourceQuotas --all-namespaces --show-kind --show-labels
echo
echo "== oc get persistentvolumes --show-kind --show-labels =="
oc get persistentVolumes --show-kind --show-labels
echo
echo "== oc get persistentvolumeclaims --all-namespaces --show-kind --show-labels =="
oc get persistentVolumeClaims --all-namespaces --show-kind --show-labels
echo
echo "== oc get images --show-kind --sort-by=.dockerImageReference =="
oc get images --show-kind --sort-by=.dockerImageReference
}

# Deleting VCR file allows using :new_episodes so multiple specs calling refresh
Expand All @@ -82,8 +97,11 @@ oc delete pod my-pod-1
oc delete service my-service-1
oc delete route my-route-1
oc delete resourceQuota my-resource-quota-1
oc delete resourceQuota my-resource-quota-scopes1-1
oc delete resourceQuota my-resource-quota-scopes2-1
oc delete limitRange my-limit-range-1
oc delete persistentVolumeClaim my-persistentvolumeclaim-1
oc delete persistentVolumeClaim my-persistentvolumeclaim-pending-1
oc delete template my-template-1
oc delete buildconfig my-build-config-1 # also deletes its build(s)
oc delete rc my-replicationcontroller-1
Expand All @@ -96,12 +114,25 @@ oc label route my-route-2 key-route-label-
oc patch --type=merge template my-template-2 --patch='{"parameters": []}'
oc delete pod my-pod-2

# Using JSON Patch https://erosb.github.io/post/json-patch-vs-merge-patch/
# Drop pods.
oc patch quota my-resource-quota-scopes1-2 --type json --patch '[{op: remove, path: /spec/hard/pods}]'
# Swap order of scopes (this is reflected in openshift response),
# change requests.cpu from 5.7 to 5.701,
# reformulate same requests.memory value from "10240Mi" to "10Gi" (this is actually ignored as no-op by openshift)
oc patch quota my-resource-quota-scopes2-2 --type json --patch '[{op: replace, path: /spec/scopes, value: [NotBestEffort, Terminating]}, {op: replace, path: /spec/hard/requests.cpu, value: "5.701"}, {op: replace, path: /spec/hard/requests.memory, value: "10Gi"}]'


while oc get --show-all projects | grep my-project-0; do
echo "... waiting for my-project-0 to disappear ..."
sleep 3
done

while oc get pods --show-all --all-namespaces | grep my-pod; do
echo "... waiting for pods to disappear ..."
sleep 3
done

echo; echo "===== Record second VCR ====="

rm -v "$VCR_DIR"/refresher_after_deletions.{yml,txt} || true
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,10 @@ kind: Template
metadata:
name: template-test
annotations:
description: "Description"
iconClass: "Icon"
tags: "database,nosql"
objects:
description: "Description"
iconClass: "Icon"
tags: "database,nosql"
objects:
- apiVersion: v1
kind: Pod
metadata:
Expand All @@ -28,6 +28,10 @@ objects:
user: "username"
role: "admin"
type: "default"
volumes:
- name: my-pvc-pod-volume-${INDEX}
persistentVolumeClaim:
claimName: my-persistentvolumeclaim-${INDEX}
- apiVersion: v1
kind: Route
metadata:
Expand All @@ -43,20 +47,20 @@ objects:
metadata:
name: my-service-${INDEX}
spec:
selector:
docker-registry: default
selector:
docker-registry: default
ports:
- nodePort: 0
port: 5000
port: 5000
protocol: TCP
targetPort: 5000
- apiVersion: v1
kind: "BuildConfig"
metadata:
name: my-build-config-${INDEX}
spec:
runPolicy: "Serial"
triggers:
runPolicy: "Serial"
triggers:
-
type: "GitHub"
github:
Expand All @@ -66,19 +70,19 @@ objects:
secret: "secret101"
-
type: "ImageChange"
source:
source:
git:
uri: "https://github.com/openshift/ruby-hello-world"
strategy:
strategy:
sourceStrategy:
from:
kind: "DockerImage"
name: "ruby-20-centos7:latest"
output:
output:
to:
kind: "ImageStreamTag"
name: "origin-ruby-sample:latest"
postCommit:
postCommit:
script: "bundle exec rake test"
- apiVersion: v1
kind: "ImageStream"
Expand All @@ -98,24 +102,24 @@ objects:
limits:
- type: "Pod"
max:
cpu: "2"
memory: "1Gi"
cpu: "2"
memory: "1Gi"
min:
cpu: "200m"
memory: "6Mi"
cpu: "200m"
memory: "6Mi"
- type: "Container"
max:
cpu: "2"
memory: "1Gi"
cpu: "2"
memory: "1Gi"
min:
cpu: "100m"
memory: "4Mi"
cpu: "100m"
memory: "4Mi"
default:
cpu: "300m"
memory: "200Mi"
cpu: "300m"
memory: "200Mi"
defaultRequest:
cpu: "200m"
memory: "100Mi"
cpu: "200m"
memory: "100Mi"
maxLimitRequestRatio:
cpu: "10"
- apiVersion: v1
Expand Down Expand Up @@ -149,7 +153,7 @@ objects:
- apiVersion: v1
kind: PersistentVolumeClaim
metadata:
name: my-persistentvolumeclaim
name: my-persistentvolumeclaim-in-my-template-${INDEX}
spec:
accessModes:
- ReadWriteOnce
Expand All @@ -158,7 +162,21 @@ objects:
storage: 8Gi
parameters:
- name: MYPARAM
value: my-value
value: my-value
- apiVersion: v1
kind: PersistentVolume
metadata:
name: my-persistentvolume-${INDEX}
labels:
my-pv-label: my-pv-${INDEX}
spec:
storageClassName: manual
capacity:
storage: 10Mi
accessModes:
- ReadWriteOnce
hostPath:
path: "/tmp/my-persistentvolume-${INDEX}"
- apiVersion: v1
kind: PersistentVolumeClaim
metadata:
Expand All @@ -168,7 +186,22 @@ objects:
- ReadWriteOnce
resources:
requests:
storage: 8Gi
storage: 8Mi
selector:
matchLabels:
my-pv-label: my-pv-${INDEX}
storageClassName: manual
- apiVersion: v1
kind: PersistentVolumeClaim
metadata:
name: my-persistentvolumeclaim-pending-${INDEX}
spec:
accessModes:
- ReadWriteOnce
resources:
requests:
storage: 8Mi
storageClassName: no-pv-will-match-this-class
- apiVersion: v1
kind: ResourceQuota
metadata:
Expand All @@ -189,7 +222,7 @@ objects:
- NotTerminating
hard:
pods: "6"
requests.cpu: "10"
requests.cpu: "10.3"
- apiVersion: v1
kind: ResourceQuota
metadata:
Expand All @@ -200,7 +233,8 @@ objects:
- NotBestEffort
hard:
pods: "3"
requests.cpu: "5"
requests.cpu: "5.7"
requests.memory: "10240Mi"
parameters:
- name: INDEX
value: "0"

0 comments on commit 75da912

Please sign in to comment.