mirror of
https://github.com/fatedier/frp.git
synced 2026-01-11 22:23:12 +00:00
more e2e test cases (#2450)
This commit is contained in:
@@ -10,10 +10,6 @@ import (
|
||||
"github.com/fatedier/frp/test/e2e/pkg/process"
|
||||
)
|
||||
|
||||
func GenerateConfigFile(path string, content string) error {
|
||||
return ioutil.WriteFile(path, []byte(content), 0666)
|
||||
}
|
||||
|
||||
// RunProcesses run multiple processes from templates.
|
||||
// The first template should always be frps.
|
||||
func (f *Framework) RunProcesses(serverTemplates []string, clientTemplates []string) {
|
||||
@@ -37,7 +33,8 @@ func (f *Framework) RunProcesses(serverTemplates []string, clientTemplates []str
|
||||
err = ioutil.WriteFile(path, []byte(outs[i]), 0666)
|
||||
ExpectNoError(err)
|
||||
flog.Trace("[%s] %s", path, outs[i])
|
||||
p := process.New(TestContext.FRPServerPath, []string{"-c", path})
|
||||
|
||||
p := process.NewWithEnvs(TestContext.FRPServerPath, []string{"-c", path}, f.osEnvs)
|
||||
f.serverConfPaths = append(f.serverConfPaths, path)
|
||||
f.serverProcesses = append(f.serverProcesses, p)
|
||||
err = p.Start()
|
||||
@@ -51,7 +48,8 @@ func (f *Framework) RunProcesses(serverTemplates []string, clientTemplates []str
|
||||
err = ioutil.WriteFile(path, []byte(outs[index]), 0666)
|
||||
ExpectNoError(err)
|
||||
flog.Trace("[%s] %s", path, outs[index])
|
||||
p := process.New(TestContext.FRPClientPath, []string{"-c", path})
|
||||
|
||||
p := process.NewWithEnvs(TestContext.FRPClientPath, []string{"-c", path}, f.osEnvs)
|
||||
f.clientConfPaths = append(f.clientConfPaths, path)
|
||||
f.clientProcesses = append(f.clientProcesses, p)
|
||||
err = p.Start()
|
||||
@@ -60,3 +58,34 @@ func (f *Framework) RunProcesses(serverTemplates []string, clientTemplates []str
|
||||
}
|
||||
time.Sleep(500 * time.Millisecond)
|
||||
}
|
||||
|
||||
func (f *Framework) RunFrps(args ...string) (*process.Process, string, error) {
|
||||
p := process.NewWithEnvs(TestContext.FRPServerPath, args, f.osEnvs)
|
||||
f.serverProcesses = append(f.serverProcesses, p)
|
||||
err := p.Start()
|
||||
if err != nil {
|
||||
return p, p.StdOutput(), err
|
||||
}
|
||||
// sleep for a while to get std output
|
||||
time.Sleep(500 * time.Millisecond)
|
||||
return p, p.StdOutput(), nil
|
||||
}
|
||||
|
||||
func (f *Framework) RunFrpc(args ...string) (*process.Process, string, error) {
|
||||
p := process.NewWithEnvs(TestContext.FRPClientPath, args, f.osEnvs)
|
||||
f.clientProcesses = append(f.clientProcesses, p)
|
||||
err := p.Start()
|
||||
if err != nil {
|
||||
return p, p.StdOutput(), err
|
||||
}
|
||||
time.Sleep(500 * time.Millisecond)
|
||||
return p, p.StdOutput(), nil
|
||||
}
|
||||
|
||||
func (f *Framework) GenerateConfigFile(content string) string {
|
||||
f.configFileIndex++
|
||||
path := filepath.Join(f.TempDirectory, fmt.Sprintf("frp-e2e-config-%d", f.configFileIndex))
|
||||
err := ioutil.WriteFile(path, []byte(content), 0666)
|
||||
ExpectNoError(err)
|
||||
return path
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user