@@ -239,7 +239,7 @@ function ci::verify_download_java_function_generic_auth() {
239239}
240240
241241function ci::verify_vpa_java_function() {
242- kubectl wait -l name=function-sample-vpa-function --for=condition=RecommendationProvided --timeout=2m vpa && true
242+ kubectl wait -l name=function-sample-vpa --for=condition=RecommendationProvided --timeout=2m vpa
243243 cpu=` kubectl get vpa function-sample-vpa-function -o jsonpath=' {.status.recommendation.containerRecommendations[0].target.cpu}' `
244244 memory=` kubectl get vpa function-sample-vpa-function -o jsonpath=' {.status.recommendation.containerRecommendations[0].target.memory}' `
245245 resources=' {"limits":{"cpu":"' $cpu ' ","memory":"' $memory ' "},"requests":{"cpu":"' $cpu ' ","memory":"' $memory ' "}}'
@@ -269,6 +269,39 @@ function ci::verify_vpa_java_function() {
269269 ci::verify_exclamation_function " persistent://public/default/input-vpa-java-topic" " persistent://public/default/output-vpa-java-topic" " test-message" " test-message!" 10
270270}
271271
272+ function ci::verify_vpa_with_resource_unit() {
273+ name=$1
274+ kind=$2
275+ baseCpu=200 # cpu value of the resource unit
276+ baseMemory=` echo $(( 800 * 1024 * 1024 )) ` # memory value of the resource unit
277+ vpaName=" $1 -$2 "
278+ kubectl wait -l name=$name --for=condition=RecommendationProvided --timeout=2m vpa
279+ cpu=` kubectl get vpa $vpaName -o jsonpath=' {.status.recommendation.containerRecommendations[0].target.cpu}' `
280+ cpu_value=${cpu% m}
281+
282+ quotient=$(( $cpu_value / $baseCpu ))
283+ remainder=$(( $cpu_value % $baseCpu ))
284+
285+ # If there's any remainder, we need to round up
286+ if [ $remainder -ne 0 ]; then
287+ multiple=$(( $quotient + 1 ))
288+ else
289+ multiple=$quotient
290+ fi
291+ targetCpu=` echo $(( $baseCpu * $multiple )) m`
292+ targetMemory=` echo $(( $baseMemory * $multiple )) `
293+
294+ resources=' {"limits":{"cpu":"' $targetCpu ' ","memory":"' $targetMemory ' "},"requests":{"cpu":"' $targetCpu ' ","memory":"' $targetMemory ' "}}'
295+
296+ realResource=` kubectl get $kind $name -o jsonpath=' {.spec.resources}' `
297+ if [[ " $resources " != " $realResource " ]]; then
298+ echo " vpa tests failed for $kind "
299+ echo " recommend resource is: ${resources} , actual resource is ${realResource} "
300+ exit 1
301+ fi
302+ echo " vpa tests passed"
303+ }
304+
272305function ci::verify_python_function() {
273306 ci::verify_exclamation_function " persistent://public/default/input-python-topic" " persistent://public/default/output-python-topic" " test-message" " test-message!" 10
274307}
@@ -349,7 +382,8 @@ function ci::verify_exclamation_function() {
349382 timesleep=$5
350383 kubectl exec -n ${NAMESPACE} ${CLUSTER} -pulsar-broker-0 -- bin/pulsar-client produce -m " ${inputmessage} " -n 1 " ${inputtopic} "
351384 sleep " $timesleep "
352- MESSAGE=$( kubectl exec -n ${NAMESPACE} ${CLUSTER} -pulsar-broker-0 -- bin/pulsar-client consume -n 1 -s " sub" --subscription-position Earliest " ${outputtopic} " )
385+ sub=` cat /dev/urandom | tr -dc ' a-z' | head -c 8`
386+ MESSAGE=$( kubectl exec -n ${NAMESPACE} ${CLUSTER} -pulsar-broker-0 -- bin/pulsar-client consume -n 1 -s " ${sub} " --subscription-position Earliest " ${outputtopic} " )
353387 echo " $MESSAGE "
354388 if [[ " $MESSAGE " == * " $outputmessage " * ]]; then
355389 return 0
@@ -366,7 +400,8 @@ function ci::verify_exclamation_function_with_auth() {
366400 command=" kubectl exec -n ${NAMESPACE} ${CLUSTER} -pulsar-broker-0 -- sh -c 'bin/pulsar-client --auth-plugin \$ brokerClientAuthenticationPlugin --auth-params \$ brokerClientAuthenticationParameters produce -m \" ${inputmessage} \" -n 1 \" ${inputtopic} \" '"
367401 sh -c " $command "
368402 sleep " $timesleep "
369- consumeCommand=" kubectl exec -n ${NAMESPACE} ${CLUSTER} -pulsar-broker-0 -- sh -c 'bin/pulsar-client --auth-plugin \$ brokerClientAuthenticationPlugin --auth-params \$ brokerClientAuthenticationParameters consume -n 1 -s " sub" --subscription-position Earliest \" ${outputtopic} \" '"
403+ sub=` cat /dev/urandom | tr -dc ' a-z' | head -c 8`
404+ consumeCommand=" kubectl exec -n ${NAMESPACE} ${CLUSTER} -pulsar-broker-0 -- sh -c 'bin/pulsar-client --auth-plugin \$ brokerClientAuthenticationPlugin --auth-params \$ brokerClientAuthenticationParameters consume -n 1 -s \" ${sub} \" --subscription-position Earliest \" ${outputtopic} \" '"
370405 MESSAGE=$( sh -c " $consumeCommand " )
371406 echo " $MESSAGE "
372407 if [[ " $MESSAGE " == * " $outputmessage " * ]]; then
@@ -383,7 +418,8 @@ function ci::verify_wordcount_function() {
383418 timesleep=$5
384419 kubectl exec -n ${NAMESPACE} ${CLUSTER} -pulsar-broker-0 -- bin/pulsar-client produce -m " ${inputmessage} " -n 1 " ${inputtopic} "
385420 sleep " $timesleep "
386- MESSAGE=$( kubectl exec -n ${NAMESPACE} ${CLUSTER} -pulsar-broker-0 -- bin/pulsar-client consume -n 3 -s " sub" --subscription-position Earliest " ${outputtopic} " )
421+ sub=` cat /dev/urandom | tr -dc ' a-z' | head -c 8`
422+ MESSAGE=$( kubectl exec -n ${NAMESPACE} ${CLUSTER} -pulsar-broker-0 -- bin/pulsar-client consume -n 3 -s " ${sub} " --subscription-position Earliest " ${outputtopic} " )
387423 echo " $MESSAGE "
388424 if [[ " $MESSAGE " == * " $outputmessage " * ]]; then
389425 return 0
@@ -453,12 +489,13 @@ function ci::verify_elasticsearch_sink() {
453489
454490function ci::verify_mongodb_source() {
455491 timesleep=$1
456- kubectl exec mongo-dbz-0 -c mongo -- mongo -u debezium -p dbz --authenticationDatabase admin localhost:27017/inventory --eval ' db.products.update({"_id":NumberLong(104)},{$set:{weight:1.25}})'
492+ kubectl exec mongo-dbz-0 -c mongo -- mongosh -u debezium -p dbz --authenticationDatabase admin localhost:27017/inventory --eval ' db.products.update({"_id":NumberLong(104)},{$set:{weight:1.25}})'
457493 sleep " $timesleep "
458494 kubectl logs --tail=-1 -l compute.functionmesh.io/name=source-sample | grep " records sent"
459495 if [ $? -eq 0 ]; then
460496 return 0
461497 fi
498+ kubectl logs --tail=-1 -l compute.functionmesh.io/name=source-sample
462499 return 1
463500}
464501
@@ -484,7 +521,8 @@ function ci::verify_function_with_encryption() {
484521
485522 kubectl exec -n ${NAMESPACE} ${CLUSTER} -pulsar-broker-0 -- bin/pulsar-client produce -ekn " myapp1" -ekv " data:application/x-pem-file;base64,${correct_pubkey} " -m " ${inputmessage} " -n 1 " ${inputtopic} "
486523 sleep " $timesleep "
487- MESSAGE=$( kubectl exec -n ${NAMESPACE} ${CLUSTER} -pulsar-broker-0 -- bin/pulsar-client consume -n 1 -s " sub" --subscription-position Earliest " ${outputtopic} " )
524+ sub=` cat /dev/urandom | tr -dc ' a-z' | head -c 8`
525+ MESSAGE=$( kubectl exec -n ${NAMESPACE} ${CLUSTER} -pulsar-broker-0 -- bin/pulsar-client consume -n 1 -s " ${sub} " --subscription-position Earliest " ${outputtopic} " )
488526 echo " $MESSAGE "
489527 if [[ " $MESSAGE " == * " $outputmessage " * ]]; then
490528 return 0
@@ -573,7 +611,8 @@ function ci::verify_log_topic() {
573611 timesleep=$3
574612
575613 sleep " $timesleep "
576- MESSAGE=$( kubectl exec -n ${NAMESPACE} ${CLUSTER} -pulsar-broker-0 -- bin/pulsar-client consume -n 1 -s " sub" --subscription-position Earliest " ${logTopic} " )
614+ sub=` cat /dev/urandom | tr -dc ' a-z' | head -c 8`
615+ MESSAGE=$( kubectl exec -n ${NAMESPACE} ${CLUSTER} -pulsar-broker-0 -- bin/pulsar-client consume -n 1 -s " ${sub} " --subscription-position Earliest " ${logTopic} " )
577616 echo " $MESSAGE "
578617 if [[ " $MESSAGE " == * " $message " * ]]; then
579618 return 0
@@ -588,7 +627,8 @@ function ci::verify_log_topic_with_auth() {
588627 timesleep=$3
589628
590629 sleep " $timesleep "
591- consumeCommand=" kubectl exec -n ${NAMESPACE} ${CLUSTER} -pulsar-broker-0 -- sh -c 'bin/pulsar-client --auth-plugin \$ brokerClientAuthenticationPlugin --auth-params \$ brokerClientAuthenticationParameters consume -n 1 -s " sub" --subscription-position Earliest \" ${logTopic} \" '"
630+ sub=` cat /dev/urandom | tr -dc ' a-z' | head -c 8`
631+ consumeCommand=" kubectl exec -n ${NAMESPACE} ${CLUSTER} -pulsar-broker-0 -- sh -c 'bin/pulsar-client --auth-plugin \$ brokerClientAuthenticationPlugin --auth-params \$ brokerClientAuthenticationParameters consume -n 1 -s \" ${sub} \" --subscription-position Earliest \" ${logTopic} \" '"
592632 MESSAGE=$( sh -c " $consumeCommand " )
593633 echo " $MESSAGE "
594634 if [[ " $MESSAGE " == * " $message " * ]]; then
0 commit comments