Skip to content

Commit 55de8be

Browse files
committed
Added driver unit tests and e2e tests to CI and formatted code
Signed-off-by: aryans1204 <arshar1204@gmail.com> Added tests to CI and formatted code Signed-off-by: aryans1204 <arshar1204@gmail.com> Fixing the E2E test for vSwarm loader Signed-off-by: aryans1204 <arshar1204@gmail.com> Extracted vSwarm mock server from standard workload Signed-off-by: aryans1204 <arshar1204@gmail.com>
1 parent 13a66a4 commit 55de8be

File tree

12 files changed

+476
-72
lines changed

12 files changed

+476
-72
lines changed

.github/workflows/e2e.yaml

Lines changed: 104 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,104 @@
1+
name: End-to-End Tests
2+
3+
on:
4+
schedule:
5+
- cron: "0 9 * * 1"
6+
workflow_dispatch:
7+
push:
8+
branches: [main]
9+
pull_request:
10+
branches: [main]
11+
12+
env:
13+
GOOS: linux
14+
GO111MODULE: on
15+
16+
jobs:
17+
test-knative:
18+
name: Test Knative Deployment
19+
env:
20+
KIND_VERSION: v0.22.0
21+
K8S_VERSION: v1.29
22+
YAML_DIR: workloads/container
23+
24+
runs-on: ubuntu-20.04
25+
strategy:
26+
fail-fast: false
27+
matrix:
28+
service:
29+
[
30+
trace_func_go,
31+
]
32+
steps:
33+
- uses: actions/checkout@v4
34+
with:
35+
lfs: "true"
36+
- name: Checkout LFS objects
37+
run: git lfs checkout
38+
39+
- uses: actions/setup-go@v5
40+
with:
41+
go-version: 1.22
42+
43+
- name: Create k8s Kind Cluster
44+
run: bash ./scripts/konk-ci/01-kind.sh
45+
46+
- name: Install Serving
47+
run: bash ./scripts/konk-ci/02-serving.sh
48+
49+
- name: Install Kourier
50+
run: bash ./scripts/konk-ci/02-kourier.sh
51+
52+
- name: Setup domain and autoscaler
53+
run: |
54+
INGRESS_HOST="127.0.0.1"
55+
KNATIVE_DOMAIN=$INGRESS_HOST.sslip.io
56+
kubectl patch configmap -n knative-serving config-domain -p "{\"data\": {\"$KNATIVE_DOMAIN\": \"\"}}"
57+
kubectl patch configmap -n knative-serving config-autoscaler -p "{\"data\": {\"allow-zero-initial-scale\": \"true\"}}"
58+
kubectl patch configmap -n knative-serving config-features -p "{\"data\": {\"kubernetes.podspec-affinity\": \"enabled\"}}"
59+
kubectl label node knative-control-plane loader-nodetype=worker
60+
61+
- name: Build and run loader
62+
run: go run cmd/loader.go --config pkg/config/test_config.json
63+
64+
- name: Check the output
65+
run: test -f "data/out/experiment_duration_2.csv" && test $(cat data/out/experiment_duration_2.csv | wc -l) -gt 1 && test $(grep true data/out/experiment_duration_2.csv | wc -l) -eq 0 # test the output file for errors (true means failure to invoke)
66+
67+
- name: Print logs
68+
if: ${{ always() }}
69+
run: |
70+
set -x
71+
container_list=$(kubectl get pods -n default -o jsonpath="{.items[*].spec.containers[*].name}")
72+
for container_name in $container_list
73+
do
74+
kubectl logs -n default -c $container_name -l serving.knative.dev/service=${{ matrix.service }}
75+
done
76+
- name: Down
77+
if: ${{ always() }}
78+
run: |
79+
kn service delete --all
80+
81+
- name: Untar vSwarm YAMLs
82+
if: ${{ always() }}
83+
run: |
84+
tar -xzvf workloads/container/yamls.tar.gz -C workloads/container/
85+
- name: Run vSwarm loader
86+
run: go run cmd/loader.go --config pkg/config/test_vswarm_config.json
87+
88+
- name: Check vSwarm output
89+
run: test -f "data/out/experiment_duration_2.csv" && test $(cat data/out/experiment_duration_2.csv | wc -l) -gt 1 && test $(grep true data/out/experiment_duration_2.csv | wc -l) -eq 1 # test the output file for errors (true means failure to invoke)
90+
91+
- name: Print logs
92+
if: ${{ always() }}
93+
run: |
94+
set -x
95+
container_list=$(kubectl get pods -n default -o jsonpath="{.items[*].spec.containers[*].name}")
96+
for container_name in $container_list
97+
do
98+
kubectl logs -n default -c $container_name -l serving.knative.dev/service=${{ matrix.service }}
99+
done
100+
- name: Down
101+
if: ${{ always() }}
102+
run: |
103+
kn service delete --all
104+

cmd/config_vswarm_trace.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@
1313
"OutputPathPrefix": "data/out/experiment",
1414
"IATDistribution": "exponential",
1515
"CPULimit": "1vCPU",
16-
"ExperimentDuration": 3,
16+
"ExperimentDuration": 10,
1717
"WarmupDuration": 0,
1818

1919
"IsPartiallyPanic": false,

