Skip to content

Commit e9aab93

Browse files
authored
Merge branch 'main' into dev/storage
2 parents 971d224 + 1f23f2f commit e9aab93

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

42 files changed

+1845
-961
lines changed

.github/workflows/go.yml

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,9 @@ jobs:
2222
go-version: '1.24'
2323

2424
- name: Build
25-
run: go build -v ./...
25+
run: |
26+
go generate ./...
27+
go build -v ./...
2628
2729
- name: Test
2830
run: go test -v ./...

.gitignore

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,4 @@
11
.idea
2-
testing_system
2+
testing_system
3+
cp.sh
4+
swag

common/config/invoker.go

Lines changed: 15 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,21 +1,28 @@
11
package config
22

3+
import "time"
4+
35
type InvokerConfig struct {
6+
// PublicAddress defines address for public access to invoker from master if the server is set up locally with some proxy
7+
PublicAddress *string `yaml:"PublicAddress,omitempty"`
8+
49
Threads uint64 `yaml:"Threads"`
510
Sandboxes uint64 `yaml:"Sandboxes"`
611
QueueSize uint64 `yaml:"QueueSize"`
712

813
SandboxType string `yaml:"SandboxType"`
914
SandboxHomePath string `yaml:"SandboxHomePath"`
1015

16+
MasterPingInterval time.Duration `yaml:"MasterPingInterval"`
17+
1118
CacheSize uint64 `yaml:"CacheSize"`
1219
CachePath string `yaml:"CachePath"`
1320

1421
SaveOutputHead *uint64 `yaml:"SaveOutputHead,omitempty"`
1522

1623
CompilerConfigsFolder string `yaml:"CompilerConfigsFolder"`
1724

18-
CheckerLimits *RunConfig `yaml:"CheckerLimits,omitempty"`
25+
CheckerLimits *RunLimitsConfig `yaml:"CheckerLimits,omitempty"`
1926
}
2027

2128
func FillInInvokerConfig(config *InvokerConfig) {
@@ -36,10 +43,15 @@ func FillInInvokerConfig(config *InvokerConfig) {
3643
switch config.SandboxType {
3744
case "simple":
3845
panic("No sandbox home path specified")
46+
case "isolate":
47+
panic("No isolate home path specified (it is used for meta files)")
3948
default:
4049
panic("unsupported sandbox type: " + config.SandboxType)
4150
}
4251
}
52+
if config.MasterPingInterval == 0 {
53+
config.MasterPingInterval = time.Second * 10
54+
}
4355
if len(config.CachePath) == 0 {
4456
panic("No invoker cache path specified")
4557
}
@@ -51,7 +63,7 @@ func FillInInvokerConfig(config *InvokerConfig) {
5163
}
5264

5365
if config.CheckerLimits == nil {
54-
config.CheckerLimits = &RunConfig{}
66+
config.CheckerLimits = &RunLimitsConfig{}
5567
}
56-
fillInDefaultCheckerRunConfig(config.CheckerLimits)
68+
fillInDefaultCheckerRunLimitsConfig(config.CheckerLimits)
5769
}

common/config/run_config.go

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

common/config/run_limits_config.go

Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
package config
2+
3+
import "testing_system/lib/customfields"
4+
5+
type RunLimitsConfig struct {
6+
TimeLimit customfields.Time `yaml:"TimeLimit" json:"TimeLimit"`
7+
MemoryLimit customfields.Memory `yaml:"MemoryLimit" json:"MemoryLimit"`
8+
WallTimeLimit customfields.Time `yaml:"WallTimeLimit" json:"WallTimeLimit"`
9+
10+
// MaxThreads specifies max number of threads and/or processes.
11+
// If MaxThreads is unspecified (equals 0) it is considered as 1.
12+
// If MaxThreads = -1, any number of threads is allowed
13+
MaxThreads int64 `yaml:"MaxThreads" json:"MaxThreads"`
14+
15+
// MaxOpenFiles specifies max number of files, opened by process
16+
// If MaxOpenFiles is unspecified (equals 0), it is considered as 64
17+
MaxOpenFiles uint64 `yaml:"MaxOpenFiles" json:"MaxOpenFiles"`
18+
19+
// MaxOutputSize specifies max output in EACH file.
20+
// If MaxOpenFiles is unspecified (equals 0), it is considered as 1g
21+
MaxOutputSize customfields.Memory `yaml:"MaxOutputSize" json:"MaxOutputSize"`
22+
}
23+
24+
func fillInDefaultCheckerRunLimitsConfig(config *RunLimitsConfig) {
25+
if config.TimeLimit == 0 {
26+
config.TimeLimit.FromStr("15s")
27+
}
28+
if config.MemoryLimit == 0 {
29+
config.MemoryLimit.FromStr("1g")
30+
}
31+
if config.WallTimeLimit == 0 {
32+
config.WallTimeLimit.FromStr("30s")
33+
}
34+
if config.MaxOpenFiles == 0 {
35+
config.MaxOpenFiles = 64
36+
}
37+
if config.MaxOutputSize == 0 {
38+
config.MaxOutputSize.FromStr("1g")
39+
}
40+
}
Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,11 @@
11
package invokerconn
22

