goss.yaml 2.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445
  1. # Copyright Broadcom, Inc. All Rights Reserved.
  2. # SPDX-License-Identifier: APACHE-2.0
  3. command:
  4. {{- $mongos := .Vars.mongos.replicaCount }}
  5. {{- $shards := .Vars.shards }}
  6. {{- $shardNodes := .Vars.shardsvr.dataNode.replicaCount }}
  7. {{- $collection := printf "test_%s" (randAlpha 5) }}
  8. {{- $dbUser := .Vars.auth.rootUser }}
  9. {{- $dbPassword := .Vars.auth.rootPassword }}
  10. {{- $authOptions := printf "-u %s -p %s" $dbUser $dbPassword }}
  11. {{- $svcPort := .Vars.mongos.servicePerReplica.port }}
  12. {{- $localEndpoint := printf "%s:%d" "localhost" .Vars.common.containerPorts.mongodb }}
  13. mongos-check:
  14. exec: mongosh --quiet {{ $authOptions }} {{ $localEndpoint }} --eval "db.createCollection('{{ $collection }}')"{{ range $e, $i := until $mongos }} && mongosh --quiet {{ $authOptions }} mongodb-sharded-{{ $i }}:{{ $svcPort }} --eval "db.getCollectionNames()" | grep {{ $collection }}{{ end }}
  15. exit-status: 0
  16. timeout: 20000
  17. sharding-status:
  18. exec: if [ "$(mongosh --quiet {{ $authOptions }} {{ $localEndpoint }} --eval 'sh.status()' | grep 'state.*1' | wc -l)" -ne {{ $shards }} ]; then exit 1; fi
  19. exit-status: 0
  20. timeout: 20000
  21. shard-data-nodes:
  22. exec: mongosh --quiet {{ $authOptions }} {{ $localEndpoint }} --eval "sh.status()"
  23. exit-status: 0
  24. stdout:
  25. {{ range $e, $shard := until $shards }}
  26. {{ range $e, $shardNode := until $shardNodes }}
  27. - /host.*mongodb-sharded-shard{{ $shard }}-data-{{ $shardNode }}/
  28. {{ end }}
  29. {{ end }}
  30. timeout: 20000
  31. {{- $uid := .Vars.mongos.containerSecurityContext.runAsUser }}
  32. {{- $gid := .Vars.mongos.podSecurityContext.fsGroup }}
  33. check-user-info:
  34. # The UID and GID should always be either the one specified as vars (always a bigger number that the default)
  35. # or the one randomly defined by openshift (larger values). Otherwise, the chart is still using the default value.
  36. exec: if [ $(id -u) -lt {{ $uid }} ] || [ $(id -G | awk '{print $2}') -lt {{ $gid }} ]; then exit 1; fi
  37. exit-status: 0
  38. file:
  39. /opt/bitnami/mongodb/conf/keyfile:
  40. mode: "0600"
  41. filetype: file
  42. contents:
  43. - "{{ .Vars.auth.replicaSetKey }}"
  44. exists: true