Skip to content

Commit 339d5a5

Browse files
committed
feat: datasource 수정사항 main에 적용
1 parent 9456540 commit 339d5a5

File tree

1 file changed

+26
-9
lines changed

1 file changed

+26
-9
lines changed

main.go

Lines changed: 26 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -3,15 +3,19 @@ package main
33
import (
44
"context"
55
"net/http"
6-
7-
// _ "net/http/pprof"
86
"os"
7+
"strconv"
8+
"time"
99

10+
// _ "net/http/pprof"
1011
"github.com/cranemont/iris/src/connector"
1112
"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"
1217
"github.com/cranemont/iris/src/handler"
1318
"github.com/cranemont/iris/src/router"
14-
"github.com/cranemont/iris/src/service/cache"
1519
"github.com/cranemont/iris/src/service/file"
1620
"github.com/cranemont/iris/src/service/logger"
1721
"github.com/cranemont/iris/src/service/sandbox"
@@ -41,12 +45,25 @@ func main() {
4145
ctx := context.Background()
4246
cache := cache.NewCache(ctx)
4347

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)
5067

5168
fileManager := file.NewFileManager("/app/sandbox/results")
5269
langConfig := sandbox.NewLangConfig(fileManager, "/app/sandbox/policy/java_policy")

0 commit comments

Comments
 (0)