Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Version bump #134

Merged
merged 4 commits into from
Aug 19, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions .env
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
FAABRIC_VERSION=0.1.1
FAABRIC_CLI_IMAGE=faasm/faabric:0.1.1
FAABRIC_VERSION=0.1.2
FAABRIC_CLI_IMAGE=faasm/faabric:0.1.2
COMPOSE_PROJECT_NAME=faabric-dev
6 changes: 3 additions & 3 deletions .github/workflows/tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ jobs:
REDIS_QUEUE_HOST: redis
REDIS_STATE_HOST: redis
container:
image: faasm/faabric:0.1.1
image: faasm/faabric:0.1.2
defaults:
run:
working-directory: /code/faabric
Expand Down Expand Up @@ -45,7 +45,7 @@ jobs:
REDIS_QUEUE_HOST: redis
REDIS_STATE_HOST: redis
container:
image: faasm/faabric:0.1.1
image: faasm/faabric:0.1.2
defaults:
run:
working-directory: /code/faabric
Expand Down Expand Up @@ -96,7 +96,7 @@ jobs:
REDIS_QUEUE_HOST: redis
REDIS_STATE_HOST: redis
container:
image: faasm/faabric:0.1.1
image: faasm/faabric:0.1.2
defaults:
run:
working-directory: /code/faabric
Expand Down
125 changes: 10 additions & 115 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,122 +1,17 @@
# Faabric [![Faabric tests](https://github.com/faasm/faabric/workflows/Tests/badge.svg?branch=master)](https://github.com/faasm/faabric/actions) [![License](https://img.shields.io/github/license/faasm/faabric.svg)](https://github.com/faasm/faabric/blob/master/LICENSE.md)
# Faabric [![Faabric tests](https://github.com/faasm/faabric/workflows/Tests/badge.svg?branch=master)](https://github.com/faasm/faabric/actions) [![License](https://img.shields.io/github/license/faasm/faabric.svg)](https://github.com/faasm/faabric/blob/master/LICENSE.md)

Faabric is a messaging and state layer for serverless applications.
Faabric is a library that provides scheduling, messaging and state for
distributed serverless runtimes.