cmd/loader.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -192,7 +192,7 @@ func runTraceMode(cfg *config.LoaderConfiguration, readIATFromFile bool, writeIA
192192
}
193193

194194
iatType, shiftIAT := parseIATDistribution(cfg)
195-
195+
196196
experimentDriver := driver.NewDriver(&config.Configuration{
197197
LoaderConfiguration: cfg,
198198
FailureConfiguration: config.ReadFailureConfiguration(*failurePath),

pkg/config/parser_test.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,7 @@ func TestConfigParser(t *testing.T) {
5454
!strings.HasPrefix(config.OutputPathPrefix, "data/out/experiment") ||
5555
config.IATDistribution != "equidistant" ||
5656
config.CPULimit != "1vCPU" ||
57-
config.ExperimentDuration != 5 ||
57+
config.ExperimentDuration != 2 ||
5858
config.WarmupDuration != 0 ||
5959
config.IsPartiallyPanic != false ||
6060
config.EnableZipkinTracing != false ||

pkg/config/test_config.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111
"OutputPathPrefix": "data/out/experiment",
1212
"IATDistribution": "equidistant",
1313
"CPULimit": "1vCPU",
14-
"ExperimentDuration": 5,
14+
"ExperimentDuration": 2,
1515
"WarmupDuration": 0,
1616

1717
"IsPartiallyPanic": false,

pkg/config/test_vswarm_config.json

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
{
2+
"Seed": 42,
3+
4+
"Platform": "Knative",
5+
"InvokeProtocol" : "grpc",
6+
"YAMLSelector": "container",
7+
"EndpointPort": 80,
8+
9+
"BusyLoopOnSandboxStartup": false,
10+
11+
"TracePath": "data/traces/example/",
12+
"Granularity": "minute",
13+
"OutputPathPrefix": "data/out/experiment",
14+
"IATDistribution": "exponential",
15+
"CPULimit": "1vCPU",
16+
"ExperimentDuration": 2,
17+
"WarmupDuration": 0,
18+
19+
"IsPartiallyPanic": false,
20+
"EnableZipkinTracing": false,
21+
"EnableMetricsScrapping": false,
22+
"MetricScrapingPeriodSeconds": 15,
23+
"AutoscalingMetric": "concurrency",
24+
25+
"GRPCConnectionTimeoutSeconds": 15,
26+
"GRPCFunctionTimeoutSeconds": 900,
27+
"DAGMode": false,
28+
"EnableDAGDataset": true,
29+
"Width": 2,
30+
"Depth": 2,
31+
"VSwarm": true
32+
}

pkg/driver/clients/grpc_client_test.go

Lines changed: 6 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -25,19 +25,16 @@
2525
package clients
2626

2727
import (
28-
"context"
2928
"fmt"
29+
"os"
30+
"testing"
31+
"time"
32+
3033
"github.com/sirupsen/logrus"
3134
"github.com/vhive-serverless/loader/pkg/common"
3235
"github.com/vhive-serverless/loader/pkg/config"
3336
"github.com/vhive-serverless/loader/pkg/workload/standard"
34-
helloworld "github.com/vhive-serverless/vSwarm/utils/protobuf/helloworld"
35-
"google.golang.org/grpc"
36-
"google.golang.org/grpc/reflection"
37-
"net"
38-
"os"
39-
"testing"
40-
"time"
37+
"github.com/vhive-serverless/loader/pkg/workload/vswarm"
4138
)
4239

4340
func createFakeLoaderConfiguration() *config.LoaderConfiguration {
@@ -71,29 +68,6 @@ var testRuntimeSpecs = common.RuntimeSpecification{
7168
Memory: 128,
7269
}
7370

74-
type vSwarmServer struct {
75-
helloworld.UnimplementedGreeterServer
76-
}
77-
78-
func (s *vSwarmServer) SayHello(_ context.Context, req *helloworld.HelloRequest) (*helloworld.HelloReply, error) {
79-
return &helloworld.HelloReply{
80-
Message: "Reply message",
81-
}, nil
82-
}
83-
84-
func startVSwarmGRPCServer(serverAddress string, serverPort int) {
85-
lis, err := net.Listen("tcp", fmt.Sprintf("%s:%d", serverAddress, serverPort))
86-
if err != nil {
87-
logrus.Fatalf("failed to listen: %v", err)
88-
}
89-
90-
grpcServer := grpc.NewServer()
91-
92-
reflection.Register(grpcServer) // gRPC Server Reflection is used by gRPC CLI
93-
helloworld.RegisterGreeterServer(grpcServer, &vSwarmServer{})
94-
_ = grpcServer.Serve(lis)
95-
}
96-
9771
func TestGRPCClientWithServerUnreachable(t *testing.T) {
9872
cfg := createFakeLoaderConfiguration()
9973
cfg.EnableZipkinTracing = true
@@ -161,7 +135,7 @@ func TestVSwarmClientWithServerReachable(t *testing.T) {
161135
address, port := "localhost", 18081
162136
testFunction.Endpoint = fmt.Sprintf("%s:%d", address, port)
163137

164-
go startVSwarmGRPCServer(address, port)
138+
go vswarm.StartVSwarmGRPCServer(address, port)
165139
time.Sleep(2 * time.Second)
166140

167141
cfgSwarm := createFakeVSwarmLoaderConfiguration()

0 commit comments

Comments
 (0)