在以往的工作經驗中,測試工具平台一般用來構造測試資料,查詢資料等以此來提高測試的效率。但是這種功能一般都是針對系統進行特定的開發,所以本平台主打dubbo介面測試,以及一些通用功能進行開發。
技術棧:
需要實現的功能:
一般在業務系統中,我們經常會用到redis快取,我們可以自己搭建乙個服務,來對redis進行操作。用乙個簡單,實用的功能來建立你的自信心。
一、新建專案
使用django自帶的命令新建專案 :
三、引入django rest framework
pip install -i djangorestframework開啟settings.py檔案
sys.path.insert(
0, os.path.join(base_dir,))
['django.contrib.admin'
,'django.contrib.auth'
,'django.contrib.contenttypes'
,'django.contrib.sessions'
,'django.contrib.messages'
,'django.contrib.staticfiles'
,'rest_framework'
,#註冊drf
]四、功能邏輯實現
我們直接通過 redis 包來實現redis 增,刪,查 功能
class
pyredis
:def
__init__
(self)
: self.host =
'127.0.0.1'
self.port =
'6379'
self.db =
0 pool = redis.connectionpool(host=self.host, port=self.port,db=self.db)
self.conn = redis.redis(connection_pool=pool)
defset_key
(self, key, value)
:try
:return self.conn.
set(name=key, value=value)
except exception as e:
print
(e)def
get_key
(self, key)
:try
:return self.conn.get(key)
except exception as e:
print
(e)def
del_key
(self, key)
:try
:return self.conn.delete(key)
except exception as e:
print
(e)
我們用基於函式檢視的@api_view裝飾器來實現這個restful風格的api
from rest_framework.decorators import api_view
from rest_framework.response import response
from
.common import pyredis
# create your views here.
@api_view(
['get'
,'post'
,'delete'])
defredis_value
(request)
:if request.method ==
'get'
: value = pyredis(
).get_key(request.data.get(
'redis_key'))
res_data =
return response(res_data)
elif request.method ==
'post'
: value = pyredis(
).set_key(request.data.get(
'redis_key'
), request.data.get(
'redis_value'))
res_data =
return response(res_data)
elif request.method ==
'delete'
: value = pyredis(
).del_key(request.data.get(
'redis_key'))
res_data =
return response(res_data)
from django.urls import path
urlpatterns =
[ path(
'redis/'
, views.redis_value, name=
'redis'),
]
然後將上面的ur註冊在testplatform/urls.py中,
urlpatterns =
[ path(
'admin/'
, admin.site.urls)
,# 工具的url
path(
'api/utils/'
,include())
]
五、啟動專案,除錯介面
啟動專案:
python manage.py runserver該項目的第乙個功能就實現了。設定redis資料
查詢redis資料
(這裡沒有將redis的連線資訊等做成可配置,後續會慢慢將一些細節的東西完善)
六、總結
Apache ab 測試工具使用 一
簡述 試用apache ab測試工具 參考 ab的引數說明 n 需要執行的請求次數 c 併發的數量 t 等待返回的最長時間 b tcp收發緩衝區的大小,單位 byte p 使用post 同時需要定義 t引數 u 使用put 同時需要定義 t引數 w 把結果列印在html的 裡 x 的屬性 y tr行...
XL 滲透測試工具(一)
滲透測試的大致分為掃瞄工具,也包括探測功能,爆破工具,管理工具等 今天學習了八個工具 1.nmap 掃瞄工具 具有探測功能 2.sqlmap 掃瞄工具 檢測功能 3.burpsuite 爆破工具 抓包 4.hydra 爆破工具 以上四個 kali裡可以直接使用 但是建議burpsuite還是在物理機...
Code Tools AB效能測試工具(一)
二 ab工具使用 格式 ab options http hostname port path 例如 ab n 1000 c 10 https 引數 在測試會話中所執行的請求個數。預設時,僅執行乙個請求 n requests number of requests to perform 一次產生的請求個...