33
import (
4-
"github.com/go-resty/resty/v2"
54
"testing_system/common/config"
65
"testing_system/common/connectors"
76
"testing_system/lib/connector"
7+
8+
"github.com/go-resty/resty/v2"
89
)
910

1011
type Connector struct {
@@ -15,15 +16,15 @@ func NewConnector(connection *config.Connection) *Connector {
1516
return &Connector{connectors.NewConnectorBase(connection)}
1617
}
1718

18-
func (c *Connector) Status() (*StatusResponse, error) {
19+
func (c *Connector) Status() (*Status, error) {
1920
r := c.connection.R()
2021

21-
return connector.Receive[StatusResponse](r, "/invoker/status", resty.MethodGet)
22+
return connector.Receive[Status](r, "/invoker/status", resty.MethodGet)
2223
}
2324

24-
func (c *Connector) NewJob(job *Job) (*StatusResponse, error) {
25+
func (c *Connector) NewJob(job *Job) (*Status, error) {
2526
r := c.connection.R()
2627
r.SetBody(job)
2728

28-
return connector.Receive[StatusResponse](r, "/invoker/job/new", resty.MethodPost)
29+
return connector.Receive[Status](r, "/invoker/job/new", resty.MethodPost)
2930
}

common/connectors/invokerconn/structs.go

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -16,9 +16,9 @@ type Job struct {
1616
// TODO: Add job dependency
1717
}
1818

19-
type StatusResponse struct {
20-
// TODO: add some information about invoker state
19+
type Status struct {
2120
MaxNewJobs uint64 `json:"MaxNewJobs"`
2221
ActiveJobIDs []string `json:"ActiveJobIDs"`
23-
Epoch int `json:"Epoch"`
22+
Epoch string `json:"Epoch"`
23+
Address string `json:"Address"`
2424
}
Lines changed: 22 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,32 @@
11
package masterconn
22

3-
import "testing_system/common/config"
3+
import (
4+
"testing_system/common/config"
5+
"testing_system/common/connectors"
6+
"testing_system/common/connectors/invokerconn"
7+
"testing_system/lib/connector"
8+
9+
"github.com/go-resty/resty/v2"
10+
)
411

512
type Connector struct {
6-
// TODO: Add master connection
13+
connection *connectors.ConnectorBase
714
}
815

916
func NewConnector(connection *config.Connection) *Connector {
10-
return nil
17+
return &Connector{connectors.NewConnectorBase(connection)}
1118
}
1219

13-
func (c *Connector) InvokerJobResult(result *InvokerJobResult) error {
14-
return nil
20+
func (c *Connector) SendInvokerJobResult(result *InvokerJobResult) error {
21+
r := c.connection.R()
22+
r.SetBody(result)
23+
24+
return connector.ReceiveEmpty(r, "/master/invoker/job-result", resty.MethodPost)
25+
}
26+
27+
func (c *Connector) SendInvokerStatus(response *invokerconn.Status) error {
28+
r := c.connection.R()
29+
r.SetBody(response)
30+
31+
return connector.ReceiveEmpty(r, "/master/invoker/status", resty.MethodPost)
1532
}

common/connectors/masterconn/structs.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ type InvokerJobResult struct {
1616

1717
Statistics *JobResultStatistics `json:"Statistics"`
1818

19-
InvokerStatus *invokerconn.StatusResponse `json:"InvokerStatus"`
19+
InvokerStatus *invokerconn.Status `json:"InvokerStatus"`
2020
}
2121

2222
type JobResultStatistics struct {

common/constants/resource/resource_type.go

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
1-
package resource
1+
//go:generate go run golang.org/x/tools/cmd/stringer@latest -type=Type
2+
//go:generate go run golang.org/x/tools/cmd/stringer@latest -type=DataType
23

3-
//go:generate stringer -type=Type
4-
//go:generate stringer -type=DataType
4+
package resource
55

66
type Type int
77

0 commit comments

Comments
 (0)