## Building and Development
It began life as part of [Faasm](https://github.com/faasm/faasm), but is now a
stand-alone library that can be used as a base for other distributed runtimes.

You can build Faabric natively or using the containerised environment.
## Usage

### Containerised (recommended)
You can see a simple example in the [examples](examples) directory.

Run the following:
## Development

```bash
./bin/cli.sh
```
See the [development docs](docs/development.md) for more information on
developing Faabric.

This container has everything you need, and the script will also mount your
current checkout of the code. This means you can just run the following:

```bash
# Set up the build
inv dev.cmake

# Build the tests
inv dev.cc faabric_tests

# Run the tests
faabric_tests
```

To stop the `faabric`-related containers run:
```bash
docker-compose down
```

### Native

Most external dependencies are installed through CMake in
[cmake/ExternalProjects.cmake](./cmake/ExternalProjects.cmake).
The remaining installed packages can be inspected in the [`faabric-base`](
./docker/faabric-base.dockerfile) dockerfile.

Use of Clang and Ninja is recommended. From the root of this project you can
run:

```bash
mkdir build
cd build

cmake \
-GNinja \
-DCMAKE_C_COMPILER=clang \
-DCMAKE_CXX_COMPILER=clang++ \
-DCMAKE_BUILD_TYPE=Release \
..

ninja
```

You can also run the CLI with:

```bash
# Set up env
export FAABRIC_BUILD_DIR=<some dir>
source bin/workon.sh

# Install requirements
pip install -r requirements.txt

# Build Faabric
inv dev.cc faabric
```

## Releasing

Create a new branch, then find and replace the current version with the relevant
bumped version. Currently it's held in `VERSION`, `.env`,
`mpi-native/mpi-native.env` and the Github Actions configuration.

Once done, commit and push, then run:

```bash
source bin/workon.sh
inv git.tag
```

This will trigger the release build in Github Actions which will build all the
containers. Once that's complete, create a PR from your branch and make sure the
tests pass as normal.

If you want to overwrite a tag, you can run:

```bash
inv git.tag --force
```

### Building images manually

Containers are built with Github Actions, so you should only need to build them
yourself when diagnosing issues.

To build the main container, run:

```bash
source bin/workon.sh

# Build
inv container.build

# Push
inv container.push

# Build and push
inv container.build --push
```

## Additional documentation

More detail on some key features and implementations can be found below:

- [Native MPI builds](docs/mpi_native.md) - run native applications against
Faabric's MPI library.
2 changes: 1 addition & 1 deletion VERSION
Original file line number Diff line number Diff line change
@@ -1 +1 @@
0.1.1
0.1.2
112 changes: 112 additions & 0 deletions docs/development.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,73 @@
# Developing Faabric

## Development environment

### Containerised (recommended)

Run the following:

```bash
./bin/cli.sh
```

This container has everything you need, and the script will also mount your
current checkout of the code. This means you can just run the following:

```bash
# Set up the build
inv dev.cmake

# Build the tests
inv dev.cc faabric_tests

# Run the tests
faabric_tests
```

To stop the `faabric`-related containers run:

```bash
docker-compose down
```

### Native

Most external dependencies are installed through CMake in
[cmake/ExternalProjects.cmake](./cmake/ExternalProjects.cmake).
The remaining installed packages can be inspected in the [`faabric-base`](
./docker/faabric-base.dockerfile) dockerfile.

Use of Clang and Ninja is recommended. From the root of this project you can
run:

```bash
mkdir build
cd build

cmake \
-GNinja \
-DCMAKE_C_COMPILER=clang \
-DCMAKE_CXX_COMPILER=clang++ \
-DCMAKE_BUILD_TYPE=Release \
..

ninja
```

You can also run the CLI with:

```bash
# Set up env
export FAABRIC_BUILD_DIR=<some dir>
source bin/workon.sh

# Install requirements
pip install -r requirements.txt

# Build Faabric
inv dev.cc faabric
```

## Testing

We have some standard tests using [Catch2](https://github.com/catchorg/Catch2)
Expand Down Expand Up @@ -52,3 +120,47 @@ docker-compose rm
# Run once through
./dist-test/run.sh
```

## Releasing

Create a new branch, then find and replace the current version with the relevant
bumped version. Currently it's held in `VERSION`, `.env`,
`mpi-native/mpi-native.env` and the Github Actions configuration.

Once done, commit and push, then run:

```bash
source bin/workon.sh
inv git.tag
```

This will trigger the release build in Github Actions which will build all the
containers. Once that's complete, create a PR from your branch and make sure the
tests pass as normal.

If you want to overwrite a tag, you can run:

```bash
inv git.tag --force
```

### Building images manually

Containers are built with Github Actions, so you should only need to build them
yourself when diagnosing issues.

To build the main container, run:

```bash
source bin/workon.sh

# Build
inv container.build

# Push
inv container.push

# Build and push
inv container.build --push
```

2 changes: 1 addition & 1 deletion tasks/container.py
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ def _do_push(name):
run(cmd, shell=True, check=True)


@task
@task(default=True)
def build(ctx, nocache=False, push=False):
"""
Build current version of faabric container
Expand Down
2 changes: 1 addition & 1 deletion tests/dist/scheduler/test_threads.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@

#include <faabric/proto/faabric.pb.h>
#include <faabric/scheduler/Scheduler.h>
#include <faabric/scheduler/SnapshotClient.h>
#include <faabric/snapshot/SnapshotClient.h>
#include <faabric/snapshot/SnapshotRegistry.h>
#include <faabric/util/config.h>
#include <faabric/util/func.h>
Expand Down
60 changes: 60 additions & 0 deletions tests/test/endpoint/test_endpoint_api.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,11 @@ class EndpointApiTestExecutor final : public Executor
returnVal = 1;
msg.set_outputdata(fmt::format(
"Endpoint API returning {} for {}", returnVal, msg.id()));
} else if (msg.isasync()) {
returnVal = 0;
SLEEP_MS(3000);
msg.set_outputdata(
fmt::format("Finished async message {}", msg.id()));
} else {
throw std::runtime_error("Endpoint API error");
}
Expand Down Expand Up @@ -138,4 +143,59 @@ TEST_CASE_METHOD(EndpointApiTestFixture,
serverThread.join();
}
}

TEST_CASE_METHOD(EndpointApiTestFixture,
"Test status requests to endpoint",
"[endpoint]")
{
port++;
faabric::endpoint::FaabricEndpoint endpoint(port, 2);

std::thread serverThread([&endpoint]() { endpoint.start(false); });

// Wait for the server to start
SLEEP_MS(2000);

// Make the initial invocation
faabric::Message msg = faabric::util::messageFactory("foo", "blah");
msg.set_isasync(true);
std::string body = faabric::util::messageToJson(msg);

std::pair<int, std::string> result =
submitGetRequestToUrl(LOCALHOST, port, body);

REQUIRE(result.first == 200);
REQUIRE(result.second == std::to_string(msg.id()));

// Make a status request, should still be running
faabric::Message statusMsg;
statusMsg.set_user("foo");
statusMsg.set_function("blah");
statusMsg.set_id(msg.id());
statusMsg.set_isstatusrequest(true);

std::string statusBody = faabric::util::messageToJson(statusMsg);

std::pair<int, std::string> statusResult =
submitGetRequestToUrl(LOCALHOST, port, statusBody);

REQUIRE(statusResult.first == 200);
REQUIRE(statusResult.second == "RUNNING");

// Wait for the function to finish
SLEEP_MS(4000);

std::pair<int, std::string> statusResultAfter =
submitGetRequestToUrl(LOCALHOST, port, statusBody);

REQUIRE(statusResultAfter.first == 200);
REQUIRE(statusResultAfter.second ==
fmt::format("SUCCESS: Finished async message {}", msg.id()));

endpoint.stop();

if (serverThread.joinable()) {
serverThread.join();
}
}
}
2 changes: 0 additions & 2 deletions tests/utils/http_utils.cpp
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
#include <faabric/util/bytes.h>
#include <faabric/util/http.h>
#include <faabric/util/logging.h>

#include <pistache/async.h>
Expand All @@ -24,7 +23,6 @@ namespace tests {
std::pair<int, std::string> submitGetRequestToUrl(const std::string& host,
int port,
const std::string& body)

{
Http::Client client;
client.init();
Expand Down