/*
* Copyright 2020-2021 Huawei Technologies Co., Ltd.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package mp1
import (
"bytes"
"context"
"crypto/tls"
"encoding/json"
"errors"
"fmt"
"github.com/beevik/ntp"
"github.com/ghodss/yaml"
"io"
"io/ioutil"
"math/rand"
"mepserver/common/config"
"mepserver/common/extif/dataplane"
"mepserver/common/extif/dataplane/none"
"mepserver/common/models"
"mepserver/mp1/plans"
"net/http"
"net/http/httptest"
"net/url"
"os"
"strconv"
"testing"
"time"
"github.com/agiledragon/gomonkey"
"github.com/apache/servicecomb-service-center/pkg/log"
baseutil "github.com/apache/servicecomb-service-center/pkg/util"
_ "github.com/apache/servicecomb-service-center/server"
_ "github.com/apache/servicecomb-service-center/server/bootstrap"
pb "github.com/apache/servicecomb-service-center/server/core/proto"
scerr "github.com/apache/servicecomb-service-center/server/error"
"github.com/apache/servicecomb-service-center/server/plugin/pkg/registry"
"github.com/apache/servicecomb-service-center/server/plugin/pkg/registry/buildin"
srv "github.com/apache/servicecomb-service-center/server/service"
svcutil "github.com/apache/servicecomb-service-center/server/service/util"
uuid "github.com/satori/go.uuid"
"github.com/stretchr/testify/assert"
"github.com/stretchr/testify/mock"
"reflect"
"mepserver/common/extif/backend"
"mepserver/common/extif/dns"
ntpc "mepserver/common/extif/ntp"
"mepserver/common/util"
)
type mockHttpWriter struct {
mock.Mock
response []byte
}
//============================= dns ============================================
const defaultAppInstanceId = "5abe4782-2c70-4e47-9a4e-0ee3a1a0fd1f"
const dnsRuleId = "7d71e54e-81f3-47bb-a2fc-b565a326d794"
const trafficRuleId = "8ft68t22-81f3-47bb-a2fc-56996er4tf37"
const panicFormatString = "Panic: %v"
const getDnsRulesUrlFormat = "/mep/mec_app_support/v1/applications/%s/dns_rules"
const getDnsRuleUrlFormat = "/mep/mec_app_support/v1/applications/%s/dns_rules/%s"
const appInstanceQueryFormat = ":appInstanceId=%s&;"
const appIdAndDnsRuleIdQueryFormat = ":appInstanceId=%s&;:dnsRuleId=%s&;"
const appIdAndTrafficRuleIdQueryFormat = ":appInstanceId=%s&;:trafficRuleId=%s&;"
const appInstanceIdHeader = "X-AppinstanceID"
const responseStatusHeader = "X-Response-Status"
const responseCheckFor200 = "Response status code must be 200"
const responseCheckFor400 = "Response status code must be 404"
const errorWriteRespErr = "Write Response Error"
const exampleDomainName = "www.example.com"
const defaultTTL = 30
const maxIPVal = 255
const ipAddFormatter = "%d.%d.%d.%d"
const writeObjectFormat = "{\"dnsRuleId\":\"7d71e54e-81f3-47bb-a2fc-b565a326d794\",\"domainName\":\"www.example.com\"," +
"\"ipAddressType\":\"IP_V4\",\"ipAddress\":\"%s\",\"ttl\":30,\"state\":\"%s\"}\n"
const writeTrafficObjectFormat = "{\"trafficRuleId\":\"" + trafficRuleId + "\",\"filterType\":\"FLOW\",\"priority\":5," +
"\"trafficFilter\":null,\"action\":\"DROP\",\"dstInterface\":null,\"state\":\"%s\"}\n"
const writeTrafficPutObjectFormat = "{\"trafficRuleId\":\"" + trafficRuleId + "\",\"filterType\":\"FLOW\"," +
"\"priority\":5," +
"\"trafficFilter\":[],\"action\":\"DROP\",\"dstInterface\":null,\"state\":\"%s\"}\n"
const writeCurTimetFormat = "{\"seconds\":1623770544,\"nanoSeconds\":468538768," +
"\"timeSourceStatus\":\"TRACEABLE\"}"
const writeCurTimeNonSynct = "{\"seconds\":1623770544,\"nanoSeconds\":468538768," +
"\"timeSourceStatus\":\"NONTRACEABLE\"}"
const writeCaps = "{\"timeStamp\":{\"seconds\":1623770544,\"nanoSeconds\":468538768},\"ntpServers\"" +
":[{\"ntpServerAddrType\":\"DNS_NAME\",\"ntpServerAddr\":\"mep-ntp\",\"minPollingInterval\":4,\"maxPollingInterval\":17," +
"\"localPriority\":1,\"authenticationOption\":\"NONE\",\"authenticationKeyNum\":0}]}"
const writeTransport = "{\"id\":\"8eb442b7cdfc11eba09314feb5b475da\",\"name\":\"REST\",\"description\":\"REST API\"," +
"\"type\":\"REST_HTTP\",\"protocol\":\"HTTP\",\"version\":\"2.0\",\"endpoint\":{\"uris\":null,\"addresses\":null," +
"\"alternative\":null},\"security\":{\"oAuth2Info\":{\"grantTypes\":[\"OAUTH2_CLIENT_CREDENTIALS\"]," +
"\"tokenEndpoint\":\"/mep/token\"}}}"
const writeCurTimeFormatVal = "{\"seconds\":%s,\"nanoSeconds\":%s," +
"\"timeSourceStatus\":\"TRACEABLE\"}"
const defCapabilityId = "16384563dca094183778a41ea7701d15"
const svcCatHref = "serCategory/href"
const svcCatResponse = "/example/catalogue1"
const svcCatName = "serCategory/name"
const svcCatId = "serCategory/id"
const svcCatVersion = "serCategory/version"
//===========================Services==============================================
const postSubscribeUrl = "/mec_service_mgmt/v1/applications/%s/services"
const getSubscribeUrl = "/mec_service_mgmt/v1/applications/%s/services"
const getOrDelOneSubscribeOrSveUrl = "/mec_service_mgmt/v1/applications/%s/services/%s"
const responseCheckFor201 = "Response status code must be 201"
const responseCheckFor204 = "Response status code must be 204"
const subtype1 = "SerAvailabilityNotificationSubscription"
const subtype2 = "AppTerminationNotificationSubscription"
const errorSubtypeMissMatch = "Subscription type mismatch"
const postAppTerminologiesUrl = "/mec_app_support/v1/applications/%s/services"
const getAppTerminologiesUrl = "/mec_app_support/v1/applications/%s/services"
const getOneAppTerminologiesUrl = "/mec_app_support/v1/applications/%s/services/%s"
const delOneAppTerminologiesUrl = "/mec_app_support/v1/applications/%s/services/%s"
const appIdAndServiceIdQueryFormat = ":appInstanceId=%s&;:serviceId=%s&;"
const sampleServiceId = "f7e898d1c9ea9edd7496c761ddc92718"
const sampleInstanceId = "f7e898d1c9ea9edd7496c761ddc92718"
const serviceDiscoverUrlFormat = "/mep/mec_service_mgmt/v1/applications/%s/services"
const serNameQueryFormat = ":appInstanceId=%s&;ser_name=%s&;"
const getAllTrafficRuleUrl = "/mec_app_support/v1/applications/%s/traffic_rules"
const getOneTrafficRuleUrl = "/mec_app_support/v1/applications/%s/traffic_rules/%s"
const heartBeatUrl = "/mep/mec_service_mgmt/v1/applications/%s/services/%s/liveness"
const formatIntBase = 10
const secString = "timestamp/seconds"
const nanosecString = "timestamp/nanoseconds"
const getTiming = "/mec_app_support/v1/applications/timing/%s"
const getCurrentTIme = "currentTime"
const getCaps = "timing_caps"
const getTransport = "transports"
const confirm_ready = "/mec_app_support/v1/applications/%s/confirm_ready"
const confirm_termination = "/mec_app_support/v1/applications/%s/confirm_termination"
//=====================================COMMON====================================================================
const restApi = "REST API"
const tokenEndPoint = "/mecSerMgmtApi/security/TokenEndPoint"
const href = "/example/catalogue1"
const callBack = "https://%d.%d.%d.%d:%d/example/catalogue1"
const parseFail = "Parsing configuration file error"
//=======================================END======================================================================
// Generate test IP, instead of hard coding them
var exampleIPAddress = fmt.Sprintf(ipAddFormatter, rand.Intn(maxIPVal), rand.Intn(maxIPVal), rand.Intn(maxIPVal),
rand.Intn(maxIPVal))
var callBackRef = fmt.Sprintf(callBack, 192, 0, 2, 1, 8080)
func (m *mockHttpWriter) Header() http.Header {
// Get the argument inputs
args := m.Called()
// retrieve the configured value we provided at the input and return it back
return args.Get(0).(http.Header)
}
func (m *mockHttpWriter) Write(respons
没有合适的资源?快使用搜索试试~ 我知道了~
Edgegallery MEP是依据ETSI MEC 003 1和011 2标准实现的MEP开源方案
共195个文件
go:156个
sh:5个
dockerfile:5个
1 下载量 140 浏览量
2023-08-04
10:24:24
上传
评论
收藏 350KB ZIP 举报
温馨提示
Edgegallery MEP是依据ETSI MEC 003 [1]和011 [2]标准实现的MEP开源方案。ETSI GS MEC 003中定义的MEP,提供了一个使应用程序可以发现、通告、使用和提供MEC服务的环境。在从MEC平台管理器、应用程序或服务接收到流量规则的更新,激活或停用后,MEP会进行对应的执行动作。MEP还从MEC平台管理器接收DNS记录,并使用它们来配置DNS代理/服务器。
资源推荐
资源详情
资源评论
收起资源包目录
Edgegallery MEP是依据ETSI MEC 003 1和011 2标准实现的MEP开源方案 (195个子文件)
app.conf 5KB
app.conf 1KB
app.conf 669B
app.conf 648B
kong.conf 626B
Dockerfile 3KB
Dockerfile 2KB
Dockerfile 2KB
Dockerfile 2KB
Dockerfile 2KB
.gitignore 145B
.gitignore 34B
controller_test.go 167KB
controller_test.go 127KB
sync.go 32KB
controller_test.go 26KB
meputil.go 25KB
main_test.go 21KB
sync_test.go 20KB
util.go 19KB
appd.go 15KB
controller.go 14KB
serviceinfo.go 14KB
dns_one_update.go 13KB
token_test.go 12KB
apigw_test.go 11KB
apigw.go 11KB
svc_register.go 11KB
conf_test.go 10KB
instance_event_handler.go 10KB
app_subscribe.go 10KB
kong_http_log.go 10KB
plan_svc_discover.go 10KB
const.go 10KB
app_instance_termination.go 9KB
boltdb.go 9KB
token.go 9KB
dns_test.go 9KB
heartbeat_patched.go 9KB
conf.go 8KB
boltdb_test.go 8KB
appd_config_create.go 7KB
capability_all_get.go 7KB
main_test.go 7KB
controller.go 7KB
requestutil.go 7KB
traffic_one_get.go 7KB
sign.go 6KB
factory_test.go 6KB
controller.go 6KB
main.go 6KB
traffic_one_update.go 6KB
rest.go 6KB
app_confirm_termination.go 6KB
run.go 6KB
base.go 6KB
capability_one_get.go 6KB
httprsp_builder.go 6KB
dns.go 5KB
instance_event_handler_test.go 5KB
apigwutil.go 5KB
validation_test.go 5KB
svc_one_get.go 5KB
heartbeat_get.go 5KB
validation.go 5KB
dataplane_if.go 5KB
util_test.go 5KB
mepserver_loader_test.go 5KB
app_confirm_ready.go 5KB
communicate_test.go 5KB
workspace_base.go 5KB
main.go 5KB
controller_test.go 4KB
datastore.go 4KB
serviceinfo_test.go 4KB
communicate.go 4KB
appd_get_taskstatus.go 4KB
const.go 4KB
heartbeat.go 4KB
validation.go 4KB
app_subscribes_get.go 4KB
taskstatus_db.go 4KB
app_subscribe_one_get.go 3KB
pgdb.go 3KB
appd_config_update.go 3KB
subscription_info_get.go 3KB
base.go 3KB
edgeHealth.go 3KB
svc_one_update.go 3KB
blocklist.go 3KB
app_subscribe_one_del.go 3KB
runner.go 3KB
svc_one_delete.go 3KB
main.go 3KB
appd_config_delete.go 3KB
none.go 3KB
transport_all_get.go 3KB
app_config.go 3KB
doc.go 3KB
blocklist_test.go 3KB
共 195 条
- 1
- 2
资源评论
Java程序员-张凯
- 粉丝: 1w+
- 资源: 6746
上传资源 快速赚钱
- 我的内容管理 展开
- 我的资源 快来上传第一个资源
- 我的收益 登录查看自己的收益
- 我的积分 登录查看自己的积分
- 我的C币 登录后查看C币余额
- 我的收藏
- 我的下载
- 下载帮助
安全验证
文档复制为VIP权益,开通VIP直接复制
信息提交成功