apiVersion: v1
kind: Pod
metadata:
  name: smarter-device-management-client
  namespace: NAMESPACE
spec:
  serviceAccountName: default
  automountServiceAccountToken: false
  dnsPolicy: ClusterFirstWithHostNet
  hostname: yocto-test-client
  nodeName: NODE_TO_TEST
  restartPolicy: Never
  containers:
  - name: smarter-device-management-client
    imagePullPolicy: IfNotPresent
    image: alpine
    command: ["/bin/ash"]
    args:
    - "-c"
    - |
      if [ ! -d /dev/snd ]
      then
           echo "No sound directory available (/dev/snd)"
           exit 1
      fi
      apk add alsa-utils
      if [ $? -gt 0 ]
      then
           echo "Could not install alsa-utils"
           for i in 1 2 3 4 5 6 7 8 9 10
           do
               sleep 20
           done
           exit $?
      fi
      if [ $? -gt 0 ]
      then
           echo "Could not install alsa-utils"
           exit $?
      fi
      RESULT=$(aplay -L)
      if [ $? -gt 0 ]
      then
           echo "Could not execute aplay"
           exit $?
      fi
      NL=$(echo "${RESULT}" | grep tegrasndt19xmob | wc -l)
      if [ ${NL} -ne 2 ]
      then
           echo "Aplay did not find the correct device check:" 
           echo "${RESULT}"
           exit 11
      fi
      exit 0
    resources:
      limits:
        cpu: 100m
        memory: 100Mi
        smarter-devices/snd: 1
      requests:
        cpu: 100m
        memory: 100Mi
        smarter-devices/snd: 1
  terminationGracePeriodSeconds: 10
