test: Add unit tests
This commit is contained in:
parent
43bc27cbc3
commit
ee73bd4921
@ -3,7 +3,7 @@
|
|||||||
mkdir lib
|
mkdir lib
|
||||||
mkdir include
|
mkdir include
|
||||||
|
|
||||||
cp gmssl/include include
|
cp -r gmssl/include include
|
||||||
|
|
||||||
mkdir gmssl/build
|
mkdir gmssl/build
|
||||||
cd gmssl/build || exit
|
cd gmssl/build || exit
|
||||||
|
117
nohup.out
117
nohup.out
@ -2,3 +2,120 @@ python: can't open file '/home/muzhi/tpre-python/server.py': [Errno 2] No such f
|
|||||||
python: can't open file '/home/muzhi/tpre-python/client.py': [Errno 2] No such file or directory
|
python: can't open file '/home/muzhi/tpre-python/client.py': [Errno 2] No such file or directory
|
||||||
python: can't open file '/home/muzhi/tpre-python/node.py': [Errno 2] No such file or directory
|
python: can't open file '/home/muzhi/tpre-python/node.py': [Errno 2] No such file or directory
|
||||||
python: can't open file '/home/muzhi/tpre-python/server.py': [Errno 2] No such file or directory
|
python: can't open file '/home/muzhi/tpre-python/server.py': [Errno 2] No such file or directory
|
||||||
|
time="2024-09-26T22:09:36.376459942+08:00" level=info msg="Starting up"
|
||||||
|
time="2024-09-26T22:09:36.377656686+08:00" level=info msg="containerd not running, starting managed containerd"
|
||||||
|
time="2024-09-26T22:09:36.379426679+08:00" level=info msg="started new containerd process" address=/var/run/docker/containerd/containerd.sock module=libcontainerd pid=45300
|
||||||
|
time="2024-09-26T22:09:36.429831283+08:00" level=info msg="starting containerd" revision=7f7fdf5fed64eb6a7caf99b3e12efcf9d60e311c version=1.7.22
|
||||||
|
time="2024-09-26T22:09:36.442939090+08:00" level=info msg="loading plugin \"io.containerd.snapshotter.v1.aufs\"..." type=io.containerd.snapshotter.v1
|
||||||
|
time="2024-09-26T22:09:36.456812832+08:00" level=info msg="skip loading plugin \"io.containerd.snapshotter.v1.aufs\"..." error="aufs is not supported (modprobe aufs failed: exit status 1 \"modprobe: FATAL: Module aufs not found in directory /lib/modules/5.15.153.1-microsoft-standard-WSL2\\n\"): skip plugin" type=io.containerd.snapshotter.v1
|
||||||
|
time="2024-09-26T22:09:36.456884831+08:00" level=info msg="loading plugin \"io.containerd.event.v1.exchange\"..." type=io.containerd.event.v1
|
||||||
|
time="2024-09-26T22:09:36.456905922+08:00" level=info msg="loading plugin \"io.containerd.internal.v1.opt\"..." type=io.containerd.internal.v1
|
||||||
|
time="2024-09-26T22:09:36.458606154+08:00" level=info msg="loading plugin \"io.containerd.warning.v1.deprecations\"..." type=io.containerd.warning.v1
|
||||||
|
time="2024-09-26T22:09:36.458650500+08:00" level=info msg="loading plugin \"io.containerd.snapshotter.v1.blockfile\"..." type=io.containerd.snapshotter.v1
|
||||||
|
time="2024-09-26T22:09:36.459278550+08:00" level=info msg="skip loading plugin \"io.containerd.snapshotter.v1.blockfile\"..." error="no scratch file generator: skip plugin" type=io.containerd.snapshotter.v1
|
||||||
|
time="2024-09-26T22:09:36.459325491+08:00" level=info msg="loading plugin \"io.containerd.snapshotter.v1.btrfs\"..." type=io.containerd.snapshotter.v1
|
||||||
|
time="2024-09-26T22:09:36.459887232+08:00" level=info msg="skip loading plugin \"io.containerd.snapshotter.v1.btrfs\"..." error="path /var/lib/docker/containerd/daemon/io.containerd.snapshotter.v1.btrfs (ext4) must be a btrfs filesystem to be used with the btrfs snapshotter: skip plugin" type=io.containerd.snapshotter.v1
|
||||||
|
time="2024-09-26T22:09:36.460093853+08:00" level=info msg="loading plugin \"io.containerd.snapshotter.v1.devmapper\"..." type=io.containerd.snapshotter.v1
|
||||||
|
time="2024-09-26T22:09:36.461105889+08:00" level=info msg="skip loading plugin \"io.containerd.snapshotter.v1.devmapper\"..." error="devmapper not configured: skip plugin" type=io.containerd.snapshotter.v1
|
||||||
|
time="2024-09-26T22:09:36.461252323+08:00" level=info msg="loading plugin \"io.containerd.snapshotter.v1.native\"..." type=io.containerd.snapshotter.v1
|
||||||
|
time="2024-09-26T22:09:36.461509442+08:00" level=info msg="loading plugin \"io.containerd.snapshotter.v1.overlayfs\"..." type=io.containerd.snapshotter.v1
|
||||||
|
time="2024-09-26T22:09:36.461854703+08:00" level=info msg="loading plugin \"io.containerd.snapshotter.v1.zfs\"..." type=io.containerd.snapshotter.v1
|
||||||
|
time="2024-09-26T22:09:36.462030544+08:00" level=info msg="skip loading plugin \"io.containerd.snapshotter.v1.zfs\"..." error="path /var/lib/docker/containerd/daemon/io.containerd.snapshotter.v1.zfs must be a zfs filesystem to be used with the zfs snapshotter: skip plugin" type=io.containerd.snapshotter.v1
|
||||||
|
time="2024-09-26T22:09:36.462067746+08:00" level=info msg="loading plugin \"io.containerd.content.v1.content\"..." type=io.containerd.content.v1
|
||||||
|
time="2024-09-26T22:09:36.462482502+08:00" level=info msg="loading plugin \"io.containerd.metadata.v1.bolt\"..." type=io.containerd.metadata.v1
|
||||||
|
time="2024-09-26T22:09:36.462533912+08:00" level=info msg="metadata content store policy set" policy=shared
|
||||||
|
time="2024-09-26T22:09:36.463147002+08:00" level=info msg="loading plugin \"io.containerd.gc.v1.scheduler\"..." type=io.containerd.gc.v1
|
||||||
|
time="2024-09-26T22:09:36.463200977+08:00" level=info msg="loading plugin \"io.containerd.differ.v1.walking\"..." type=io.containerd.differ.v1
|
||||||
|
time="2024-09-26T22:09:36.463216397+08:00" level=info msg="loading plugin \"io.containerd.lease.v1.manager\"..." type=io.containerd.lease.v1
|
||||||
|
time="2024-09-26T22:09:36.463231386+08:00" level=info msg="loading plugin \"io.containerd.streaming.v1.manager\"..." type=io.containerd.streaming.v1
|
||||||
|
time="2024-09-26T22:09:36.463244502+08:00" level=info msg="loading plugin \"io.containerd.runtime.v1.linux\"..." type=io.containerd.runtime.v1
|
||||||
|
time="2024-09-26T22:09:36.463287866+08:00" level=info msg="loading plugin \"io.containerd.monitor.v1.cgroups\"..." type=io.containerd.monitor.v1
|
||||||
|
time="2024-09-26T22:09:36.463499972+08:00" level=info msg="loading plugin \"io.containerd.runtime.v2.task\"..." type=io.containerd.runtime.v2
|
||||||
|
time="2024-09-26T22:09:36.464312109+08:00" level=info msg="loading plugin \"io.containerd.runtime.v2.shim\"..." type=io.containerd.runtime.v2
|
||||||
|
time="2024-09-26T22:09:36.464354031+08:00" level=info msg="loading plugin \"io.containerd.sandbox.store.v1.local\"..." type=io.containerd.sandbox.store.v1
|
||||||
|
time="2024-09-26T22:09:36.464370964+08:00" level=info msg="loading plugin \"io.containerd.sandbox.controller.v1.local\"..." type=io.containerd.sandbox.controller.v1
|
||||||
|
time="2024-09-26T22:09:36.464384059+08:00" level=info msg="loading plugin \"io.containerd.service.v1.containers-service\"..." type=io.containerd.service.v1
|
||||||
|
time="2024-09-26T22:09:36.464396353+08:00" level=info msg="loading plugin \"io.containerd.service.v1.content-service\"..." type=io.containerd.service.v1
|
||||||
|
time="2024-09-26T22:09:36.464407845+08:00" level=info msg="loading plugin \"io.containerd.service.v1.diff-service\"..." type=io.containerd.service.v1
|
||||||
|
time="2024-09-26T22:09:36.464422915+08:00" level=info msg="loading plugin \"io.containerd.service.v1.images-service\"..." type=io.containerd.service.v1
|
||||||
|
time="2024-09-26T22:09:36.464437002+08:00" level=info msg="loading plugin \"io.containerd.service.v1.introspection-service\"..." type=io.containerd.service.v1
|
||||||
|
time="2024-09-26T22:09:36.464449406+08:00" level=info msg="loading plugin \"io.containerd.service.v1.namespaces-service\"..." type=io.containerd.service.v1
|
||||||
|
time="2024-09-26T22:09:36.464472751+08:00" level=info msg="loading plugin \"io.containerd.service.v1.snapshots-service\"..." type=io.containerd.service.v1
|
||||||
|
time="2024-09-26T22:09:36.464484735+08:00" level=info msg="loading plugin \"io.containerd.service.v1.tasks-service\"..." type=io.containerd.service.v1
|
||||||
|
time="2024-09-26T22:09:36.464693600+08:00" level=info msg="loading plugin \"io.containerd.grpc.v1.containers\"..." type=io.containerd.grpc.v1
|
||||||
|
time="2024-09-26T22:09:36.464733678+08:00" level=info msg="loading plugin \"io.containerd.grpc.v1.content\"..." type=io.containerd.grpc.v1
|
||||||
|
time="2024-09-26T22:09:36.464746764+08:00" level=info msg="loading plugin \"io.containerd.grpc.v1.diff\"..." type=io.containerd.grpc.v1
|
||||||
|
time="2024-09-26T22:09:36.464758586+08:00" level=info msg="loading plugin \"io.containerd.grpc.v1.events\"..." type=io.containerd.grpc.v1
|
||||||
|
time="2024-09-26T22:09:36.464769828+08:00" level=info msg="loading plugin \"io.containerd.grpc.v1.images\"..." type=io.containerd.grpc.v1
|
||||||
|
time="2024-09-26T22:09:36.464792542+08:00" level=info msg="loading plugin \"io.containerd.grpc.v1.introspection\"..." type=io.containerd.grpc.v1
|
||||||
|
time="2024-09-26T22:09:36.464804626+08:00" level=info msg="loading plugin \"io.containerd.grpc.v1.leases\"..." type=io.containerd.grpc.v1
|
||||||
|
time="2024-09-26T22:09:36.464815948+08:00" level=info msg="loading plugin \"io.containerd.grpc.v1.namespaces\"..." type=io.containerd.grpc.v1
|
||||||
|
time="2024-09-26T22:09:36.464837941+08:00" level=info msg="loading plugin \"io.containerd.grpc.v1.sandbox-controllers\"..." type=io.containerd.grpc.v1
|
||||||
|
time="2024-09-26T22:09:36.464871305+08:00" level=info msg="loading plugin \"io.containerd.grpc.v1.sandboxes\"..." type=io.containerd.grpc.v1
|
||||||
|
time="2024-09-26T22:09:36.464901955+08:00" level=info msg="loading plugin \"io.containerd.grpc.v1.snapshots\"..." type=io.containerd.grpc.v1
|
||||||
|
time="2024-09-26T22:09:36.464932825+08:00" level=info msg="loading plugin \"io.containerd.grpc.v1.streaming\"..." type=io.containerd.grpc.v1
|
||||||
|
time="2024-09-26T22:09:36.464945519+08:00" level=info msg="loading plugin \"io.containerd.grpc.v1.tasks\"..." type=io.containerd.grpc.v1
|
||||||
|
time="2024-09-26T22:09:36.464968354+08:00" level=info msg="loading plugin \"io.containerd.transfer.v1.local\"..." type=io.containerd.transfer.v1
|
||||||
|
time="2024-09-26T22:09:36.464986078+08:00" level=info msg="loading plugin \"io.containerd.grpc.v1.transfer\"..." type=io.containerd.grpc.v1
|
||||||
|
time="2024-09-26T22:09:36.465008893+08:00" level=info msg="loading plugin \"io.containerd.grpc.v1.version\"..." type=io.containerd.grpc.v1
|
||||||
|
time="2024-09-26T22:09:36.465038761+08:00" level=info msg="loading plugin \"io.containerd.internal.v1.restart\"..." type=io.containerd.internal.v1
|
||||||
|
time="2024-09-26T22:09:36.465092485+08:00" level=info msg="loading plugin \"io.containerd.tracing.processor.v1.otlp\"..." type=io.containerd.tracing.processor.v1
|
||||||
|
time="2024-09-26T22:09:36.465127934+08:00" level=info msg="skip loading plugin \"io.containerd.tracing.processor.v1.otlp\"..." error="skip plugin: tracing endpoint not configured" type=io.containerd.tracing.processor.v1
|
||||||
|
time="2024-09-26T22:09:36.465138795+08:00" level=info msg="loading plugin \"io.containerd.internal.v1.tracing\"..." type=io.containerd.internal.v1
|
||||||
|
time="2024-09-26T22:09:36.465149816+08:00" level=info msg="skip loading plugin \"io.containerd.internal.v1.tracing\"..." error="skip plugin: tracing endpoint not configured" type=io.containerd.internal.v1
|
||||||
|
time="2024-09-26T22:09:36.465158413+08:00" level=info msg="loading plugin \"io.containerd.grpc.v1.healthcheck\"..." type=io.containerd.grpc.v1
|
||||||
|
time="2024-09-26T22:09:36.465169154+08:00" level=info msg="loading plugin \"io.containerd.nri.v1.nri\"..." type=io.containerd.nri.v1
|
||||||
|
time="2024-09-26T22:09:36.465181087+08:00" level=info msg="NRI interface is disabled by configuration."
|
||||||
|
time="2024-09-26T22:09:36.465891657+08:00" level=info msg=serving... address=/var/run/docker/containerd/containerd-debug.sock
|
||||||
|
time="2024-09-26T22:09:36.466517121+08:00" level=info msg=serving... address=/var/run/docker/containerd/containerd.sock.ttrpc
|
||||||
|
time="2024-09-26T22:09:36.466959130+08:00" level=info msg=serving... address=/var/run/docker/containerd/containerd.sock
|
||||||
|
time="2024-09-26T22:09:36.467011552+08:00" level=info msg="containerd successfully booted in 0.038445s"
|
||||||
|
time="2024-09-26T22:09:37.442872969+08:00" level=info msg="[graphdriver] using prior storage driver: overlay2"
|
||||||
|
time="2024-09-26T22:09:37.447160585+08:00" level=info msg="Loading containers: start."
|
||||||
|
time="2024-09-26T22:09:39.014560587+08:00" level=info msg="Default bridge (docker0) is assigned with an IP address 172.17.0.0/16. Daemon option --bip can be used to set a preferred IP address"
|
||||||
|
time="2024-09-26T22:09:39.242339674+08:00" level=warning msg="error locating sandbox id 81d08d4c2c0b3dacb9981e18cadd6c4c6f0102b918d7c1088835c3b9da2f3c53: sandbox 81d08d4c2c0b3dacb9981e18cadd6c4c6f0102b918d7c1088835c3b9da2f3c53 not found"
|
||||||
|
time="2024-09-26T22:09:39.242568849+08:00" level=info msg="Loading containers: done."
|
||||||
|
time="2024-09-26T22:09:39.261071197+08:00" level=warning msg="WARNING: No swap limit support"
|
||||||
|
time="2024-09-26T22:09:39.261150972+08:00" level=info msg="Docker daemon" commit=41ca978 containerd-snapshotter=false storage-driver=overlay2 version=27.3.1
|
||||||
|
time="2024-09-26T22:09:39.261238482+08:00" level=info msg="Daemon has completed initialization"
|
||||||
|
time="2024-09-26T22:09:39.397145375+08:00" level=info msg="API listen on /var/run/docker.sock"
|
||||||
|
time="2024-09-26T22:10:13.924903837+08:00" level=info msg="loading plugin \"io.containerd.event.v1.publisher\"..." runtime=io.containerd.runc.v2 type=io.containerd.event.v1
|
||||||
|
time="2024-09-26T22:10:13.924972560+08:00" level=info msg="loading plugin \"io.containerd.internal.v1.shutdown\"..." runtime=io.containerd.runc.v2 type=io.containerd.internal.v1
|
||||||
|
time="2024-09-26T22:10:13.924982339+08:00" level=info msg="loading plugin \"io.containerd.ttrpc.v1.task\"..." runtime=io.containerd.runc.v2 type=io.containerd.ttrpc.v1
|
||||||
|
time="2024-09-26T22:10:13.925516687+08:00" level=info msg="loading plugin \"io.containerd.ttrpc.v1.pause\"..." runtime=io.containerd.runc.v2 type=io.containerd.ttrpc.v1
|
||||||
|
time="2024-09-26T22:10:14.208176453+08:00" level=info msg="shim disconnected" id=e145f3df1dddfc96034a1baa04e74de7ccdde60afd4338fa72e0876d22fcf584 namespace=moby
|
||||||
|
time="2024-09-26T22:10:14.208307628+08:00" level=warning msg="cleaning up after shim disconnected" id=e145f3df1dddfc96034a1baa04e74de7ccdde60afd4338fa72e0876d22fcf584 namespace=moby
|
||||||
|
time="2024-09-26T22:10:14.208325012+08:00" level=info msg="cleaning up dead shim" namespace=moby
|
||||||
|
time="2024-09-26T22:10:14.208306065+08:00" level=info msg="ignoring event" container=e145f3df1dddfc96034a1baa04e74de7ccdde60afd4338fa72e0876d22fcf584 module=libcontainerd namespace=moby topic=/tasks/delete type="*events.TaskDelete"
|
||||||
|
time="2024-09-26T22:11:13.512588582+08:00" level=info msg="Attempting next endpoint for pull after error: manifest unknown" spanID=eb934e7ce3cd1083 traceID=17ccb05069dbebd6bd5fb11dc63e19a3
|
||||||
|
time="2024-09-26T22:11:13.516805407+08:00" level=error msg="Handler for POST /v1.47/images/create returned error: manifest unknown" spanID=eb934e7ce3cd1083 traceID=17ccb05069dbebd6bd5fb11dc63e19a3
|
||||||
|
time="2024-09-26T22:12:36.723554394+08:00" level=info msg="Starting up"
|
||||||
|
failed to start daemon, ensure docker is not running or delete /var/run/docker.pid: process with PID 45288 is still running
|
||||||
|
time="2024-09-26T22:12:45.468726560+08:00" level=info msg="Attempting next endpoint for pull after error: manifest unknown" spanID=010270fb339b6bf1 traceID=01d5a0c9dae25828e5d77b55d882882d
|
||||||
|
time="2024-09-26T22:12:45.472831049+08:00" level=error msg="Handler for POST /v1.47/images/create returned error: manifest unknown" spanID=010270fb339b6bf1 traceID=01d5a0c9dae25828e5d77b55d882882d
|
||||||
|
time="2024-09-26T22:15:11.861644651+08:00" level=info msg="Attempting next endpoint for pull after error: manifest unknown" spanID=118c45205f702a06 traceID=b0b11dd284ebbabd278b615651c974b5
|
||||||
|
time="2024-09-26T22:15:11.865851123+08:00" level=error msg="Handler for POST /v1.47/images/create returned error: manifest unknown" spanID=118c45205f702a06 traceID=b0b11dd284ebbabd278b615651c974b5
|
||||||
|
time="2024-09-26T22:17:02.729973112+08:00" level=error msg=/moby.buildkit.v1.Control/Solve error="rpc error: code = Unknown desc = lstat /lib: no such file or directory" spanID=db91626bb053461d traceID=f545117fa69de86c0a735d077a4655cf
|
||||||
|
2024/09/26 22:18:24 http2: server: error reading preface from client @: read unix /var/run/docker.sock->@: read: connection reset by peer
|
||||||
|
time="2024-09-26T22:18:24.883408806+08:00" level=info msg="trying next host - response was http.StatusNotFound" host=git.mamahaha.work spanID=e8c18cc4d36ed288 traceID=e0d10168bfd3754ac405bd3730c906c2
|
||||||
|
time="2024-09-26T22:18:24.889765971+08:00" level=error msg=/moby.buildkit.v1.frontend.LLBBridge/Solve error="rpc error: code = Unknown desc = git.mamahaha.work/sangge/tpre:base: failed to resolve source metadata for git.mamahaha.work/sangge/tpre:base: git.mamahaha.work/sangge/tpre:base: not found" spanID=e8c18cc4d36ed288 traceID=e0d10168bfd3754ac405bd3730c906c2
|
||||||
|
time="2024-09-26T22:18:24.948107279+08:00" level=error msg=/moby.buildkit.v1.Control/Solve error="rpc error: code = Unknown desc = git.mamahaha.work/sangge/tpre:base: failed to resolve source metadata for git.mamahaha.work/sangge/tpre:base: git.mamahaha.work/sangge/tpre:base: not found" spanID=aed2df82e313df3d traceID=e0d10168bfd3754ac405bd3730c906c2
|
||||||
|
2024/09/26 22:34:37 http2: server: error reading preface from client @: read unix /var/run/docker.sock->@: read: connection reset by peer
|
||||||
|
time="2024-09-26T22:34:38.136241507+08:00" level=error msg=/moby.buildkit.v1.frontend.LLBBridge/Solve error="rpc error: code = Unknown desc = failed to read dockerfile: open basedockerfile: no such file or directory" spanID=d177794390f72646 traceID=0b2bda7d4db3a220d8610b454cfddd62
|
||||||
|
time="2024-09-26T22:34:38.200736040+08:00" level=error msg=/moby.buildkit.v1.Control/Solve error="rpc error: code = Unknown desc = failed to read dockerfile: open basedockerfile: no such file or directory" spanID=cfb0b0b47bbb82ac traceID=0b2bda7d4db3a220d8610b454cfddd62
|
||||||
|
time="2024-09-26T22:35:23.594742365+08:00" level=error msg=/moby.buildkit.v1.frontend.LLBBridge/Solve error="rpc error: code = Unknown desc = failed to read dockerfile: open basedockerfile: no such file or directory" spanID=411a8c674f1ecd0b traceID=0e3ebe9898abf6c9c73f79e433927e1f
|
||||||
|
time="2024-09-26T22:35:23.645847397+08:00" level=error msg=/moby.buildkit.v1.Control/Solve error="rpc error: code = Unknown desc = failed to read dockerfile: open basedockerfile: no such file or directory" spanID=da72a8db0b2e384f traceID=0e3ebe9898abf6c9c73f79e433927e1f
|
||||||
|
time="2024-09-26T22:36:08.441647831+08:00" level=error msg=/moby.buildkit.v1.Control/Solve error="rpc error: code = Unknown desc = lstat /lib: no such file or directory" spanID=91939050af2dbd1f traceID=c9e913c83fcae0c7f69b76d567b07de3
|
||||||
|
time="2024-09-26T23:07:47.840212311+08:00" level=info msg="Attempting next endpoint for pull after error: manifest unknown" spanID=aab848f5367186bd traceID=eebdeacdd619ad271f4aebbb50f677a8
|
||||||
|
time="2024-09-26T23:07:47.847177330+08:00" level=error msg="Handler for POST /v1.47/images/create returned error: manifest unknown" spanID=aab848f5367186bd traceID=eebdeacdd619ad271f4aebbb50f677a8
|
||||||
|
time="2024-09-26T23:08:34.972228920+08:00" level=info msg="Got signal to reload configuration, reloading from: /etc/docker/daemon.json"
|
||||||
|
time="2024-09-26T23:08:34.993038120+08:00" level=info msg="Reloaded configuration: {\"exec-opts\":[\"native.cgroupdriver=cgroupfs\"],\"pidfile\":\"/var/run/docker.pid\",\"data-root\":\"/var/lib/docker\",\"exec-root\":\"/var/run/docker\",\"group\":\"docker\",\"max-concurrent-downloads\":3,\"max-concurrent-uploads\":5,\"max-download-attempts\":5,\"shutdown-timeout\":15,\"hosts\":[\"unix:///var/run/docker.sock\"],\"log-level\":\"info\",\"log-format\":\"text\",\"swarm-default-advertise-addr\":\"\",\"swarm-raft-heartbeat-tick\":0,\"swarm-raft-election-tick\":0,\"metrics-addr\":\"\",\"host-gateway-ip\":\"172.17.0.1\",\"log-driver\":\"json-file\",\"mtu\":1500,\"ip\":\"0.0.0.0\",\"icc\":true,\"iptables\":true,\"ip6tables\":true,\"ip-forward\":true,\"ip-masq\":true,\"userland-proxy\":true,\"userland-proxy-path\":\"/usr/bin/docker-proxy\",\"default-address-pools\":{\"Values\":null},\"network-control-plane-mtu\":1500,\"registry-mirrors\":[\"https://docker.m.daocloud.io\",\"https://dockerproxy.com\",\"https://docker.mirrors.ustc.edu.cn\",\"https://docker.nju.edu.cn\",\"https://ma2gfhbf.mirror.aliyuncs.com\",\"https://hub-mirror.c.163.com\",\"https://reg-mirror.qiniu.com\"],\"experimental\":false,\"containerd\":\"/var/run/docker/containerd/containerd.sock\",\"builder\":{\"GC\":{},\"Entitlements\":{}},\"containerd-namespace\":\"moby\",\"containerd-plugin-namespace\":\"plugins.moby\",\"default-runtime\":\"runc\",\"cgroup-parent\":\"system.slice\",\"seccomp-profile\":\"builtin\",\"default-shm-size\":67108864,\"default-ipc-mode\":\"private\",\"default-cgroupns-mode\":\"private\",\"resolv-conf\":\"/etc/resolv.conf\",\"proxies\":{}}"
|
||||||
|
time="2024-09-26T23:09:10.633349061+08:00" level=info msg="loading plugin \"io.containerd.event.v1.publisher\"..." runtime=io.containerd.runc.v2 type=io.containerd.event.v1
|
||||||
|
time="2024-09-26T23:09:10.633410449+08:00" level=info msg="loading plugin \"io.containerd.internal.v1.shutdown\"..." runtime=io.containerd.runc.v2 type=io.containerd.internal.v1
|
||||||
|
time="2024-09-26T23:09:10.633420098+08:00" level=info msg="loading plugin \"io.containerd.ttrpc.v1.task\"..." runtime=io.containerd.runc.v2 type=io.containerd.ttrpc.v1
|
||||||
|
time="2024-09-26T23:09:10.633888806+08:00" level=info msg="loading plugin \"io.containerd.ttrpc.v1.pause\"..." runtime=io.containerd.runc.v2 type=io.containerd.ttrpc.v1
|
||||||
|
time="2024-09-26T23:09:18.906669563+08:00" level=info msg="ignoring event" container=913911af5cea5667fc01c1349966bc05f98b0a0f54b1d33bce8c243f140d822f module=libcontainerd namespace=moby topic=/tasks/delete type="*events.TaskDelete"
|
||||||
|
time="2024-09-26T23:09:18.907456952+08:00" level=info msg="shim disconnected" id=913911af5cea5667fc01c1349966bc05f98b0a0f54b1d33bce8c243f140d822f namespace=moby
|
||||||
|
time="2024-09-26T23:09:18.909304706+08:00" level=warning msg="cleaning up after shim disconnected" id=913911af5cea5667fc01c1349966bc05f98b0a0f54b1d33bce8c243f140d822f namespace=moby
|
||||||
|
time="2024-09-26T23:09:18.909702333+08:00" level=info msg="cleaning up dead shim" namespace=moby
|
||||||
|
time="2024-09-26T23:09:18.922724497+08:00" level=warning msg="failed to close stdin: NotFound: task 913911af5cea5667fc01c1349966bc05f98b0a0f54b1d33bce8c243f140d822f not found: not found"
|
||||||
|
@ -0,0 +1,76 @@
|
|||||||
|
# 测试 node.py 中的函数
|
||||||
|
import os
|
||||||
|
import unittest
|
||||||
|
from unittest.mock import patch, MagicMock, Mock
|
||||||
|
import node
|
||||||
|
|
||||||
|
class TestGetLocalIP(unittest.TestCase):
|
||||||
|
|
||||||
|
@patch.dict('os.environ', {'HOST_IP': '60.204.193.58'}) # 模拟设置 HOST_IP 环境变量
|
||||||
|
def test_get_ip_from_env(self):
|
||||||
|
# 调用被测函数
|
||||||
|
node.get_local_ip()
|
||||||
|
|
||||||
|
# 检查函数是否正确获取到 HOST_IP
|
||||||
|
self.assertEqual(node.ip, '60.204.193.58')
|
||||||
|
|
||||||
|
@patch('socket.socket') # Mock socket 连接行为
|
||||||
|
@patch.dict('os.environ', {}) # 模拟没有 HOST_IP 环境变量
|
||||||
|
def test_get_ip_from_socket(self, mock_socket):
|
||||||
|
# 模拟 socket 返回的 IP 地址
|
||||||
|
mock_socket_instance = MagicMock()
|
||||||
|
mock_socket.return_value = mock_socket_instance
|
||||||
|
mock_socket_instance.getsockname.return_value = ('110.41.155.96', 0)
|
||||||
|
|
||||||
|
# 调用被测函数
|
||||||
|
node.get_local_ip()
|
||||||
|
|
||||||
|
# 确认 socket 被调用过
|
||||||
|
mock_socket_instance.connect.assert_called_with(('8.8.8.8', 80))
|
||||||
|
mock_socket_instance.close.assert_called_once()
|
||||||
|
|
||||||
|
# 检查是否通过 socket 获取到正确的 IP 地址
|
||||||
|
self.assertEqual(node.ip, '110.41.155.96')
|
||||||
|
|
||||||
|
class TestSendIP(unittest.TestCase):
|
||||||
|
@patch.dict(os.environ, {'HOST_IP': '60.204.193.58'}) # 设置环境变量 HOST_IP
|
||||||
|
@patch('requests.get') # Mock requests.get 调用
|
||||||
|
def test_send_ip(self, mock_get):
|
||||||
|
# 设置模拟返回的 HTTP 响应
|
||||||
|
mock_response = Mock()
|
||||||
|
mock_response.text = "node123" # 模拟返回的节点ID
|
||||||
|
mock_response.status_code = 200
|
||||||
|
mock_get.return_value = mock_response # 设置 requests.get() 的返回值为 mock_response
|
||||||
|
|
||||||
|
# 保存原始的全局 id 值
|
||||||
|
original_id = node.id
|
||||||
|
|
||||||
|
# 调用待测函数
|
||||||
|
node.send_ip()
|
||||||
|
|
||||||
|
# 确保 requests.get 被正确调用
|
||||||
|
expected_url = f"{node.server_address}/get_node?ip={node.ip}"
|
||||||
|
mock_get.assert_called_once_with(expected_url, timeout=3)
|
||||||
|
|
||||||
|
# 检查 id 是否被正确更新
|
||||||
|
self.assertIs(node.id, mock_response) # 检查 id 是否被修改
|
||||||
|
self.assertEqual(node.id.text, "node123") # 检查更新后的 id 是否与 mock_response.text 匹配
|
||||||
|
|
||||||
|
class TestNode(unittest.TestCase):
|
||||||
|
|
||||||
|
@patch('node.send_ip')
|
||||||
|
@patch('node.get_local_ip')
|
||||||
|
@patch('node.asyncio.create_task')
|
||||||
|
def test_init(self, mock_create_task, mock_get_local_ip, mock_send_ip):
|
||||||
|
# 调用 init 函数
|
||||||
|
node.init()
|
||||||
|
|
||||||
|
# 验证 get_local_ip 和 send_ip 被调用
|
||||||
|
mock_get_local_ip.assert_called_once()
|
||||||
|
mock_send_ip.assert_called_once()
|
||||||
|
|
||||||
|
# 确保 create_task 被调用来启动心跳包
|
||||||
|
mock_create_task.assert_called_once()
|
||||||
|
|
||||||
|
if __name__ == '__main__':
|
||||||
|
unittest.main()
|
@ -1,35 +0,0 @@
|
|||||||
#测试 get_local_ip()函数
|
|
||||||
import unittest
|
|
||||||
from unittest.mock import patch, MagicMock
|
|
||||||
import node
|
|
||||||
|
|
||||||
class TestGetLocalIP(unittest.TestCase):
|
|
||||||
|
|
||||||
@patch.dict('os.environ', {'HOST_IP': '60.204.193.58'}) # 模拟设置 HOST_IP 环境变量
|
|
||||||
def test_get_ip_from_env(self):
|
|
||||||
# 调用被测函数
|
|
||||||
node.get_local_ip()
|
|
||||||
|
|
||||||
# 检查函数是否正确获取到 HOST_IP
|
|
||||||
self.assertEqual(node.ip, '60.204.193.58')
|
|
||||||
|
|
||||||
@patch('socket.socket') # Mock socket 连接行为
|
|
||||||
@patch.dict('os.environ', {}) # 模拟没有 HOST_IP 环境变量
|
|
||||||
def test_get_ip_from_socket(self, mock_socket):
|
|
||||||
# 模拟 socket 返回的 IP 地址
|
|
||||||
mock_socket_instance = MagicMock()
|
|
||||||
mock_socket.return_value = mock_socket_instance
|
|
||||||
mock_socket_instance.getsockname.return_value = ('110.41.155.96', 0)
|
|
||||||
|
|
||||||
# 调用被测函数
|
|
||||||
node.get_local_ip()
|
|
||||||
|
|
||||||
# 确认 socket 被调用过
|
|
||||||
mock_socket_instance.connect.assert_called_with(('8.8.8.8', 80))
|
|
||||||
mock_socket_instance.close.assert_called_once()
|
|
||||||
|
|
||||||
# 检查是否通过 socket 获取到正确的 IP 地址
|
|
||||||
self.assertEqual(node.ip, '110.41.155.96')
|
|
||||||
|
|
||||||
if __name__ == '__main__':
|
|
||||||
unittest.main()
|
|
@ -1,34 +0,0 @@
|
|||||||
#测试send_ip()函数
|
|
||||||
import os
|
|
||||||
import unittest
|
|
||||||
from unittest.mock import patch, Mock
|
|
||||||
import node # 导入要测试的模块
|
|
||||||
|
|
||||||
class TestSendIP(unittest.TestCase):
|
|
||||||
@patch.dict(os.environ, {'HOST_IP': '60.204.193.58'}) # 设置环境变量 HOST_IP
|
|
||||||
@patch('requests.get') # Mock requests.get 调用
|
|
||||||
def test_send_ip(self, mock_get):
|
|
||||||
# 设置模拟返回的 HTTP 响应
|
|
||||||
mock_response = Mock()
|
|
||||||
mock_response.text = "node123" # 模拟返回的节点ID
|
|
||||||
mock_response.status_code = 200
|
|
||||||
mock_get.return_value = mock_response # 设置 requests.get() 的返回值为 mock_response
|
|
||||||
|
|
||||||
# 保存原始的全局 id 值
|
|
||||||
original_id = node.id
|
|
||||||
|
|
||||||
# 调用待测函数
|
|
||||||
node.send_ip()
|
|
||||||
|
|
||||||
# 确保 requests.get 被正确调用
|
|
||||||
expected_url = f"{node.server_address}/get_node?ip={node.ip}"
|
|
||||||
mock_get.assert_called_once_with(expected_url, timeout=3)
|
|
||||||
|
|
||||||
# 检查 id 是否被正确更新
|
|
||||||
self.assertIs(node.id, mock_response) # 检查 id 是否被修改
|
|
||||||
self.assertEqual(node.id.text, "node123") # 检查更新后的 id 是否与 mock_response.text 匹配
|
|
||||||
|
|
||||||
if __name__ == "__main__":
|
|
||||||
unittest.main()
|
|
||||||
#node.py中
|
|
||||||
#print("中心服务器返回节点ID为: ", id.text)即可看到测试代码返回的节点
|
|
@ -1,23 +0,0 @@
|
|||||||
#测试init()函数
|
|
||||||
import unittest
|
|
||||||
from unittest.mock import patch, AsyncMock
|
|
||||||
import node
|
|
||||||
|
|
||||||
class TestNode(unittest.TestCase):
|
|
||||||
|
|
||||||
@patch('node.send_ip')
|
|
||||||
@patch('node.get_local_ip')
|
|
||||||
@patch('node.asyncio.create_task')
|
|
||||||
def test_init(self, mock_create_task, mock_get_local_ip, mock_send_ip):
|
|
||||||
# 调用 init 函数
|
|
||||||
node.init()
|
|
||||||
|
|
||||||
# 验证 get_local_ip 和 send_ip 被调用
|
|
||||||
mock_get_local_ip.assert_called_once()
|
|
||||||
mock_send_ip.assert_called_once()
|
|
||||||
|
|
||||||
# 确保 create_task 被调用来启动心跳包
|
|
||||||
mock_create_task.assert_called_once()
|
|
||||||
|
|
||||||
if __name__ == '__main__':
|
|
||||||
unittest.main()
|
|
@ -1,22 +1,92 @@
|
|||||||
|
#node_test剩下部分(有问题)
|
||||||
|
import os
|
||||||
|
import unittest
|
||||||
import pytest
|
import pytest
|
||||||
|
from unittest.mock import patch, MagicMock, Mock, AsyncMock
|
||||||
|
import requests
|
||||||
|
import asyncio
|
||||||
import httpx
|
import httpx
|
||||||
import respx
|
import respx
|
||||||
import asyncio
|
|
||||||
from unittest.mock import patch, AsyncMock
|
|
||||||
from fastapi.testclient import TestClient
|
from fastapi.testclient import TestClient
|
||||||
from node import app, send_heartbeat_internal, Req
|
from node import app, send_heartbeat_internal, Req, send_ip, get_local_ip, init, clear, send_user_des_message
|
||||||
|
|
||||||
client = TestClient(app)
|
client = TestClient(app)
|
||||||
server_address = "http://60.204.236.38:8000/server"
|
server_address = "http://60.204.236.38:8000/server"
|
||||||
ip = "127.0.0.1"
|
ip = None # 初始化全局变量 ip
|
||||||
|
id = None # 初始化全局变量 id
|
||||||
|
|
||||||
@pytest.fixture(scope="session")
|
class TestGetLocalIP(unittest.TestCase):
|
||||||
def anyio_backend():
|
|
||||||
return "asyncio"
|
@patch.dict('os.environ', {'HOST_IP': '60.204.193.58'}) # 模拟设置 HOST_IP 环境变量
|
||||||
|
def test_get_ip_from_env(self):
|
||||||
|
global ip
|
||||||
|
# 调用被测函数
|
||||||
|
get_local_ip()
|
||||||
|
|
||||||
|
# 检查函数是否正确获取到 HOST_IP
|
||||||
|
self.assertEqual(ip, '60.204.193.58')
|
||||||
|
|
||||||
|
@patch('socket.socket') # Mock socket 连接行为
|
||||||
|
@patch.dict('os.environ', {}) # 模拟没有 HOST_IP 环境变量
|
||||||
|
def test_get_ip_from_socket(self, mock_socket):
|
||||||
|
global ip
|
||||||
|
# 模拟 socket 返回的 IP 地址
|
||||||
|
mock_socket_instance = MagicMock()
|
||||||
|
mock_socket.return_value = mock_socket_instance
|
||||||
|
mock_socket_instance.getsockname.return_value = ('110.41.155.96', 0)
|
||||||
|
|
||||||
|
# 调用被测函数
|
||||||
|
get_local_ip()
|
||||||
|
|
||||||
|
# 确认 socket 被调用过
|
||||||
|
mock_socket_instance.connect.assert_called_with(('8.8.8.8', 80))
|
||||||
|
mock_socket_instance.close.assert_called_once()
|
||||||
|
|
||||||
|
# 检查是否通过 socket 获取到正确的 IP 地址
|
||||||
|
self.assertEqual(ip, '110.41.155.96')
|
||||||
|
|
||||||
|
class TestSendIP(unittest.TestCase):
|
||||||
|
@patch.dict(os.environ, {'HOST_IP': '60.204.193.58'}) # 设置环境变量 HOST_IP
|
||||||
|
@respx.mock
|
||||||
|
def test_send_ip(self):
|
||||||
|
global ip, id
|
||||||
|
ip = '60.204.193.58'
|
||||||
|
mock_url = f"{server_address}/get_node?ip={ip}"
|
||||||
|
respx.get(mock_url).mock(return_value=httpx.Response(200, text="node123"))
|
||||||
|
|
||||||
|
# 调用待测函数
|
||||||
|
send_ip()
|
||||||
|
|
||||||
|
# 确保 requests.get 被正确调用
|
||||||
|
self.assertEqual(id, "node123") # 检查更新后的 id 是否与 mock_response.text 匹配
|
||||||
|
|
||||||
|
class TestNode(unittest.TestCase):
|
||||||
|
|
||||||
|
@patch('node.send_ip')
|
||||||
|
@patch('node.get_local_ip')
|
||||||
|
@patch('node.asyncio.create_task')
|
||||||
|
def test_init(self, mock_create_task, mock_get_local_ip, mock_send_ip):
|
||||||
|
# 调用 init 函数
|
||||||
|
init()
|
||||||
|
|
||||||
|
# 验证 get_local_ip 和 send_ip 被调用
|
||||||
|
mock_get_local_ip.assert_called_once()
|
||||||
|
mock_send_ip.assert_called_once()
|
||||||
|
|
||||||
|
# 确保 create_task 被调用来启动心跳包
|
||||||
|
mock_create_task.assert_called_once()
|
||||||
|
|
||||||
|
def test_clear(self):
|
||||||
|
# 调用 clear 函数
|
||||||
|
clear()
|
||||||
|
# 检查输出
|
||||||
|
self.assertTrue(True) # 这里只是为了确保函数被调用,没有实际逻辑需要测试
|
||||||
|
|
||||||
@pytest.mark.asyncio
|
@pytest.mark.asyncio
|
||||||
@respx.mock
|
@respx.mock
|
||||||
async def test_send_heartbeat_internal_success():
|
async def test_send_heartbeat_internal_success():
|
||||||
|
global ip
|
||||||
|
ip = '60.204.193.58'
|
||||||
# 模拟心跳请求
|
# 模拟心跳请求
|
||||||
heartbeat_route = respx.get(f"{server_address}/heartbeat?ip={ip}").mock(
|
heartbeat_route = respx.get(f"{server_address}/heartbeat?ip={ip}").mock(
|
||||||
return_value=httpx.Response(200)
|
return_value=httpx.Response(200)
|
||||||
@ -40,6 +110,8 @@ async def test_send_heartbeat_internal_success():
|
|||||||
@pytest.mark.asyncio
|
@pytest.mark.asyncio
|
||||||
@respx.mock
|
@respx.mock
|
||||||
async def test_send_heartbeat_internal_failure():
|
async def test_send_heartbeat_internal_failure():
|
||||||
|
global ip
|
||||||
|
ip = '60.204.193.58'
|
||||||
# 模拟心跳请求以引发异常
|
# 模拟心跳请求以引发异常
|
||||||
heartbeat_route = respx.get(f"{server_address}/heartbeat?ip={ip}").mock(
|
heartbeat_route = respx.get(f"{server_address}/heartbeat?ip={ip}").mock(
|
||||||
side_effect=httpx.RequestError("Central server error")
|
side_effect=httpx.RequestError("Central server error")
|
||||||
@ -66,8 +138,8 @@ def test_user_src():
|
|||||||
# 模拟 send_user_des_message 函数
|
# 模拟 send_user_des_message 函数
|
||||||
with patch("node.send_user_des_message", new_callable=AsyncMock) as mock_send_user_des_message:
|
with patch("node.send_user_des_message", new_callable=AsyncMock) as mock_send_user_des_message:
|
||||||
message = {
|
message = {
|
||||||
"source_ip": "127.0.0.1",
|
"source_ip": "60.204.193.58",
|
||||||
"dest_ip": "127.0.0.2",
|
"dest_ip": "60.204.193.59",
|
||||||
"capsule": (("x1", "y1"), ("x2", "y2"), 123),
|
"capsule": (("x1", "y1"), ("x2", "y2"), 123),
|
||||||
"ct": 456,
|
"ct": 456,
|
||||||
"rk": ["rk1", "rk2"]
|
"rk": ["rk1", "rk2"]
|
||||||
@ -79,11 +151,14 @@ def test_user_src():
|
|||||||
|
|
||||||
def test_send_user_des_message():
|
def test_send_user_des_message():
|
||||||
with respx.mock:
|
with respx.mock:
|
||||||
dest_ip = "127.0.0.2"
|
dest_ip = "60.204.193.59"
|
||||||
re_message = (("a", "b", "c", "d"), 123)
|
re_message = (("a", "b", "c", "d"), 123)
|
||||||
respx.post(f"http://{dest_ip}:8002/receive_messages").mock(
|
respx.post(f"http://{dest_ip}:8002/receive_messages").mock(
|
||||||
return_value=httpx.Response(200, json={"status": "success"})
|
return_value=httpx.Response(200, json={"status": "success"})
|
||||||
)
|
)
|
||||||
response = client.post(f"http://{dest_ip}:8002/receive_messages", json={"Tuple": re_message, "ip": "127.0.0.1"})
|
response = requests.post(f"http://{dest_ip}:8002/receive_messages", json={"Tuple": re_message, "ip": "60.204.193.58"})
|
||||||
assert response.status_code == 200
|
assert response.status_code == 200
|
||||||
assert response.json() == {"status": "success"}
|
assert response.json() == {"status": "success"}
|
||||||
|
|
||||||
|
if __name__ == '__main__':
|
||||||
|
unittest.main()
|
Loading…
x
Reference in New Issue
Block a user