mirror of
https://github.com/kata-containers/kata-containers.git
synced 2025-10-22 20:39:41 +00:00
Callers can use setProxy to ask agent to use an existing proxy. agent is modified to rely on its state.URL to tell if an its proxy is a valid one. And startProxy will skip a valid proxy since it is already started. Signed-off-by: Peng Tao <bergwolf@gmail.com>
51 lines
921 B
Go
51 lines
921 B
Go
// Copyright (c) 2018 HyperHQ Inc.
|
|
//
|
|
// SPDX-License-Identifier: Apache-2.0
|
|
//
|
|
|
|
package virtcontainers
|
|
|
|
import (
|
|
"testing"
|
|
|
|
"github.com/sirupsen/logrus"
|
|
"github.com/stretchr/testify/assert"
|
|
)
|
|
|
|
func TestKataBuiltinProxy(t *testing.T) {
|
|
assert := assert.New(t)
|
|
|
|
p := kataBuiltInProxy{}
|
|
|
|
params := proxyParams{}
|
|
|
|
err := p.validateParams(params)
|
|
assert.NotNil(err)
|
|
|
|
params.id = "foobarproxy"
|
|
err = p.validateParams(params)
|
|
assert.NotNil(err)
|
|
|
|
params.agentURL = "foobaragent"
|
|
err = p.validateParams(params)
|
|
assert.NotNil(err)
|
|
|
|
params.consoleURL = "foobarconsole"
|
|
err = p.validateParams(params)
|
|
assert.NotNil(err)
|
|
|
|
params.logger = logrus.WithField("proxy", params.id)
|
|
err = p.validateParams(params)
|
|
assert.Nil(err)
|
|
|
|
buildinProxyConsoleProto = "foobarproto"
|
|
_, _, err = p.start(params)
|
|
assert.NotNil(err)
|
|
assert.Empty(p.sandboxID)
|
|
|
|
err = p.stop(0)
|
|
assert.Nil(err)
|
|
|
|
assert.False(p.consoleWatched())
|
|
}
|