blob: 8ca30134d16e0f681f03aae5e630bb549759daf9 [file]
#!/bin/bash
# Licensed to the Apache Software Foundation (ASF) under one
# or more contributor license agreements. See the NOTICE file
# distributed with this work for additional information
# regarding copyright ownership. The ASF licenses this file
# to you under the Apache License, Version 2.0 (the
# "License"); you may not use this file except in compliance
# with the License. You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing,
# software distributed under the License is distributed on an
# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
# KIND, either express or implied. See the License for the
# specific language governing permissions and limitations
# under the License.
TYPE="${1:?test type}"
TYPE="$(echo $TYPE | awk -F- '{print $1}')"
# Generate a random password for the user "demo"
password=$(ops -random --str 12)
user="demouser"
ENABLE_REDIS=""
if ops config status | grep -q OPERATOR_COMPONENT_REDIS=true; then
ENABLE_REDIS="--redis"
fi
ENABLE_MONGODB=""
if ops config status | grep -q OPERATOR_COMPONENT_MONGODB=true; then
ENABLE_MONGODB="--mongodb"
fi
ENABLE_OBJECT_STORAGE=""
if ops config status | grep -q OPERATOR_COMPONENT_SEAWEEDFS=true; then
ENABLE_OBJECT_STORAGE="--seaweedfs"
elif ops config status | grep -q OPERATOR_COMPONENT_MINIO=true; then
ENABLE_OBJECT_STORAGE="--minio"
fi
ENABLE_POSTGRES=""
if ops config status | grep -q OPERATOR_COMPONENT_POSTGRES=true; then
ENABLE_POSTGRES="--postgres"
fi
# Create a new user "demo-user" with ops admin adduser with previous services enabled
ops admin deleteuser $user >/dev/null 2>&1 || true
if ops admin adduser $user demo@email.com $password $ENABLE_REDIS $ENABLE_MONGODB $ENABLE_OBJECT_STORAGE $ENABLE_POSTGRES | grep "whiskuser.nuvolaris.org/$user created"; then
echo SUCCESS CREATING $user
else
echo FAIL CREATING $user
exit 1
fi
ops util kube waitfor FOR=condition=ready OBJ="wsku/$user" TIMEOUT=120
APIURL=$(ops debug apihost | awk '/whisk API host/{print $4}')
echo $APIURL
if OPS_USER=$user OPS_PASSWORD=$password ops -login $APIURL | grep "Successfully logged in as $user."; then
echo SUCCESS LOGIN
else
echo FAIL LOGIN
exit 1
fi
if ops setup nuvolaris hello | grep hello; then
echo SUCCESS
else
echo FAIL
exit 1
fi
if ops -wsk action list | grep /$user/hello/hello; then
echo SUCCESS
exit 0
else
echo FAIL
exit 1
fi