@@ -3,15 +3,19 @@ package main
3
3
import (
4
4
"context"
5
5
"net/http"
6
-
7
- // _ "net/http/pprof"
8
6
"os"
7
+ "strconv"
8
+ "time"
9
9
10
+ // _ "net/http/pprof"
10
11
"github.com/cranemont/iris/src/connector"
11
12
"github.com/cranemont/iris/src/connector/rabbitmq"
13
+ datasource "github.com/cranemont/iris/src/data_source"
14
+ "github.com/cranemont/iris/src/data_source/cache"
15
+ fileDataSource "github.com/cranemont/iris/src/data_source/file"
16
+ httpserver "github.com/cranemont/iris/src/data_source/http_server"
12
17
"github.com/cranemont/iris/src/handler"
13
18
"github.com/cranemont/iris/src/router"
14
- "github.com/cranemont/iris/src/service/cache"
15
19
"github.com/cranemont/iris/src/service/file"
16
20
"github.com/cranemont/iris/src/service/logger"
17
21
"github.com/cranemont/iris/src/service/sandbox"
@@ -41,12 +45,25 @@ func main() {
41
45
ctx := context .Background ()
42
46
cache := cache .NewCache (ctx )
43
47
44
- // source := testcase.NewPreset()
45
- source := testcase .NewServer (
46
- os .Getenv ("TESTCASE_SERVER_URL" ),
47
- os .Getenv ("TESTCASE_SERVER_AUTH_TOKEN" ),
48
- )
49
- testcaseManager := testcase .NewManager (source , cache )
48
+ var dataSource datasource.Read
49
+ serverUrl := os .Getenv ("TESTCASE_SERVER_URL" )
50
+ if serverUrl == "" {
51
+ dataSource = fileDataSource .NewFileDataSource (os .DirFS ("./testcase" ))
52
+ logProvider .Log (logger .INFO , "Cannot find TESTCASE_SERVER_URL. It will read testcase from the \" ./testcase\" directory" )
53
+ } else {
54
+ timeout , err := strconv .Atoi (utils .Getenv ("TESTCASE_SERVER_TIMEOUT" , "5" ))
55
+ if err != nil {
56
+ timeout = 5
57
+ }
58
+ dataSource = httpserver .NewHttpServerDataSource (
59
+ serverUrl ,
60
+ utils .Getenv ("TESTCASE_SERVER_URL_PLACEHOLDER" , ":id" ),
61
+ utils .Getenv ("TESTCASE_SERVER_AUTH_TOKEN" , "iris" ),
62
+ utils .Getenv ("TESTCASE_SERVER_AUTH_HEADER" , "Authorization" ),
63
+ time .Second * time .Duration (timeout ),
64
+ )
65
+ }
66
+ testcaseManager := testcase .NewTestcaseManager (dataSource , cache )
50
67
51
68
fileManager := file .NewFileManager ("/app/sandbox/results" )
52
69
langConfig := sandbox .NewLangConfig (fileManager , "/app/sandbox/policy/java_policy" )
0 commit comments