Skip to content
Draft
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
85 changes: 85 additions & 0 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,85 @@
# MIT License
#
# Copyright (c) 2022 EASE lab
#
# Permission is hereby granted, free of charge, to any person obtaining a copy
# of this software and associated documentation files (the "Software"), to deal
# in the Software without restriction, including without limitation the rights
# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
# copies of the Software, and to permit persons to whom the Software is
# furnished to do so, subject to the following conditions:
#
# The above copyright notice and this permission notice shall be included in all
# copies or substantial portions of the Software.
#
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
# SOFTWARE.


name: Release

on:
workflow_dispatch:

# For all pushed tags
push:
tags:
- '*'

env:
GOOS: linux
GO111MODULE: on


jobs:
build_release:
name: build_release
runs-on: ubuntu-20.04
steps:
- uses: actions/checkout@v3

## Test artifacts




- name: Build release
run: make build-release
# - name: Get the version
# id: get_version
# run: |
# echo ::set-output name=TAG::${GITHUB_REF/refs\/tags\//}

- name: Get the version
id: version
run: echo "::set-output name=version::$(./bin/client --version)"


## Create the release
- name: release
uses: actions/create-release@v1
id: create_release
with:
draft: true
prerelease: true
release_name: ${{ steps.version.outputs.version }}
tag_name: ${{ github.ref }}
# body_path: CHANGELOG.md
env:
GITHUB_TOKEN: ${{ github.token }}

## Finally upload the artifacts
- name: upload linux artifact
uses: actions/upload-release-asset@v1
env:
GITHUB_TOKEN: ${{ github.token }}
with:
upload_url: ${{ steps.create_release.outputs.upload_url }}
asset_path: ./bin/client
asset_name: client-linux-amd64
asset_content_type: application
51 changes: 50 additions & 1 deletion Makefile
Original file line number Diff line number Diff line change
@@ -1,5 +1,16 @@

## Protocol buffer


BIN_DIR=./bin
BIN=client
LINUX_OS=linux


.PHONY: build test installclean release bin-dir


# VERSION ?=LOCAL

proto-all: proto-all-python proto-all-go

proto-all-python:
Expand All @@ -16,3 +27,41 @@ proto-all-go:
--go-grpc_out=. \
--go-grpc_opt=paths=source_relative \
./proto/*/*.proto


build: wkdir
sed -i "s|LOCAL|$$(git rev-parse --short HEAD)|" ./cmd/version.go;
go build -o $(BIN_DIR)/$(BIN) cmd/*;
# git checkout -- ./cmd/version.go;



build-release: wkdir
sed -i "s|LOCAL|$$(git rev-parse --short HEAD)|" ./cmd/version.go; \
go build -o $(BIN_DIR)/$(BIN) cmd/*; \


# if [ -z "$(shell git status --porcelain)" ]; then \
# sed -i "s|LOCAL|$$(git rev-parse --short HEAD)|" ./cmd/version.go; \
# go build -o $(BIN_DIR)/$(BIN) cmd/*; \
# git checkout -- ./cmd/version.go; \
# else \
# echo Working directory not clean, commit changes; \
# fi

## Client for all proto buffer

# client: test-client/main.go
# sed -i "s|LOCAL|$(VERSION)|" $<;
# go mod tidy
# go build -o $@ $<

wkdir:
mkdir -p $(BIN_DIR)

clean:
if [ -d $(BIN_DIR) ]; then rm -rf $(BIN_DIR); fi

release: build-release
VERSION=$$($(BIN_DIR)/$(BIN) --version); \
git tag $$VERSION;
12 changes: 11 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,13 @@
# vSwarm-proto

vSwarm-proto is a utility for [vSwarm](https://github.com/ease-lab/vSwarm/) containing all the proto files and client applications necessary to run benchmarks using [relay](https://github.com/ease-lab/vSwarm/tree/main/tools/relay).
vSwarm-proto is a utility for [vSwarm](https://github.com/ease-lab/vSwarm/) containing all the proto files and client applications necessary to run benchmarks using [relay](https://github.com/ease-lab/vSwarm/tree/main/tools/relay).

## CLI command
The `cmd` subfolder contains a command line interface for invoking any kind of function that implement one of the protocols in this repository.

## Releasing new versions
In order to release a new version do the following:
1. Increment the version number in `cmd/version.go`.
2. Build the release with `make release`
3. Push the new version with `git push <VERSION TAG>`

124 changes: 124 additions & 0 deletions cmd/main.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,124 @@
/* MIT License
*
* Copyright (c) 2022 David Schall and EASE lab
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in all
* copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
* SOFTWARE.
*
*/

// Package main implements a client for Greeter service.
package main

import (
"flag"
"fmt"
"log"
"os"

// pb "google.golang.org/grpc/examples/helloworld/helloworld"
grpcClients "github.com/ease-lab/vSwarm-proto/grpcclient"
)

const (
defaultInput = "world"
)

var (
print_version = flag.Bool("version", false, "Version of client")
functionName = flag.String("function-name", "helloworld", "Specify the name of the function being invoked.")
url = flag.String("url", "0.0.0.0", "The url to connect to")
port = flag.String("port", "50051", "the port to connect to")
input = flag.String("input", defaultInput, "Input to the function")
functionMethod = flag.String("function-method", "default", "Which method of benchmark to invoke")
n = flag.Int("n", 10, "Number of invokations")
logfile = flag.String("logging", "", "Log to file instead of standart out")
)

func main() {
flag.Parse()

if *print_version {
fmt.Println(version)
os.Exit(0)
}

// open file and create if non-existent
if *logfile != "" {
file, err := os.OpenFile(*logfile, os.O_APPEND|os.O_CREATE|os.O_WRONLY, 0644)
if err != nil {
log.Fatal(err)
}
defer file.Close()
log.SetOutput(file)
}

log.Println("-- Invokation test --")

// Set up a connection to the function server.
serviceName := grpcClients.FindServiceName(*functionName)
client := grpcClients.FindGrpcClient(serviceName)
client.Init(*url, *port)
defer client.Close()

// conn, err := grpc.Dial(*addr, grpc.WithInsecure())
// if err != nil {
// log.Fatalf("FAIL: did not connect: %v", err)
// }
// defer conn.Close()
// c := pb.NewGreeterClient(conn)

// // // Contact the server and print out its response.
// ctx, cancel := context.WithTimeout(context.Background(), 30*time.Second)
// defer cancel()

// Create packet to send to the function
// var pkt grpcClients.Input
// pkt.SetGenerator(grpcClients.Unique)
// pkt.SetValue(*input)
generator := client.GetGenerator()
generator.SetGenerator(grpcClients.Unique)
generator.SetValue(*input)
generator.SetMethod(*functionMethod)
pkt := generator.Next()

reply := client.Request(pkt)
// log.Debug(reply)

// r, err := c.SayHello(ctx, &pb.HelloRequest{Name: *name})
// if err != nil {
// log.Fatalf("FAIL: could not greet: %v", err)
// }
log.Printf("Greeting: %s", reply)

// Print 5 times the progress
mod := 1
if *n > 2*5 {
mod = *n / 5
}
for i := 0; i < *n; i++ {

// c.SayHello(ctx, &pb.HelloRequest{Name: *name})
client.Request(pkt)
if i%mod == 0 {
log.Printf("Invoked for %d times\n", i)
}
}
log.Printf("Finished invoking: %s", reply)
log.Printf("SUCCESS: Calling functions for %d times", *n)
}
3 changes: 3 additions & 0 deletions cmd/version.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
package main

const version = "v0.1.3-LOCAL"