@@ -1080,67 +1080,69 @@ var _ = Describe("Simulator", func() {
10801080 })
10811081 })
10821082
1083- It ("Should return correct response to /tokenize chat" , func () {
1084- ctx := context .TODO ()
1085- tmpDir := "./tmp/"
1086- //nolint
1087- defer os .RemoveAll (tmpDir )
1088- args := []string {"cmd" , "--model" , qwenModelName , "--mode" , common .ModeRandom ,
1089- "--tokenizers-cache-dir" , tmpDir }
1090- client , err := startServerWithArgs (ctx , common .ModeRandom , args , nil )
1091- Expect (err ).NotTo (HaveOccurred ())
1083+ Context ("tokenize" , Ordered , func () {
1084+ tmpDir := "./tests-tmp/"
1085+ AfterAll (func () {
1086+ err := os .RemoveAll (tmpDir )
1087+ Expect (err ).NotTo (HaveOccurred ())
1088+ })
10921089
1093- reqBody := `{
1090+ It ("Should return correct response to /tokenize chat" , func () {
1091+ ctx := context .TODO ()
1092+ args := []string {"cmd" , "--model" , qwenModelName , "--mode" , common .ModeRandom ,
1093+ "--tokenizers-cache-dir" , tmpDir , "--max-model-len" , "2048" }
1094+ client , err := startServerWithArgs (ctx , common .ModeRandom , args , nil )
1095+ Expect (err ).NotTo (HaveOccurred ())
1096+
1097+ reqBody := `{
10941098 "messages": [{"role": "user", "content": "This is a test"}],
10951099 "model": "Qwen/Qwen2-0.5B"
10961100 }`
1097- resp , err := client .Post ("http://localhost/tokenize" , "application/json" , strings .NewReader (reqBody ))
1098- Expect (err ).NotTo (HaveOccurred ())
1099- defer func () {
1100- err := resp .Body .Close ()
1101+ resp , err := client .Post ("http://localhost/tokenize" , "application/json" , strings .NewReader (reqBody ))
11011102 Expect (err ).NotTo (HaveOccurred ())
1102- }()
1103+ defer func () {
1104+ err := resp .Body .Close ()
1105+ Expect (err ).NotTo (HaveOccurred ())
1106+ }()
11031107
1104- body , err := io .ReadAll (resp .Body )
1105- Expect (err ).NotTo (HaveOccurred ())
1108+ body , err := io .ReadAll (resp .Body )
1109+ Expect (err ).NotTo (HaveOccurred ())
11061110
1107- var tokenizeResp vllmapi.TokenizeResponse
1108- err = json .Unmarshal (body , & tokenizeResp )
1109- Expect (err ).NotTo (HaveOccurred ())
1110- Expect (tokenizeResp .Count ).To (Equal (4 ))
1111- Expect (tokenizeResp .Tokens ).To (HaveLen (4 ))
1112- Expect (tokenizeResp .MaxModelLen ).To (Equal (1024 ))
1113- })
1111+ var tokenizeResp vllmapi.TokenizeResponse
1112+ err = json .Unmarshal (body , & tokenizeResp )
1113+ Expect (err ).NotTo (HaveOccurred ())
1114+ Expect (tokenizeResp .Count ).To (Equal (4 ))
1115+ Expect (tokenizeResp .Tokens ).To (HaveLen (4 ))
1116+ Expect (tokenizeResp .MaxModelLen ).To (Equal (2048 ))
1117+ })
11141118
1115- It ("Should return correct response to /tokenize text" , func () {
1116- ctx := context .TODO ()
1117- tmpDir := "./tmp/"
1118- //nolint
1119- defer os .RemoveAll (tmpDir )
1120- args := []string {"cmd" , "--model" , qwenModelName , "--mode" , common .ModeRandom ,
1121- "--tokenizers-cache-dir" , tmpDir }
1122- client , err := startServerWithArgs (ctx , common .ModeRandom , args , nil )
1123- Expect (err ).NotTo (HaveOccurred ())
1119+ It ("Should return correct response to /tokenize text" , func () {
1120+ ctx := context .TODO ()
1121+ args := []string {"cmd" , "--model" , qwenModelName , "--mode" , common .ModeRandom ,
1122+ "--tokenizers-cache-dir" , tmpDir , "--max-model-len" , "2048" }
1123+ client , err := startServerWithArgs (ctx , common .ModeRandom , args , nil )
1124+ Expect (err ).NotTo (HaveOccurred ())
11241125
1125- reqBody := `{
1126+ reqBody := `{
11261127 "prompt": "This is a test",
11271128 "model": "Qwen/Qwen2-0.5B"
11281129 }`
1129- resp , err := client .Post ("http://localhost/tokenize" , "application/json" , strings .NewReader (reqBody ))
1130- Expect (err ).NotTo (HaveOccurred ())
1131- defer func () {
1132- err := resp .Body .Close ()
1130+ resp , err := client .Post ("http://localhost/tokenize" , "application/json" , strings .NewReader (reqBody ))
11331131 Expect (err ).NotTo (HaveOccurred ())
1134- }()
1132+ defer func () {
1133+ err := resp .Body .Close ()
1134+ Expect (err ).NotTo (HaveOccurred ())
1135+ }()
11351136
1136- body , err := io .ReadAll (resp .Body )
1137- Expect (err ).NotTo (HaveOccurred ())
1137+ body , err := io .ReadAll (resp .Body )
1138+ Expect (err ).NotTo (HaveOccurred ())
11381139
1139- var tokenizeResp vllmapi.TokenizeResponse
1140- err = json .Unmarshal (body , & tokenizeResp )
1141- Expect (err ).NotTo (HaveOccurred ())
1142- Expect (tokenizeResp .Count ).To (Equal (4 ))
1143- Expect (tokenizeResp .Tokens ).To (HaveLen (4 ))
1144- Expect (tokenizeResp .MaxModelLen ).To (Equal (1024 ))
1140+ var tokenizeResp vllmapi.TokenizeResponse
1141+ err = json .Unmarshal (body , & tokenizeResp )
1142+ Expect (err ).NotTo (HaveOccurred ())
1143+ Expect (tokenizeResp .Count ).To (Equal (4 ))
1144+ Expect (tokenizeResp .Tokens ).To (HaveLen (4 ))
1145+ Expect (tokenizeResp .MaxModelLen ).To (Equal (2048 ))
1146+ })
11451147 })
11461148})
0 commit comments