Skip to content

Commit eb17a29

Browse files
committed
Changed JSON trace parser to include struct instead of interface
Signed-off-by: aryans1204 <arshar1204@gmail.com> Fixed loader e2e tests Signed-off-by: aryans1204 <arshar1204@gmail.com>
1 parent 55de8be commit eb17a29

File tree

7 files changed

+55
-1033
lines changed

7 files changed

+55
-1033
lines changed

.github/workflows/e2e.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -86,7 +86,7 @@ jobs:
8686
run: go run cmd/loader.go --config pkg/config/test_vswarm_config.json
8787

8888
- 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)
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) -le 1 # test the output file for errors (true means failure to invoke)
9090

9191
- name: Print logs
9292
if: ${{ always() }}

.github/workflows/e2e_loader.yaml

Lines changed: 29 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ jobs:
3939
run: go run cmd/loader.go --config pkg/config/test_config.json
4040

4141
- name: Check the output
42-
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)
42+
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)
4343

4444
- name: Print logs
4545
if: ${{ always() }}
@@ -54,4 +54,31 @@ jobs:
5454
- name: Down
5555
if: ${{ always() }}
5656
run: |
57-
kn service delete --all
57+
kn service delete --all
58+
59+
- name: Untar vSwarm YAMLs
60+
if: ${{ always() }}
61+
run: |
62+
tar -xzvf workloads/container/yamls.tar.gz -C workloads/container/
63+
- name: Run vSwarm loader
64+
run: go run cmd/loader.go --config pkg/config/test_vswarm_config.json
65+
66+
- name: Check vSwarm output
67+
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) -le 1 # test the output file for errors (true means failure to invoke)
68+
69+
- name: Print logs
70+
if: ${{ always() }}
71+
run: |
72+
set -x
73+
container_list=$(kubectl get pods -n default -o jsonpath="{.items[*].spec.containers[*].name}")
74+
for container_name in $container_list
75+
do
76+
kubectl logs -n default -c $container_name -l serving.knative.dev/service=${{ matrix.service }}
77+
done
78+
- name: Down
79+
if: ${{ always() }}
80+
run: |
81+
kn service delete --all
82+
83+
84+

pkg/common/trace_types.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -111,8 +111,8 @@ type Function struct {
111111
MemoryRequestsMiB int
112112
CPULimitsMilli int
113113
YAMLPath string
114-
PreDeploymentCommands []interface{}
115-
Specification *FunctionSpecification
114+
PredeploymentPath []string
115+
Specification *FunctionSpecification
116116

117117
// used only for dirigent workflows
118118
WorkflowMetadata *WorkflowMetadata

pkg/trace/deploy_info.json

Lines changed: 0 additions & 1020 deletions
This file was deleted.

pkg/trace/mapper_trace_parser.go

Lines changed: 13 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,13 @@ type MapperTraceParser struct {
1717
functionNameGenerator *rand.Rand
1818
}
1919

20+
type DeploymentInfo struct {
21+
YamlLocation string
22+
PredeploymentCommands []string
23+
}
24+
25+
type JSONParser map[string]DeploymentInfo
26+
2027
func NewMapperParser(directoryPath string, totalDuration int) *MapperTraceParser {
2128
return &MapperTraceParser{
2229
DirectoryPath: directoryPath,
@@ -26,7 +33,7 @@ func NewMapperParser(directoryPath string, totalDuration int) *MapperTraceParser
2633
}
2734
}
2835

29-
func (p *MapperTraceParser) extractFunctions(mapperOutput map[string]map[string]string, deploymentInfo map[string]map[string]interface{}, dirPath string) []*common.Function {
36+
func (p *MapperTraceParser) extractFunctions(mapperOutput map[string]map[string]string, deploymentInfo JSONParser, dirPath string) []*common.Function {
3037
var result []*common.Function
3138
invocations := parseInvocationTrace(dirPath+"/invocations.csv", p.duration)
3239
runtime := parseRuntimeTrace(dirPath + "/durations.csv")
@@ -38,8 +45,8 @@ func (p *MapperTraceParser) extractFunctions(mapperOutput map[string]map[string]
3845
invocationStats := (*invocations)[i]
3946
hashFunction := invocationStats.HashFunction
4047
proxyFunction := mapperOutput[hashFunction]["proxy-function"]
41-
yamlPath := deploymentInfo[proxyFunction]["yaml-location"].(string)
42-
preDeploymentCommands := deploymentInfo[proxyFunction]["predeployment-commands"].([]interface{})
48+
yamlPath := deploymentInfo[proxyFunction].YamlLocation
49+
preDeploymentCommands := deploymentInfo[proxyFunction].PredeploymentCommands
4350

4451
function := &common.Function{
4552
Name: fmt.Sprintf("%s-%d-%d", proxyFunction, i, p.functionNameGenerator.Uint64()),
@@ -57,12 +64,12 @@ func (p *MapperTraceParser) extractFunctions(mapperOutput map[string]map[string]
5764
func (p *MapperTraceParser) Parse() []*common.Function {
5865
var functions []*common.Function
5966
var mapperOutput map[string]map[string]string // HashFunction mapped to vSwarm function yaml.
60-
var deploymentInfo map[string]map[string]interface{}
67+
var deploymentInfo JSONParser
6168
// Read the deployment info file for yaml locations and predeployment commands if any
62-
deploymentInfoFile, err := os.ReadFile("deploy_info.json")
69+
deploymentInfoFile, err := os.ReadFile("test_data/test_deploy_info.json")
6370
if err != nil {
6471
wd, _ := os.Getwd()
65-
deploymentInfoFile, err = os.ReadFile(wd + "/pkg/trace/deploy_info.json")
72+
deploymentInfoFile, err = os.ReadFile(wd + "/workloads/container/yamls/deploy_info.json")
6673
if err != nil {
6774
log.Warn("No deployment info file")
6875
}
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
{
2+
"cartservice": {
3+
"YamlLocation": "workloads/container/yamls/online-shop/kn-cartservice.yaml",
4+
"PredeploymentCommands": [
5+
"kubectl apply -f workloads/container/yamls/online-shop/database.yaml"
6+
]
7+
}
8+
}

workloads/container/yamls.tar.gz

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
11
version https://git-lfs.github.com/spec/v1
2-
oid sha256:f75b56ca0a51bb48c2db27fe9bdfdf13d442a372121c03d1046ebddd56b5c2c9
3-
size 24024
2+
oid sha256:f9668c376425a77a640153d8a0b164fc123b90c22d65cc5b382e4c3f529ec125
3+
size 24156

0 commit comments

Comments
 (0)