+# The Kong Data plane provides the endpoint that Service Manager gives to the rApp so that the rApp can invoke the CAPIF published API.
+# In a Kubernetes environment, we need to use the Kong NodePort IP and nodePort if the rApp needs access from outside the Kong cluster.
+# From inside the Kong cluster, we can use the Kubernetes cluster DNS entry, kong-nonrtric-kong-proxy.nonrtric.svc.cluster.local.
KONG_DOMAIN=<string>
KONG_PROTOCOL=<http or https protocol scheme>
-KONG_IPV4=<host string>
-KONG_DATA_PLANE_PORT=<port number>
+KONG_CONTROL_PLANE_IPV4=<host string>
KONG_CONTROL_PLANE_PORT=<port number>
+KONG_DATA_PLANE_IPV4=<host string>
+KONG_DATA_PLANE_PORT=<port number>
CAPIF_PROTOCOL=<http or https protocol scheme>
CAPIF_IPV4=<host>
CAPIF_PORT=<port number>
LOG_LEVEL=<Trace, Debug, Info, Warning, Error, Fatal or Panic>
SERVICE_MANAGER_PORT=<port number>
TEST_SERVICE_IPV4=<host string>
-TEST_SERVICE_PORT=<port number>
\ No newline at end of file
+TEST_SERVICE_PORT=<port number>
# By default this file is in the docker build directory,
# but the location can configured in the JJB template.
---
-tag: 0.1.1
+tag: 0.1.2
spec:
containers:
- name: capifcore
- image: "nexus3.o-ran-sc.org:10004/o-ran-sc/nonrtric-plt-capifcore:1.3.1"
+ image: "nexus3.o-ran-sc.org:10004/o-ran-sc/nonrtric-plt-capifcore:CAPIF_VERSION"
imagePullPolicy: IfNotPresent
ports:
- containerPort: 8090
app: capifcore
ports:
- protocol: TCP
- port: 80
+ port: 8090
targetPort: 8090
nodePort: 31570
type: NodePort
spec:
containers:
- name: servicemanager
- image: "nexus3.o-ran-sc.org:10004/o-ran-sc/nonrtric-plt-servicemanager:0.1.1"
+ image: "nexus3.o-ran-sc.org:10004/o-ran-sc/nonrtric-plt-servicemanager:SERVICEMANAGER_VERSION"
imagePullPolicy: IfNotPresent
env:
- name: SERVICE_MANAGER_ENV
app: servicemanager
ports:
- protocol: TCP
- port: 80
+ port: 8095
targetPort: 8095
nodePort: 31575
type: NodePort
cp -v ../../.env.example ../../.env
sed -i 's/KONG_DOMAIN=<string>/KONG_DOMAIN=kong/' ../../.env
sed -i 's/KONG_PROTOCOL=<http or https protocol scheme>/KONG_PROTOCOL=http/' ../../.env
- sed -i 's/KONG_IPV4=<host string>/KONG_IPV4=10.101.1.101/' ../../.env
- sed -i 's/KONG_DATA_PLANE_PORT=<port number>/KONG_DATA_PLANE_PORT=32080/' ../../.env
- sed -i 's/KONG_CONTROL_PLANE_PORT=<port number>/KONG_CONTROL_PLANE_PORT=32081/' ../../.env
+ sed -i 's/KONG_CONTROL_PLANE_IPV4=<host string>/KONG_CONTROL_PLANE_IPV4=kong-kong-admin.kong.svc.cluster.local/' ../../.env
+ sed -i 's/KONG_CONTROL_PLANE_PORT=<port number>/KONG_CONTROL_PLANE_PORT=8001/' ../../.env
+ sed -i 's/KONG_DATA_PLANE_IPV4=<host string>/KONG_DATA_PLANE_IPV4=kong-kong-proxy.kong.svc.cluster.local/' ../../.env
+ sed -i 's/KONG_DATA_PLANE_PORT=<port number>/KONG_DATA_PLANE_PORT=80/' ../../.env
sed -i 's/CAPIF_PROTOCOL=<http or https protocol scheme>/CAPIF_PROTOCOL=http/' ../../.env
- sed -i 's/CAPIF_IPV4=<host>/CAPIF_IPV4=10.101.1.101/' ../../.env
- sed -i 's/CAPIF_PORT=<port number>/CAPIF_PORT=31570/' ../../.env
+ sed -i 's/CAPIF_IPV4=<host>/CAPIF_IPV4=capifcore.servicemanager.svc.cluster.local/' ../../.env
+ sed -i 's/CAPIF_PORT=<port number>/CAPIF_PORT=8090/' ../../.env
sed -i 's/LOG_LEVEL=<Trace, Debug, Info, Warning, Error, Fatal or Panic>/LOG_LEVEL=Info/' ../../.env
sed -i 's/SERVICE_MANAGER_PORT=<port number>/SERVICE_MANAGER_PORT=8095/' ../../.env
sed -i 's/TEST_SERVICE_IPV4=<host string>/TEST_SERVICE_IPV4=10.101.1.101/' ../../.env
fi
}
-substitute_repo(){
- echo "substitute_repo"
+substitute_repos(){
+ echo "substitute_repos"
docker_repo=$1
# Use our own Capificore and ServiceManager images
- sed -i "s/image: o-ran-sc.org\/nonrtric\/plt\/capifcore/image: $docker_repo\/capifcore:latest/" ../manifests/capifcore.yaml
- sed -i 's/imagePullPolicy: IfNotPresent/imagePullPolicy: Always/' ../manifests/capifcore.yaml
- sed -i "s/image: o-ran-sc.org\/nonrtric\/plt\/servicemanager/image: $docker_repo\/servicemanager:latest/" ../manifests/servicemanager.yaml
- sed -i 's/imagePullPolicy: IfNotPresent/imagePullPolicy: Always/' ../manifests/servicemanager.yaml
+ sed -i "s*nexus3.o-ran-sc.org:10004/o-ran-sc/nonrtric-plt-capifcore:CAPIF_VERSION*$docker_repo/capifcore:latest*" ../manifests/capifcore.yaml
+ sed -i "s*nexus3.o-ran-sc.org:10004/o-ran-sc/nonrtric-plt-servicemanager:SERVICEMANAGER_VERSION*$docker_repo/servicemanager:latest*" ../manifests/servicemanager.yaml
+
+ sed -i 's*imagePullPolicy: IfNotPresent*imagePullPolicy: Always*' ../manifests/capifcore.yaml
+ sed -i 's*imagePullPolicy: IfNotPresent*imagePullPolicy: Always*' ../manifests/servicemanager.yaml
+}
+
+substitute_repo_versions(){
+ echo "substitute_repo_versions"
+ servicemanager_version=$(awk '/tag:/{print $2}' ../../container-tag.yaml)
+ capif_version=$(awk '/tag:/{print $2}' ../../../capifcore/container-tag.yaml)
+ # Set the Capificore and ServiceManager image versions
+ sed -i "s*nexus3.o-ran-sc.org:10004/o-ran-sc/nonrtric-plt-capifcore:CAPIF_VERSION*nexus3.o-ran-sc.org:10004/o-ran-sc/nonrtric-plt-capifcore:$capif_version*" ../manifests/capifcore.yaml
+ sed -i "s*nexus3.o-ran-sc.org:10004/o-ran-sc/nonrtric-plt-servicemanager:SERVICEMANAGER_VERSION*nexus3.o-ran-sc.org:10004/o-ran-sc/nonrtric-plt-servicemanager:$servicemanager_version*" ../manifests/servicemanager.yaml
}
add_env(){
# Check if the development switch is enabled
if [ "$USE_OWN_REPO" = true ]; then
- substitute_repo $DOCKER_REPO
+ substitute_repos $DOCKER_REPO
+else
+ substitute_repo_versions
fi
kubectl create ns servicemanager
"oransc.org/nonrtric/servicemanager/internal/publishservice"
"oransc.org/nonrtric/capifcore"
- "oransc.org/nonrtric/servicemanager/mockkong"
+ mockKong "oransc.org/nonrtric/servicemanager/mockkong"
)
var (
- eServiceManager *echo.Echo
- eCapifWeb *echo.Echo
- eKong *echo.Echo
- mockConfigReader *envreader.MockConfigReader
+ eServiceManager *echo.Echo
+ eCapifWeb *echo.Echo
+ eKong *echo.Echo
+ mockConfigReader *envreader.MockConfigReader
serviceManagerServer *httptest.Server
- capifServer *httptest.Server
- mockKongServer *httptest.Server
+ capifServer *httptest.Server
+ mockKongServer *httptest.Server
)
func TestMain(m *testing.M) {
MockedConfig: map[string]string{
"KONG_DOMAIN": "kong",
"KONG_PROTOCOL": "http",
- "KONG_IPV4": mockKongHost,
- "KONG_DATA_PLANE_PORT": "32080",
+ "KONG_CONTROL_PLANE_IPV4": mockKongHost,
"KONG_CONTROL_PLANE_PORT": mockKongControlPlanePort,
+ "KONG_DATA_PLANE_IPV4": "10.101.1.101",
+ "KONG_DATA_PLANE_PORT": "32080",
"CAPIF_PROTOCOL": "http",
"CAPIF_IPV4": capifHost,
"CAPIF_PORT": capifPort,
}
}
-
-func capifCleanUp() {
+func capifCleanUp() {
t := new(testing.T) // Create a new testing.T instance for capifCleanUp
// Delete the invoker
// Check if the parsed array is empty
assert.Zero(t, len(resultServices))
- assert.True (t, len(resultServices) == 0)
+ assert.True(t, len(resultServices) == 0)
aefId := "AEF_id_rApp_Kong_as_AEF"
namespace := "namespace"
resultServiceIpv4 := *interfaceDescription.Ipv4Addr
resultServicePort := *interfaceDescription.Port
- kongIPv4 := common29122.Ipv4Addr(myEnv["KONG_IPV4"])
+ kongDataPlaneIPv4 := common29122.Ipv4Addr(myEnv["KONG_DATA_PLANE_IPV4"])
kongDataPlanePort := common29122.Port(myPorts["KONG_DATA_PLANE_PORT"])
- assert.NotEmpty(t, kongIPv4, "KONG_IPV4 is required in .env file for unit testing")
+ assert.NotEmpty(t, kongDataPlaneIPv4, "KONG_DATA_PLANE_IPV4 is required in .env file for unit testing")
assert.NotZero(t, kongDataPlanePort, "KONG_DATA_PLANE_PORT is required in .env file for unit testing")
- assert.Equal(t, kongIPv4, resultServiceIpv4)
+ assert.Equal(t, kongDataPlaneIPv4, resultServiceIpv4)
assert.Equal(t, kongDataPlanePort, resultServicePort)
// Check one service published
assert.NoError(t, err, "error unmarshaling response")
// Check if the parsed array has one item
- assert.True (t, len(resultServices) == 1)
+ assert.True(t, len(resultServices) == 1)
// Publish a second service for provider
apiName2 := "apiName2"
assert.NoError(t, err, "error unmarshaling response")
// Check if the parsed array has two items
- assert.True (t, len(resultServices) == 2)
+ assert.True(t, len(resultServices) == 2)
}
func TestOnboardInvoker(t *testing.T) {
capifPort := common29122.Port(myPorts["CAPIF_PORT"])
kongDomain := myEnv["KONG_DOMAIN"]
kongProtocol := myEnv["KONG_PROTOCOL"]
- kongIPv4 := common29122.Ipv4Addr(myEnv["KONG_IPV4"])
- kongDataPlanePort := common29122.Port(myPorts["KONG_DATA_PLANE_PORT"])
+ kongControlPlaneIPv4 := common29122.Ipv4Addr(myEnv["KONG_CONTROL_PLANE_IPV4"])
kongControlPlanePort := common29122.Port(myPorts["KONG_CONTROL_PLANE_PORT"])
+ kongDataPlaneIPv4 := common29122.Ipv4Addr(myEnv["KONG_DATA_PLANE_IPV4"])
+ kongDataPlanePort := common29122.Port(myPorts["KONG_DATA_PLANE_PORT"])
// Register ProviderManagement
providerManagerSwagger, err := provapi.GetSwagger()
publishServiceSwagger.Servers = nil
- ps := publishservice.NewPublishService(kongDomain, kongProtocol, kongIPv4, kongDataPlanePort, kongControlPlanePort, capifProtocol, capifIPv4, capifPort)
+ ps := publishservice.NewPublishService(
+ kongDomain, kongProtocol,
+ kongControlPlaneIPv4, kongControlPlanePort,
+ kongDataPlaneIPv4, kongDataPlanePort,
+ capifProtocol, capifIPv4, capifPort)
group = e.Group("/published-apis/v1")
group.Use(echomiddleware.Logger())
log.Infof("KONG_DOMAIN %s", myEnv["KONG_DOMAIN"])
log.Infof("KONG_PROTOCOL %s", myEnv["KONG_PROTOCOL"])
- log.Infof("KONG_IPV4 %s", myEnv["KONG_IPV4"])
- log.Infof("KONG_DATA_PLANE_PORT %s", myEnv["KONG_DATA_PLANE_PORT"])
+ log.Infof("KONG_CONTROL_PLANE_IPV4 %s", myEnv["KONG_CONTROL_PLANE_IPV4"])
log.Infof("KONG_CONTROL_PLANE_PORT %s", myEnv["KONG_CONTROL_PLANE_PORT"])
+ log.Infof("KONG_DATA_PLANE_IPV4 %s", myEnv["KONG_DATA_PLANE_IPV4"])
+ log.Infof("KONG_DATA_PLANE_PORT %s", myEnv["KONG_DATA_PLANE_PORT"])
log.Infof("CAPIF_PROTOCOL %s", myEnv["CAPIF_PROTOCOL"])
log.Infof("CAPIF_IPV4 %s", myEnv["CAPIF_IPV4"])
log.Infof("CAPIF_PORT %s", myEnv["CAPIF_PORT"])
"github.com/stretchr/testify/assert"
"oransc.org/nonrtric/capifcore"
- "oransc.org/nonrtric/servicemanager/mockkong"
+ mockKong "oransc.org/nonrtric/servicemanager/mockkong"
)
var (
- eServiceManager *echo.Echo
- eCapifWeb *echo.Echo
- eKong *echo.Echo
- mockConfigReader *envreader.MockConfigReader
+ eServiceManager *echo.Echo
+ eCapifWeb *echo.Echo
+ eKong *echo.Echo
+ mockConfigReader *envreader.MockConfigReader
serviceManagerServer *httptest.Server
- capifServer *httptest.Server
- mockKongServer *httptest.Server
+ capifServer *httptest.Server
+ mockKongServer *httptest.Server
)
func TestMain(m *testing.M) {
MockedConfig: map[string]string{
"KONG_DOMAIN": "kong",
"KONG_PROTOCOL": "http",
- "KONG_IPV4": mockKongHost,
- "KONG_DATA_PLANE_PORT": "32080",
+ "KONG_CONTROL_PLANE_IPV4": mockKongHost,
"KONG_CONTROL_PLANE_PORT": mockKongControlPlanePort,
+ "KONG_DATA_PLANE_IPV4": "10.101.1.101",
+ "KONG_DATA_PLANE_PORT": "32080",
"CAPIF_PROTOCOL": "http",
"CAPIF_IPV4": capifHost,
"CAPIF_PORT": capifPort,
}
}
-func capifCleanUp() {
+func capifCleanUp() {
t := new(testing.T) // Create a new testing.T instance for capifCleanUp
// Delete the invoker
resultServiceIpv4 := *interfaceDescription.Ipv4Addr
resultServicePort := *interfaceDescription.Port
- kongIPv4 := common29122.Ipv4Addr(myEnv["KONG_IPV4"])
+ kongDataPlaneIPv4 := common29122.Ipv4Addr(myEnv["KONG_DATA_PLANE_IPV4"])
kongDataPlanePort := common29122.Port(myPorts["KONG_DATA_PLANE_PORT"])
- assert.NotEmpty(t, kongIPv4, "KONG_IPV4 is required in .env file for unit testing")
+ assert.NotEmpty(t, kongDataPlaneIPv4, "KONG_DATA_PLANE_IPV4 is required in .env file for unit testing")
assert.NotZero(t, kongDataPlanePort, "KONG_DATA_PLANE_PORT is required in .env file for unit testing")
- assert.Equal(t, kongIPv4, resultServiceIpv4)
+ assert.Equal(t, kongDataPlaneIPv4, resultServiceIpv4)
assert.Equal(t, kongDataPlanePort, resultServicePort)
}
capifPort := common29122.Port(myPorts["CAPIF_PORT"])
kongDomain := myEnv["KONG_DOMAIN"]
kongProtocol := myEnv["KONG_PROTOCOL"]
- kongIPv4 := common29122.Ipv4Addr(myEnv["KONG_IPV4"])
- kongDataPlanePort := common29122.Port(myPorts["KONG_DATA_PLANE_PORT"])
+ kongControlPlaneIPv4 := common29122.Ipv4Addr(myEnv["KONG_CONTROL_PLANE_IPV4"])
kongControlPlanePort := common29122.Port(myPorts["KONG_CONTROL_PLANE_PORT"])
+ kongDataPlaneIPv4 := common29122.Ipv4Addr(myEnv["KONG_DATA_PLANE_IPV4"])
+ kongDataPlanePort := common29122.Port(myPorts["KONG_DATA_PLANE_PORT"])
// Register ProviderManagement
providerManagerSwagger, err := provapi.GetSwagger()
publishServiceSwagger.Servers = nil
- ps := publishservice.NewPublishService(kongDomain, kongProtocol, kongIPv4, kongDataPlanePort, kongControlPlanePort, capifProtocol, capifIPv4, capifPort)
+ ps := publishservice.NewPublishService(
+ kongDomain, kongProtocol,
+ kongControlPlaneIPv4, kongControlPlanePort,
+ kongDataPlaneIPv4, kongDataPlanePort,
+ capifProtocol, capifIPv4, capifPort)
group = e.Group("/published-apis/v1")
group.Use(echomiddleware.Logger())
func KongClear(myEnv map[string]string, myPorts map[string]int) error {
log.Info("delete only ServiceManager Kong routes and services")
- kongAdminApiUrl := fmt.Sprintf("%s://%s:%d/", myEnv["KONG_PROTOCOL"], myEnv["KONG_IPV4"], myPorts["KONG_CONTROL_PLANE_PORT"])
+ kongAdminApiUrl := fmt.Sprintf("%s://%s:%d/", myEnv["KONG_PROTOCOL"], myEnv["KONG_CONTROL_PLANE_IPV4"], myPorts["KONG_CONTROL_PLANE_PORT"])
err := deleteRoutes(kongAdminApiUrl)
if err != nil {
MockedConfig: map[string]string{
"KONG_DOMAIN": "kong",
"KONG_PROTOCOL": "http",
- "KONG_IPV4": mockKongHost,
+ "KONG_CONTROL_PLANE_IPV4": mockKongHost,
+ "KONG_CONTROL_PLANE_PORT": mockKongControlPlanePort,
+ "KONG_DATA_PLANE_IPV4": "10.101.1.101",
"KONG_DATA_PLANE_PORT": "32080",
- "KONG_CONTROL_PLANE_PORT": mockKongControlPlanePort,
"CAPIF_PROTOCOL": "http",
"CAPIF_IPV4": capifHost,
"CAPIF_PORT": capifPort,
type PublishService struct {
KongDomain string;
KongProtocol string;
- KongIPv4 common29122.Ipv4Addr;
- KongDataPlanePort common29122.Port;
KongControlPlanePort common29122.Port;
+ KongControlPlaneIPv4 common29122.Ipv4Addr;
+ KongDataPlaneIPv4 common29122.Ipv4Addr;
+ KongDataPlanePort common29122.Port;
CapifProtocol string;
CapifIPv4 common29122.Ipv4Addr;
CapifPort common29122.Port;
}
// Creates a service that implements both the PublishRegister and the publishserviceapi.ServerInterface interfaces.
-func NewPublishService(kongDomain string, kongProtocol string, kongIPv4 common29122.Ipv4Addr, kongDataPlanePort common29122.Port, kongControlPlanePort common29122.Port, capifProtocol string, capifIPv4 common29122.Ipv4Addr, capifPort common29122.Port) *PublishService {
+func NewPublishService(
+ kongDomain string,
+ kongProtocol string,
+ kongControlPlaneIPv4 common29122.Ipv4Addr,
+ kongControlPlanePort common29122.Port,
+ kongDataPlaneIPv4 common29122.Ipv4Addr,
+ kongDataPlanePort common29122.Port,
+ capifProtocol string,
+ capifIPv4 common29122.Ipv4Addr,
+ capifPort common29122.Port) *PublishService {
return &PublishService{
KongDomain : kongDomain,
KongProtocol : kongProtocol,
- KongIPv4 : kongIPv4,
- KongDataPlanePort : kongDataPlanePort,
+ KongControlPlaneIPv4 : kongControlPlaneIPv4,
KongControlPlanePort : kongControlPlanePort,
+ KongDataPlaneIPv4 : kongDataPlaneIPv4,
+ KongDataPlanePort : kongDataPlanePort,
CapifProtocol : capifProtocol,
CapifIPv4 : capifIPv4,
CapifPort : capifPort,
// Publish a new API.
func (ps *PublishService) PostApfIdServiceApis(ctx echo.Context, apfId string) error {
log.Tracef("entering PostApfIdServiceApis apfId %s", apfId)
+ log.Debugf("PostApfIdServiceApis KongControlPlaneIPv4 %s", ps.KongControlPlaneIPv4)
+ log.Debugf("PostApfIdServiceApis KongDataPlaneIPv4 %s", ps.KongDataPlaneIPv4)
capifcoreUrl := fmt.Sprintf("%s://%s:%d/published-apis/v1/", ps.CapifProtocol, ps.CapifIPv4, ps.CapifPort)
client, err := publishapi.NewClientWithResponses(capifcoreUrl)
newServiceAPIDescription.PrepareNewService()
- statusCode, err := newServiceAPIDescription.RegisterKong(ps.KongDomain, ps.KongProtocol, ps.KongIPv4, ps.KongDataPlanePort, ps.KongControlPlanePort, apfId)
+ statusCode, err := newServiceAPIDescription.RegisterKong(
+ ps.KongDomain,
+ ps.KongProtocol,
+ ps.KongControlPlaneIPv4,
+ ps.KongControlPlanePort,
+ ps.KongDataPlaneIPv4,
+ ps.KongDataPlanePort,
+ apfId)
if (err != nil) || (statusCode != http.StatusCreated) {
// We can return with http.StatusForbidden if there is a http.StatusConflict detected by Kong
msg := err.Error()
log.Debugf("PostApfIdServiceApisWithResponse status code %d", rsp.StatusCode())
log.Debugf("PostApfIdServiceApisWithResponse error %s", msg)
if rsp.StatusCode() == http.StatusForbidden || rsp.StatusCode() == http.StatusBadRequest {
- newServiceAPIDescription.UnregisterKong(ps.KongDomain, ps.KongProtocol, ps.KongIPv4, ps.KongDataPlanePort, ps.KongControlPlanePort)
+ newServiceAPIDescription.UnregisterKong(ps.KongDomain, ps.KongProtocol, ps.KongControlPlaneIPv4, ps.KongControlPlanePort)
}
return sendCoreError(ctx, rsp.StatusCode(), msg)
}
}
rspServiceAPIDescription := *rsp.JSON200
- statusCode, err = rspServiceAPIDescription.UnregisterKong(ps.KongDomain, ps.KongProtocol, ps.KongIPv4, ps.KongDataPlanePort, ps.KongControlPlanePort)
+
+ statusCode, err = rspServiceAPIDescription.UnregisterKong(ps.KongDomain, ps.KongProtocol, ps.KongControlPlaneIPv4, ps.KongControlPlanePort)
if (err != nil) || (statusCode != http.StatusNoContent) {
msg := err.Error()
log.Errorf("error on UnregisterKong %s", msg)
if rsp.StatusCode() != http.StatusOK {
log.Errorf("PutApfIdServiceApisServiceApiIdWithResponse status code %d", rsp.StatusCode())
if rsp.StatusCode() == http.StatusBadRequest {
- updatedServiceDescription.UnregisterKong(ps.KongDomain, ps.KongProtocol, ps.KongIPv4, ps.KongDataPlanePort, ps.KongControlPlanePort)
+ updatedServiceDescription.UnregisterKong(ps.KongDomain, ps.KongProtocol,ps.KongControlPlaneIPv4, ps.KongControlPlanePort)
}
msg := string(rsp.Body)
return sendCoreError(ctx, rsp.StatusCode(), msg)
publishapi "oransc.org/nonrtric/servicemanager/internal/publishserviceapi"
"oransc.org/nonrtric/capifcore"
- "oransc.org/nonrtric/servicemanager/mockkong"
+ mockKong "oransc.org/nonrtric/servicemanager/mockkong"
)
var (
- eServiceManager *echo.Echo
- eCapifWeb *echo.Echo
- eKong *echo.Echo
- mockConfigReader *envreader.MockConfigReader
+ eServiceManager *echo.Echo
+ eCapifWeb *echo.Echo
+ eKong *echo.Echo
+ mockConfigReader *envreader.MockConfigReader
serviceManagerServer *httptest.Server
- capifServer *httptest.Server
- mockKongServer *httptest.Server
+ capifServer *httptest.Server
+ mockKongServer *httptest.Server
)
func TestMain(m *testing.M) {
MockedConfig: map[string]string{
"KONG_DOMAIN": "kong",
"KONG_PROTOCOL": "http",
- "KONG_IPV4": mockKongHost,
- "KONG_DATA_PLANE_PORT": "32080",
+ "KONG_CONTROL_PLANE_IPV4": mockKongHost,
"KONG_CONTROL_PLANE_PORT": mockKongControlPlanePort,
+ "KONG_DATA_PLANE_IPV4": "10.101.1.101",
+ "KONG_DATA_PLANE_PORT": "32080",
"CAPIF_PROTOCOL": "http",
"CAPIF_IPV4": capifHost,
"CAPIF_PORT": capifPort,
}
}
-func capifCleanUp() {
+func capifCleanUp() {
t := new(testing.T) // Create a new testing.T instance for capifCleanUp
// Delete the invoker
resultServiceIpv4 := *interfaceDescription.Ipv4Addr
resultServicePort := *interfaceDescription.Port
- kongIPv4 := common29122.Ipv4Addr(myEnv["KONG_IPV4"])
+ kongDataPlaneIPv4 := common29122.Ipv4Addr(myEnv["KONG_DATA_PLANE_IPV4"])
kongDataPlanePort := common29122.Port(myPorts["KONG_DATA_PLANE_PORT"])
- assert.NotEmpty(t, kongIPv4, "KONG_IPV4 is required in .env file for unit testing")
+ assert.NotEmpty(t, kongDataPlaneIPv4, "KONG_DATA_PLANE_IPV4 is required in .env file for unit testing")
assert.NotZero(t, kongDataPlanePort, "KONG_DATA_PLANE_PORT is required in .env file for unit testing")
- assert.Equal(t, kongIPv4, resultServiceIpv4)
+ assert.Equal(t, kongDataPlaneIPv4, resultServiceIpv4)
assert.Equal(t, kongDataPlanePort, resultServicePort)
// Publish the same service again should result in Forbidden
capifPort := common29122.Port(myPorts["CAPIF_PORT"])
kongDomain := myEnv["KONG_DOMAIN"]
kongProtocol := myEnv["KONG_PROTOCOL"]
- kongIPv4 := common29122.Ipv4Addr(myEnv["KONG_IPV4"])
- kongDataPlanePort := common29122.Port(myPorts["KONG_DATA_PLANE_PORT"])
+ kongControlPlaneIPv4 := common29122.Ipv4Addr(myEnv["KONG_CONTROL_PLANE_IPV4"])
kongControlPlanePort := common29122.Port(myPorts["KONG_CONTROL_PLANE_PORT"])
+ kongDataPlaneIPv4 := common29122.Ipv4Addr(myEnv["KONG_DATA_PLANE_IPV4"])
+ kongDataPlanePort := common29122.Port(myPorts["KONG_DATA_PLANE_PORT"])
// Register ProviderManagement
providerManagerSwagger, err := provapi.GetSwagger()
publishServiceSwagger.Servers = nil
- ps := NewPublishService(kongDomain, kongProtocol, kongIPv4, kongDataPlanePort, kongControlPlanePort, capifProtocol, capifIPv4, capifPort)
+ ps := NewPublishService(
+ kongDomain, kongProtocol,
+ kongControlPlaneIPv4, kongControlPlanePort,
+ kongDataPlaneIPv4, kongDataPlanePort,
+ capifProtocol, capifIPv4, capifPort)
group = e.Group("/published-apis/v1")
group.Use(echomiddleware.Logger())
sd.ApiId = &apiName
}
-func (sd *ServiceAPIDescription) RegisterKong(kongDomain string,
- kongProtocol string,
- kongIPv4 common29122.Ipv4Addr,
- kongDataPlanePort common29122.Port,
+func (sd *ServiceAPIDescription) RegisterKong(
+ kongDomain string,
+ kongProtocol string,
+ kongControlPlaneIPv4 common29122.Ipv4Addr,
kongControlPlanePort common29122.Port,
- apfId string) (int, error) {
+ kongDataPlaneIPv4 common29122.Ipv4Addr,
+ kongDataPlanePort common29122.Port,
+ apfId string) (int, error) {
log.Trace("entering RegisterKong")
+ log.Debugf("RegisterKong kongDataPlaneIPv4 %s", kongDataPlaneIPv4)
+
var (
statusCode int
err error
)
- kongControlPlaneURL := fmt.Sprintf("%s://%s:%d", kongProtocol, kongIPv4, kongControlPlanePort)
+ kongControlPlaneURL := fmt.Sprintf("%s://%s:%d", kongProtocol, kongControlPlaneIPv4, kongControlPlanePort)
statusCode, err = sd.createKongRoutes(kongControlPlaneURL, apfId)
if (err != nil) || (statusCode != http.StatusCreated) {
return statusCode, err
}
- sd.updateInterfaceDescription(kongIPv4, kongDataPlanePort, kongDomain)
+ sd.updateInterfaceDescription(kongDataPlaneIPv4, kongDataPlanePort, kongDomain)
log.Trace("exiting from RegisterKong")
return statusCode, nil
}
// Update our exposures to point to Kong by replacing in incoming interface description with Kong interface descriptions.
-func (sd *ServiceAPIDescription) updateInterfaceDescription(kongIPv4 common29122.Ipv4Addr, kongDataPlanePort common29122.Port, kongDomain string) {
+func (sd *ServiceAPIDescription) updateInterfaceDescription(kongDataPlaneIPv4 common29122.Ipv4Addr, kongDataPlanePort common29122.Port, kongDomain string) {
log.Trace("updating InterfaceDescriptions")
+ log.Debugf("InterfaceDescriptions kongDataPlaneIPv4 %s", kongDataPlaneIPv4)
+
interfaceDesc := InterfaceDescription{
- Ipv4Addr: &kongIPv4,
+ Ipv4Addr: &kongDataPlaneIPv4,
Port: &kongDataPlanePort,
}
interfaceDescs := []InterfaceDescription{interfaceDesc}
}
}
-func (sd *ServiceAPIDescription) UnregisterKong(kongDomain string, kongProtocol string, kongIPv4 common29122.Ipv4Addr, kongDataPlanePort common29122.Port, kongControlPlanePort common29122.Port) (int, error) {
+func (sd *ServiceAPIDescription) UnregisterKong(kongDomain string, kongProtocol string, kongControlPlaneIPv4 common29122.Ipv4Addr, kongControlPlanePort common29122.Port) (int, error) {
log.Trace("entering UnregisterKong")
var (
statusCode int
err error
)
- kongControlPlaneURL := fmt.Sprintf("%s://%s:%d", kongProtocol, kongIPv4, kongControlPlanePort)
+ kongControlPlaneURL := fmt.Sprintf("%s://%s:%d", kongProtocol, kongControlPlaneIPv4, kongControlPlanePort)
statusCode, err = sd.deleteKongRoutes(kongControlPlaneURL)
if (err != nil) || (statusCode != http.StatusNoContent) {
)
func main() {
- realConfigReader := &envreader.RealConfigReader{}
- myEnv, myPorts, err := realConfigReader.ReadDotEnv()
- if err != nil {
+ realConfigReader := &envreader.RealConfigReader{}
+ myEnv, myPorts, err := realConfigReader.ReadDotEnv()
+ if err != nil {
log.Fatal("error loading environment file")
- return
- }
+ return
+ }
eServiceManager := echo.New()
err = registerHandlers(eServiceManager, myEnv, myPorts)
capifPort := common29122.Port(myPorts["CAPIF_PORT"])
kongDomain := myEnv["KONG_DOMAIN"]
kongProtocol := myEnv["KONG_PROTOCOL"]
- kongIPv4 := common29122.Ipv4Addr(myEnv["KONG_IPV4"])
- kongDataPlanePort := common29122.Port(myPorts["KONG_DATA_PLANE_PORT"])
+ kongControlPlaneIPv4 := common29122.Ipv4Addr(myEnv["KONG_CONTROL_PLANE_IPV4"])
kongControlPlanePort := common29122.Port(myPorts["KONG_CONTROL_PLANE_PORT"])
+ kongDataPlaneIPv4 := common29122.Ipv4Addr(myEnv["KONG_DATA_PLANE_IPV4"])
+ kongDataPlanePort := common29122.Port(myPorts["KONG_DATA_PLANE_PORT"])
var group *echo.Group
return err
}
publishServiceSwagger.Servers = nil
- publishService := publishservice.NewPublishService(kongDomain, kongProtocol, kongIPv4, kongDataPlanePort, kongControlPlanePort, capifProtocol, capifIPv4, capifPort)
+ publishService := publishservice.NewPublishService(
+ kongDomain, kongProtocol,
+ kongControlPlaneIPv4, kongControlPlanePort,
+ kongDataPlaneIPv4, kongDataPlanePort,
+ capifProtocol, capifIPv4, capifPort)
group = e.Group("/published-apis/v1")
group.Use(middleware.OapiRequestValidator(publishServiceSwagger))
MockedConfig: map[string]string{
"KONG_DOMAIN": "kong",
"KONG_PROTOCOL": "http",
- "KONG_IPV4": mockKongHost,
- "KONG_DATA_PLANE_PORT": "32080",
+ "KONG_CONTROL_PLANE_IPV4": mockKongHost,
"KONG_CONTROL_PLANE_PORT": mockKongControlPlanePort,
+ "KONG_DATA_PLANE_IPV4": "10.101.1.101",
+ "KONG_DATA_PLANE_PORT": "32080",
"CAPIF_PROTOCOL": "http",
"CAPIF_IPV4": capifHost,
"CAPIF_PORT": capifPort,