mirror of
https://github.com/openfaas/faas.git
synced 2025-06-09 00:36:46 +00:00
Adds annotation attribute to CreateFunctionRequest
1. Add new annotation attributes which may be used by the back-end for making scheduling or routing decisions. 2. Updated tests/README.md to give clearer instructions on creating and tearing down the stack required to run the integration tests 3. Update ci.sh * Fail as soon as an error is encountered * Allow script to run locally in development environment, test if repos are already cloned etc.. * Deploy ./stack.yml used by existing integration tests Signed-off-by: Edward Wilde <ewilde@gmail.com>
This commit is contained in:
parent
9512f09d2b
commit
be907d220c
2
.gitignore
vendored
2
.gitignore
vendored
@ -4,3 +4,5 @@ fwatchdog-armhf
|
|||||||
**/*.DS_Store
|
**/*.DS_Store
|
||||||
.vscode
|
.vscode
|
||||||
.idea
|
.idea
|
||||||
|
certifier
|
||||||
|
.editorconfig
|
||||||
|
@ -15,9 +15,8 @@ addons:
|
|||||||
before_install:
|
before_install:
|
||||||
|
|
||||||
script:
|
script:
|
||||||
- sh build.sh
|
- ./build.sh
|
||||||
# Invoke ci script too
|
- ./contrib/ci.sh
|
||||||
- sh contrib/ci.sh
|
|
||||||
|
|
||||||
after_success:
|
after_success:
|
||||||
- if [ -z $DOCKER_NS ] ; then
|
- if [ -z $DOCKER_NS ] ; then
|
||||||
|
4
Makefile
4
Makefile
@ -1,6 +1,8 @@
|
|||||||
.PHONY: build
|
.PHONY: build build-gateway test-ci
|
||||||
|
|
||||||
build:
|
build:
|
||||||
./build.sh
|
./build.sh
|
||||||
build-gateway:
|
build-gateway:
|
||||||
(cd gateway; ./build.sh latest-dev)
|
(cd gateway; ./build.sh latest-dev)
|
||||||
|
test-ci:
|
||||||
|
./contrib/ci.sh
|
||||||
|
@ -263,6 +263,16 @@ definitions:
|
|||||||
additionalProperties:
|
additionalProperties:
|
||||||
type: string
|
type: string
|
||||||
description: Overrides to environmental variables
|
description: Overrides to environmental variables
|
||||||
|
labels:
|
||||||
|
type: array
|
||||||
|
items:
|
||||||
|
type: string
|
||||||
|
description: An array of labels used by the back-end for making scheduling or routing decisions
|
||||||
|
annotations:
|
||||||
|
type: array
|
||||||
|
items:
|
||||||
|
type: string
|
||||||
|
description: An array of annotations used by the back-end for management, orchestration, events and build tasks
|
||||||
secrets:
|
secrets:
|
||||||
type: array
|
type: array
|
||||||
items:
|
items:
|
||||||
|
57
contrib/ci.sh
Normal file → Executable file
57
contrib/ci.sh
Normal file → Executable file
@ -1,39 +1,78 @@
|
|||||||
#!/bin/bash
|
#!/bin/bash
|
||||||
|
|
||||||
docker swarm init --advertise-addr=127.0.0.1
|
docker swarm init --advertise-addr=127.0.0.1
|
||||||
|
set -e
|
||||||
|
|
||||||
./deploy_stack.sh --no-auth
|
./deploy_stack.sh --no-auth
|
||||||
|
|
||||||
docker service update func_gateway --image=openfaas/gateway:latest-dev
|
docker service update func_gateway --image=openfaas/gateway:latest-dev
|
||||||
|
|
||||||
# Script makes sure OpenFaaS API gateway is ready before running tests
|
# Script makes sure OpenFaaS API gateway is ready before running tests
|
||||||
|
wait_success=false
|
||||||
for i in {1..30};
|
for i in {1..30};
|
||||||
do
|
do
|
||||||
echo "Checking if 127.0.0.1:8000 is up.. ${i}/30"
|
echo "Checking if 127.0.0.1:8000 is up.. ${i}/30"
|
||||||
curl -fs 127.0.0.1:8080/
|
status_code=$(curl --silent --output /dev/stderr --write-out "%{http_code}" http://127.0.0.1:8080/)
|
||||||
|
|
||||||
if [ $? -eq 0 ]; then
|
if [ "$status_code" -ge 200 -a "$status_code" -lt 400 ]; then
|
||||||
|
echo "Deploying gateway success"
|
||||||
|
wait_success=true
|
||||||
break
|
break
|
||||||
fi
|
fi
|
||||||
sleep 0.5
|
sleep 0.5
|
||||||
done
|
done
|
||||||
|
|
||||||
|
if [ "$wait_success" != true ] ; then
|
||||||
|
echo "Failed to wait for gateway"
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
|
||||||
cd ..
|
cd ..
|
||||||
|
|
||||||
echo $GOPATH
|
echo $GOPATH
|
||||||
|
|
||||||
mkdir -p $GOPATH/src/github.com/openfaas/
|
if [ ! -d "$GOPATH/src/github.com/openfaas/" ]; then
|
||||||
cp -r faas $GOPATH/src/github.com/openfaas/
|
mkdir -p $GOPATH/src/github.com/openfaas/
|
||||||
|
cp -r faas $GOPATH/src/github.com/openfaas/
|
||||||
|
fi
|
||||||
|
|
||||||
git clone https://github.com/openfaas/certifier
|
if [ ! -d "$GOPATH/src/github.com/openfaas/certifier" ]; then
|
||||||
|
git clone https://github.com/openfaas/certifier
|
||||||
|
fi
|
||||||
|
|
||||||
cp -r certifier $GOPATH/src/github.com/openfaas/
|
echo "Deploying OpenFaaS stack.yml from $(pwd)/faas"
|
||||||
|
command -v faas-cli >/dev/null 2>&1 || curl -sSL https://cli.openfaas.com | sudo sh
|
||||||
|
faas-cli deploy -f ./faas/stack.yml
|
||||||
|
|
||||||
|
wait_success=false
|
||||||
|
for i in {1..30}
|
||||||
|
do
|
||||||
|
echo "Checking if 127.0.0.1:8080/function/echoit is up.. ${i}/30"
|
||||||
|
status_code=$(curl --silent --output /dev/stderr --write-out "%{http_code}" http://127.0.0.1:8080/function/echoit -d "hello")
|
||||||
|
|
||||||
|
if [ "$status_code" -ge 200 -a "$status_code" -lt 400 ]; then
|
||||||
|
echo "Deploying OpenFaaS stack.yml success"
|
||||||
|
wait_success=true
|
||||||
|
break
|
||||||
|
else
|
||||||
|
echo "Attempt $i lets try again"
|
||||||
|
fi
|
||||||
|
|
||||||
|
printf '.'
|
||||||
|
sleep 0.5
|
||||||
|
done
|
||||||
|
|
||||||
|
if [ "$wait_success" != true ] ; then
|
||||||
|
echo "Failed to wait for stack.yml to deploy"
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
|
||||||
|
echo Running integration tests
|
||||||
cd $GOPATH/src/github.com/openfaas/faas/gateway/tests/integration && \
|
cd $GOPATH/src/github.com/openfaas/faas/gateway/tests/integration && \
|
||||||
go test -v
|
go test -v -count=1
|
||||||
|
|
||||||
|
echo Running certifier
|
||||||
cd $GOPATH/src/github.com/openfaas/certifier && \
|
cd $GOPATH/src/github.com/openfaas/certifier && \
|
||||||
make test
|
make test
|
||||||
|
|
||||||
|
echo Integration tests all PASSED
|
||||||
exit 0
|
exit 0
|
||||||
|
@ -36,6 +36,10 @@ type CreateFunctionRequest struct {
|
|||||||
// back-end for making scheduling or routing decisions
|
// back-end for making scheduling or routing decisions
|
||||||
Labels *map[string]string `json:"labels"`
|
Labels *map[string]string `json:"labels"`
|
||||||
|
|
||||||
|
// Annotations are metadata for functions which may be used by the
|
||||||
|
// back-end for management, orchestration, events and build tasks
|
||||||
|
Annotations *map[string]string `json:"annotations"`
|
||||||
|
|
||||||
// Limits for function
|
// Limits for function
|
||||||
Limits *FunctionResources `json:"limits"`
|
Limits *FunctionResources `json:"limits"`
|
||||||
|
|
||||||
@ -67,6 +71,10 @@ type Function struct {
|
|||||||
// Labels are metadata for functions which may be used by the
|
// Labels are metadata for functions which may be used by the
|
||||||
// back-end for making scheduling or routing decisions
|
// back-end for making scheduling or routing decisions
|
||||||
Labels *map[string]string `json:"labels"`
|
Labels *map[string]string `json:"labels"`
|
||||||
|
|
||||||
|
// Annotations are metadata for functions which may be used by the
|
||||||
|
// back-end for management, orchestration, events and build tasks
|
||||||
|
Annotations *map[string]string `json:"annotations"`
|
||||||
}
|
}
|
||||||
|
|
||||||
// AsyncReport is the report from a function executed on a queue worker.
|
// AsyncReport is the report from a function executed on a queue worker.
|
||||||
|
@ -2,3 +2,15 @@
|
|||||||
|
|
||||||
These tests should be run against the sample stack included in the repository root.
|
These tests should be run against the sample stack included in the repository root.
|
||||||
|
|
||||||
|
## Deploy the stack
|
||||||
|
```
|
||||||
|
./deploy_stack.sh
|
||||||
|
faas-cli deploy -f ./stack.yml
|
||||||
|
```
|
||||||
|
|
||||||
|
## Remove the stack
|
||||||
|
1. Delete all OpenFaaS deployed functions
|
||||||
|
```
|
||||||
|
faas-cli remove
|
||||||
|
docker stack rm func
|
||||||
|
```
|
@ -34,7 +34,7 @@ func Test_InfoEndpoint_Returns_Gateway_Version_SHA_And_Message(t *testing.T) {
|
|||||||
gatewayInfo := &types.GatewayInfo{}
|
gatewayInfo := &types.GatewayInfo{}
|
||||||
err = json.Unmarshal([]byte(body), gatewayInfo)
|
err = json.Unmarshal([]byte(body), gatewayInfo)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
t.Log(err)
|
t.Errorf("Could not unmarshal gateway info, response body:%s, error:%s", body, err.Error())
|
||||||
t.Fail()
|
t.Fail()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -3,10 +3,10 @@ package main
|
|||||||
import (
|
import (
|
||||||
"fmt"
|
"fmt"
|
||||||
"io/ioutil"
|
"io/ioutil"
|
||||||
|
"log"
|
||||||
"os"
|
"os"
|
||||||
"strconv"
|
"strconv"
|
||||||
"time"
|
"time"
|
||||||
"log"
|
|
||||||
)
|
)
|
||||||
|
|
||||||
func main() {
|
func main() {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user