Skip to content

Commit

Permalink
update tests for v2 (#985)
Browse files Browse the repository at this point in the history
Signed-off-by: Ahmed ElSayed <ahmels@microsoft.com>
  • Loading branch information
ahmelsayed committed Aug 11, 2020
1 parent bcc7526 commit 3917ec4
Show file tree
Hide file tree
Showing 7 changed files with 32 additions and 39 deletions.
6 changes: 3 additions & 3 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ GIT_VERSION = $(shell git describe --always --abbrev=7)
GIT_COMMIT = $(shell git rev-list -1 HEAD)
DATE = $(shell date -u +"%Y.%m.%d.%H.%M.%S")

TEST_CLUSTER_NAME ?= keda-nightly-run
TEST_CLUSTER_NAME ?= keda-nightly-run-2

##################################################
# All #
Expand Down Expand Up @@ -117,7 +117,7 @@ generate-api:
$(GO_BUILD_VARS) operator-sdk generate crds --crd-version=v1beta1
# withTriggers and withPods are only used for duck typing so we only need the deepcopy methods
# However operator-sdk generate doesn't appear to have an option for that
# until this issue is fixed: https://github.com/kubernetes-sigs/controller-tools/issues/398
# until this issue is fixed: https://github.com/kubernetes-sigs/controller-tools/issues/398
rm deploy/crds/keda.sh_withtriggers_crd.yaml
rm deploy/crds/keda.sh_withpods_crd.yaml

Expand All @@ -134,7 +134,7 @@ pkg/scalers/liiklus/mocks/mock_liiklus.go: pkg/scalers/liiklus/LiiklusService.pb
verify-clientset:
$(GO_BUILD_VARS) go mod vendor
./hack/verify-codegen.sh

.PHONY: generate-clientset
generate-clientset:
$(GO_BUILD_VARS) go mod vendor
Expand Down
3 changes: 1 addition & 2 deletions tests/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,7 @@
"ts-node/register"
]
},
"scripts": {
},
"scripts": {},
"dependencies": {
"@kubernetes/client-node": "^0.10.3",
"@types/async": "^3.0.3",
Expand Down
4 changes: 2 additions & 2 deletions tests/scalers/azure-blob.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -31,12 +31,12 @@ test.serial('Deployment should have 0 replicas on start', t => {
t.is(replicaCount, '0', 'replica count should start out as 0')
})

test.serial.cb('Deployment should scale to 2 with 2000 blobs on the blob container then back to 0', t => {
test.serial.cb('Deployment should scale to 2 with 150 blobs on the blob container then back to 0', t => {
// add 2000 files
const blobSvc = azure.createBlobService(connectionString)
blobSvc.createContainerIfNotExists('container-name', err => {
t.falsy(err, 'unable to create blob')
async.mapLimit(Array(2000).keys(), 500, (n, cb) => blobSvc.createBlockBlobFromText('container-name',`blobsubpath/blob-name-${n}`,'test text', cb), () => {
async.mapLimit(Array(150).keys(), 50, (n, cb) => blobSvc.createBlockBlobFromText('container-name',`blobsubpath/blob-name-${n}`,'test text', cb), () => {
let replicaCount = '0'
for (let i = 0; i < 40 && replicaCount !== '2'; i++) {
replicaCount = sh.exec(`kubectl get deployment.apps/test-deployment --namespace ${defaultNamespace} -o jsonpath="{.spec.replicas}"`).stdout
Expand Down
2 changes: 1 addition & 1 deletion tests/scalers/kafka.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -242,6 +242,6 @@ spec:
- type: kafka
metadata:
topic: ${defaultTopic}
brokerList: ${defaultCluster}-kafka-bootstrap.${defaultNamespace}:9092
bootstrapServers: ${defaultCluster}-kafka-bootstrap.${defaultNamespace}:9092
consumerGroup: functions
lagThreshold: '1'`
12 changes: 6 additions & 6 deletions tests/scalers/mysql.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ test.before(t => {
const mysqlPod = sh.exec(`kubectl get po -n ${mySQLNamespace} -o jsonpath='{.items[0].metadata.name}'`).stdout
t.not(mysqlPod, '')
sh.exec( `kubectl exec -n ${mySQLNamespace} ${mysqlPod} -- mysql -u${mySQLUsername} -p${mySQLPassword} -e \"${createTableSQL}\"`)

sh.config.silent = true

sh.exec(`kubectl create namespace ${testNamespace}`)
Expand Down Expand Up @@ -95,7 +95,7 @@ test.serial(`Deployment should scale to 5 (the max) then back to 0`, t => {
sh.exec('sleep 5s')
}
}

t.is('0', replicaCount, 'Replica count should be 0 after 3 minutes')
})

Expand Down Expand Up @@ -160,7 +160,7 @@ type: Opaque
data:
mysql_conn_str: {{MYSQL_CONNECTION_STRING}}
---
apiVersion: keda.k8s.io/v1alpha1
apiVersion: keda.sh/v1alpha1
kind: TriggerAuthentication
metadata:
name: keda-trigger-auth-mysql-secret
Expand All @@ -170,13 +170,13 @@ spec:
name: mysql-secrets
key: mysql_conn_str
---
apiVersion: keda.k8s.io/v1alpha1
apiVersion: keda.sh/v1alpha1
kind: ScaledObject
metadata:
name: mysql-scaledobject
spec:
scaleTargetRef:
deploymentName: worker
name: worker
pollingInterval: 5
cooldownPeriod: 10
minReplicaCount: 0
Expand Down Expand Up @@ -241,7 +241,7 @@ spec:
name: mysql
env:
- name: MYSQL_ROOT_PASSWORD
value: {{MYSQL_ROOT_PASSWORD}}
value: {{MYSQL_ROOT_PASSWORD}}
- name: MYSQL_USER
value: {{MYSQL_USER}}
- name: MYSQL_PASSWORD
Expand Down
42 changes: 18 additions & 24 deletions tests/scalers/redis-lists.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -126,7 +126,7 @@ test.serial('Deployment for redis host and port env vars should have 0 replica o


test.serial(`Deployment using redis host port env vars should max and scale to 5 with ${itemsToWrite} items written to list and back to 0`, t => {

runWriteJob(t, writeJobNameForHostPortRef, listNameForHostPortRef)

let replicaCount = '0'
Expand Down Expand Up @@ -166,7 +166,7 @@ test.serial('Deployment for redis address env var should have 0 replica on start


test.serial(`Deployment using redis address env var should max and scale to 5 with ${itemsToWrite} items written to list and back to 0`, t => {

runWriteJob(t, writeJobNameForAddressRef, listNameForAddressRef)

let replicaCount = '0'
Expand Down Expand Up @@ -206,7 +206,7 @@ test.serial('Deployment for redis host and port in the trigger auth should have


test.serial(`Deployment using redis host port in triggerAuth should max and scale to 5 with ${itemsToWrite} items written to list and back to 0`, t => {

runWriteJob(t, writeJobNameForHostPortInTriggerAuth, listNameForHostPortTriggerAuth)

let replicaCount = '0'
Expand Down Expand Up @@ -357,16 +357,14 @@ spec:
- name: READ_PROCESS_TIME
value: "200"
---
apiVersion: keda.k8s.io/v1alpha1
apiVersion: keda.sh/v1alpha1
kind: ScaledObject
metadata:
name: {{DEPLOYMENT_NAME}}
labels:
deploymentName: {{DEPLOYMENT_NAME}}
spec:
scaleTargetRef:
deploymentName: {{DEPLOYMENT_NAME}}
pollingInterval: 5
name: {{DEPLOYMENT_NAME}}
pollingInterval: 5
cooldownPeriod: 30
minReplicaCount: 0
maxReplicaCount: 5
Expand All @@ -375,7 +373,7 @@ spec:
metadata:
host: REDIS_HOST
port: REDIS_PORT
listName: {{LIST_NAME}}
listName: {{LIST_NAME}}
listLength: "5"
authenticationRef:
name: keda-redis-list-triggerauth
Expand Down Expand Up @@ -413,24 +411,22 @@ spec:
- name: READ_PROCESS_TIME
value: "500"
---
apiVersion: keda.k8s.io/v1alpha1
apiVersion: keda.sh/v1alpha1
kind: ScaledObject
metadata:
name: {{DEPLOYMENT_NAME}}
labels:
deploymentName: {{DEPLOYMENT_NAME}}
spec:
scaleTargetRef:
deploymentName: {{DEPLOYMENT_NAME}}
pollingInterval: 5
name: {{DEPLOYMENT_NAME}}
pollingInterval: 5
cooldownPeriod: 30
minReplicaCount: 0
maxReplicaCount: 5
triggers:
- type: redis
metadata:
address: REDIS_ADDRESS
listName: {{LIST_NAME}}
listName: {{LIST_NAME}}
listLength: "5"
authenticationRef:
name: keda-redis-list-triggerauth
Expand Down Expand Up @@ -469,23 +465,21 @@ spec:
- name: READ_PROCESS_TIME
value: "200"
---
apiVersion: keda.k8s.io/v1alpha1
apiVersion: keda.sh/v1alpha1
kind: ScaledObject
metadata:
name: {{DEPLOYMENT_NAME}}
labels:
deploymentName: {{DEPLOYMENT_NAME}}
spec:
scaleTargetRef:
deploymentName: {{DEPLOYMENT_NAME}}
pollingInterval: 5
name: {{DEPLOYMENT_NAME}}
pollingInterval: 5
cooldownPeriod: 30
minReplicaCount: 0
maxReplicaCount: 5
triggers:
- type: redis
metadata:
listName: {{LIST_NAME}}
listName: {{LIST_NAME}}
listLength: "5"
authenticationRef:
name: keda-redis-list-triggerauth-host-port
Expand All @@ -501,7 +495,7 @@ data:
redisHost: {{REDIS_HOST}}
redisPort: {{REDIS_PORT}}
---
apiVersion: keda.k8s.io/v1alpha1
apiVersion: keda.sh/v1alpha1
kind: TriggerAuthentication
metadata:
name: keda-redis-list-triggerauth-host-port
Expand All @@ -526,7 +520,7 @@ type: Opaque
data:
password: {{REDIS_PASSWORD}}
---
apiVersion: keda.k8s.io/v1alpha1
apiVersion: keda.sh/v1alpha1
kind: TriggerAuthentication
metadata:
name: keda-redis-list-triggerauth
Expand All @@ -549,7 +543,7 @@ spec:
- name: redis
image: {{CONTAINER_IMAGE}}
imagePullPolicy: IfNotPresent
env:
env:
- name: REDIS_ADDRESS
value: {{REDIS_ADDRESS}}
- name: REDIS_PASSWORD
Expand Down
2 changes: 1 addition & 1 deletion tests/setup.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -111,7 +111,7 @@ test.serial('verifyKeda', t => {
const parsedMetrics = parseInt(resultMetrics.stdout, 10)
if (isNaN(parsedOperator) || parsedOperator != 1 || isNaN(parsedMetrics) || parsedMetrics != 1) {
t.log(`Keda is not ready. sleeping`)
sh.exec('sleep 1s')
sh.exec('sleep 5s')
} else if (parsedOperator == 1 && parsedMetrics == 1) {
t.log('keda is running 1 pod for operator and 1 pod for metrics server')
success = true
Expand Down

0 comments on commit 3917ec4

Please sign in to comment.