2024-05-23 20:48:12 +00:00
|
|
|
package config
|
2023-05-30 11:01:55 +00:00
|
|
|
|
|
|
|
import (
|
|
|
|
"os"
|
|
|
|
|
|
|
|
. "github.com/onsi/ginkgo/v2"
|
|
|
|
. "github.com/onsi/gomega"
|
|
|
|
)
|
|
|
|
|
|
|
|
var _ = Describe("Test cases for config related functions", func() {
|
|
|
|
|
|
|
|
var (
|
|
|
|
configFile string
|
|
|
|
)
|
|
|
|
|
|
|
|
Context("Test Read configuration functions", func() {
|
|
|
|
configFile = os.Getenv("CONFIG_FILE")
|
2024-05-23 20:48:12 +00:00
|
|
|
It("Test readConfigFile", func() {
|
|
|
|
config, err := readMultipleBackendConfigsFromFile(configFile)
|
2023-05-30 11:01:55 +00:00
|
|
|
Expect(err).To(BeNil())
|
|
|
|
Expect(config).ToNot(BeNil())
|
|
|
|
// two configs in config.yaml
|
2023-06-01 14:20:45 +00:00
|
|
|
Expect(config[0].Name).To(Equal("list1"))
|
|
|
|
Expect(config[1].Name).To(Equal("list2"))
|
2023-05-30 11:01:55 +00:00
|
|
|
})
|
|
|
|
|
2023-06-01 14:20:45 +00:00
|
|
|
It("Test LoadConfigs", func() {
|
2024-05-23 20:48:12 +00:00
|
|
|
|
|
|
|
bcl := NewBackendConfigLoader()
|
|
|
|
err := bcl.LoadBackendConfigsFromPath(os.Getenv("MODELS_PATH"))
|
|
|
|
|
2023-06-01 14:20:45 +00:00
|
|
|
Expect(err).To(BeNil())
|
2024-05-23 20:48:12 +00:00
|
|
|
configs := bcl.GetAllBackendConfigs()
|
|
|
|
loadedModelNames := []string{}
|
|
|
|
for _, v := range configs {
|
|
|
|
loadedModelNames = append(loadedModelNames, v.Name)
|
|
|
|
}
|
|
|
|
Expect(configs).ToNot(BeNil())
|
2023-06-01 14:20:45 +00:00
|
|
|
|
2024-05-23 20:48:12 +00:00
|
|
|
Expect(loadedModelNames).To(ContainElements("code-search-ada-code-001"))
|
2023-06-01 14:20:45 +00:00
|
|
|
|
|
|
|
// config should includes text-embedding-ada-002 models's api.config
|
2024-05-23 20:48:12 +00:00
|
|
|
Expect(loadedModelNames).To(ContainElements("text-embedding-ada-002"))
|
2023-06-01 14:20:45 +00:00
|
|
|
|
|
|
|
// config should includes rwkv_test models's api.config
|
2024-05-23 20:48:12 +00:00
|
|
|
Expect(loadedModelNames).To(ContainElements("rwkv_test"))
|
2023-06-01 14:20:45 +00:00
|
|
|
|
|
|
|
// config should includes whisper-1 models's api.config
|
2024-05-23 20:48:12 +00:00
|
|
|
Expect(loadedModelNames).To(ContainElements("whisper-1"))
|
2023-06-01 14:20:45 +00:00
|
|
|
})
|
2023-05-30 11:01:55 +00:00
|
|
|
})
|
|
|
|
})
|