Skip to content

Commit 64ccf99

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 66f7343 commit 64ccf99

File tree

12 files changed

+399
-74
lines changed

12 files changed

+399
-74
lines changed

.github/workflows/e2e.yaml

Lines changed: 27 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,7 @@ jobs:
6262
run: go run cmd/loader.go --config pkg/config/test_config.json
6363

6464
- name: Check the output
65-
run: test -f "data/out/experiment_duration_5.csv" && test $(cat data/out/experiment_duration_5.csv | wc -l) -gt 1 && test $(grep true data/out/experiment_duration_5.csv | wc -l) -eq 0 # test the output file for errors (true means failure to invoke)
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)
6666

6767
- name: Print logs
6868
if: ${{ always() }}
@@ -76,4 +76,29 @@ jobs:
7676
- name: Down
7777
if: ${{ always() }}
7878
run: |
79-
kn service delete --all
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
@@ -194,7 +194,7 @@ func runTraceMode(cfg *config.LoaderConfiguration, readIATFromFile bool, writeIA
194194
}
195195

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

pkg/config/parser_test.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,7 @@ func TestConfigParser(t *testing.T) {
5353
!strings.HasPrefix(config.OutputPathPrefix, "data/out/experiment") ||
5454
config.IATDistribution != "equidistant" ||
5555
config.CPULimit != "1vCPU" ||
56-
config.ExperimentDuration != 5 ||
56+
config.ExperimentDuration != 2 ||
5757
config.WarmupDuration != 0 ||
5858
config.IsPartiallyPanic != false ||
5959
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)