Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
D
Distributed Computing and Network Fusion System
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
3
Issues
3
List
Boards
Labels
Milestones
Merge Requests
1
Merge Requests
1
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
WirelessInformationCollaborate
Distributed Computing and Network Fusion System
Commits
3c8e74e7
Commit
3c8e74e7
authored
Jun 27, 2020
by
joliu
Browse files
Options
Browse Files
Download
Plain Diff
Merge branch '10-utils-starter' into 'feature-cnf'
Resolve "utils starter化" See merge request
xidiancos/cnf!6
parents
028a177e
318e4a90
Pipeline
#14
passed with stage
in 0 seconds
Changes
15
Pipelines
1
Show whitespace changes
Inline
Side-by-side
Showing
15 changed files
with
93 additions
and
102 deletions
+93
-102
cnf-edge-center/src/main/resources/application.yaml
cnf-edge-center/src/main/resources/application.yaml
+3
-0
cnf-utils/pom.xml
cnf-utils/pom.xml
+14
-2
cnf-utils/src/main/java/top/ninwoo/utils/config/CNFUtilsAutoConfiguration.java
...va/top/ninwoo/utils/config/CNFUtilsAutoConfiguration.java
+3
-1
cnf-utils/src/main/java/top/ninwoo/utils/config/UtilsProperties.java
...rc/main/java/top/ninwoo/utils/config/UtilsProperties.java
+16
-0
cnf-utils/src/main/java/top/ninwoo/utils/util/impl/OvsDockerUtilsImpl.java
...n/java/top/ninwoo/utils/util/impl/OvsDockerUtilsImpl.java
+7
-2
cnf-utils/src/main/java/top/ninwoo/utils/util/impl/OvsUtilsImpl.java
...rc/main/java/top/ninwoo/utils/util/impl/OvsUtilsImpl.java
+15
-12
cnf-utils/src/test/java/top/ninwoo/utils/DockerServiceTests.java
...ls/src/test/java/top/ninwoo/utils/DockerServiceTests.java
+2
-2
cnf-utils/src/test/java/top/ninwoo/utils/DockerUtilsTest.java
...utils/src/test/java/top/ninwoo/utils/DockerUtilsTest.java
+26
-5
cnf-utils/src/test/java/top/ninwoo/utils/EntityTests.java
cnf-utils/src/test/java/top/ninwoo/utils/EntityTests.java
+0
-9
cnf-utils/src/test/java/top/ninwoo/utils/IptablesServiceTests.java
.../src/test/java/top/ninwoo/utils/IptablesServiceTests.java
+0
-21
cnf-utils/src/test/java/top/ninwoo/utils/IptablesUtilsTests.java
...ls/src/test/java/top/ninwoo/utils/IptablesUtilsTests.java
+2
-2
cnf-utils/src/test/java/top/ninwoo/utils/OVSServiceTests.java
...utils/src/test/java/top/ninwoo/utils/OVSServiceTests.java
+2
-3
cnf-utils/src/test/java/top/ninwoo/utils/OsUtilsTests.java
cnf-utils/src/test/java/top/ninwoo/utils/OsUtilsTests.java
+3
-3
cnf-utils/src/test/java/top/ninwoo/utils/SpringMain.java
cnf-utils/src/test/java/top/ninwoo/utils/SpringMain.java
+0
-12
cnf-utils/src/test/java/top/ninwoo/utils/TcUtilsTests.java
cnf-utils/src/test/java/top/ninwoo/utils/TcUtilsTests.java
+0
-28
No files found.
cnf-edge-center/src/main/resources/application.yaml
View file @
3c8e74e7
...
...
@@ -32,3 +32,6 @@ bs:
port
:
6653
zookeeper
:
url
:
zk.cnf.org:2181
cnf
:
passwd
:
Vudo3423
cnf-utils/pom.xml
View file @
3c8e74e7
...
...
@@ -20,9 +20,21 @@
<dependencies>
<dependency>
<groupId>
org.springframework
</groupId>
<artifactId>
spring-context
</artifactId>
<groupId>
org.springframework.boot
</groupId>
<artifactId>
spring-boot-starter
</artifactId>
</dependency>
<dependency>
<groupId>
org.projectlombok
</groupId>
<artifactId>
lombok
</artifactId>
</dependency>
<dependency>
<groupId>
org.springframework.boot
</groupId>
<artifactId>
spring-boot-configuration-processor
</artifactId>
<optional>
true
</optional>
</dependency>
<dependency>
<groupId>
junit
</groupId>
<artifactId>
junit
</artifactId>
...
...
cnf-utils/src/main/java/top/ninwoo/utils/config/
DockerConfig
.java
→
cnf-utils/src/main/java/top/ninwoo/utils/config/
CNFUtilsAutoConfiguration
.java
View file @
3c8e74e7
...
...
@@ -2,6 +2,7 @@ package top.ninwoo.utils.config;
import
com.spotify.docker.client.DefaultDockerClient
;
import
com.spotify.docker.client.DockerClient
;
import
org.springframework.boot.context.properties.EnableConfigurationProperties
;
import
org.springframework.context.annotation.Bean
;
import
org.springframework.context.annotation.ComponentScan
;
import
org.springframework.context.annotation.Configuration
;
...
...
@@ -10,7 +11,8 @@ import java.net.URI;
@Configuration
@ComponentScan
(
"top.ninwoo.utils"
)
public
class
DockerConfig
{
@EnableConfigurationProperties
(
UtilsProperties
.
class
)
public
class
CNFUtilsAutoConfiguration
{
@Bean
(
destroyMethod
=
"close"
)
public
DockerClient
dockerClient
()
{
return
DefaultDockerClient
.
builder
()
...
...
cnf-utils/src/main/java/top/ninwoo/utils/config/UtilsProperties.java
0 → 100644
View file @
3c8e74e7
package
top.ninwoo.utils.config
;
import
org.springframework.boot.context.properties.ConfigurationProperties
;
@ConfigurationProperties
(
prefix
=
"cnf.utils"
)
public
class
UtilsProperties
{
private
String
passwd
=
"Vudo3423"
;
public
String
getPasswd
()
{
return
passwd
;
}
public
void
setPasswd
(
String
passwd
)
{
this
.
passwd
=
passwd
;
}
}
cnf-utils/src/main/java/top/ninwoo/utils/util/impl/OvsDockerUtilsImpl.java
View file @
3c8e74e7
...
...
@@ -3,6 +3,7 @@ package top.ninwoo.utils.util.impl;
import
org.slf4j.Logger
;
import
org.slf4j.LoggerFactory
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.beans.factory.annotation.Value
;
import
top.ninwoo.utils.util.LinuxCtlUtils
;
import
top.ninwoo.utils.util.OvsDockerUtils
;
import
top.ninwoo.utils.util.Utils
;
...
...
@@ -15,13 +16,17 @@ import top.ninwoo.utils.util.Utils;
@Utils
public
class
OvsDockerUtilsImpl
implements
OvsDockerUtils
{
private
static
Logger
LOG
=
LoggerFactory
.
getLogger
(
OvsDockerUtilsImpl
.
class
);
@Value
(
"${cnf.passwd}"
)
private
String
passwd
;
@Autowired
LinuxCtlUtils
linuxCtlUtils
;
@Override
public
String
addPort
(
String
bridgeName
,
String
devName
,
String
containerId
,
String
ip
)
{
String
cmd
=
"ovs-docker add-port "
+
bridgeName
String
cmd
=
"
echo '"
+
passwd
+
"' | sudo -S
ovs-docker add-port "
+
bridgeName
+
" "
+
devName
+
" "
+
containerId
+
" --ipaddress="
+
ip
;
String
res
=
linuxCtlUtils
.
runCmd
(
cmd
);
if
(
res
.
contains
(
"Error"
))
{
...
...
@@ -37,7 +42,7 @@ public class OvsDockerUtilsImpl implements OvsDockerUtils {
@Override
public
String
delPort
(
String
bridgeName
,
String
devName
,
String
containerId
)
{
String
cmd
=
"ovs-docker del-port "
+
bridgeName
+
" "
String
cmd
=
"
echo '"
+
passwd
+
"' | sudo -S
ovs-docker del-port "
+
bridgeName
+
" "
+
devName
+
" "
+
containerId
;
return
linuxCtlUtils
.
runCmd
(
cmd
);
...
...
cnf-utils/src/main/java/top/ninwoo/utils/util/impl/OvsUtilsImpl.java
View file @
3c8e74e7
...
...
@@ -3,6 +3,7 @@ package top.ninwoo.utils.util.impl;
import
org.slf4j.Logger
;
import
org.slf4j.LoggerFactory
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.beans.factory.annotation.Value
;
import
top.ninwoo.utils.entity.BridgePort
;
import
top.ninwoo.utils.entity.Ovs
;
import
top.ninwoo.utils.entity.OvsBridge
;
...
...
@@ -26,11 +27,13 @@ public class OvsUtilsImpl implements OvsUtils {
private
final
AtomicInteger
atomicInteger
=
new
AtomicInteger
(
0
);
@Autowired
LinuxCtlUtils
linuxCtlUtils
;
@Value
(
"${cnf.passwd}"
)
private
String
passwd
;
@Override
public
boolean
isInstall
()
{
// 可能会遇到权限问题
String
s
=
linuxCtlUtils
.
runCmd
(
"ovs-vsctl --version"
);
String
s
=
linuxCtlUtils
.
runCmd
(
"
echo '"
+
passwd
+
"' | sudo -S
ovs-vsctl --version"
);
if
(
s
.
contains
(
"Error"
))
{
return
false
;
}
else
{
...
...
@@ -40,7 +43,7 @@ public class OvsUtilsImpl implements OvsUtils {
@Override
public
Ovs
showDetails
()
{
String
res
=
linuxCtlUtils
.
runCmd
(
"ovs-vsctl show"
);
String
res
=
linuxCtlUtils
.
runCmd
(
"
echo '"
+
passwd
+
"' | sudo -S
ovs-vsctl show"
);
Ovs
ovs
=
parseOvsString
(
res
);
return
ovs
;
...
...
@@ -128,7 +131,7 @@ public class OvsUtilsImpl implements OvsUtils {
@Override
public
void
addBridge
(
String
name
)
{
String
cmd
=
"ovs-vsctl add-br "
+
name
;
String
cmd
=
"
echo '"
+
passwd
+
"' | sudo -S
ovs-vsctl add-br "
+
name
;
String
res
=
linuxCtlUtils
.
runCmd
(
cmd
);
if
(
res
.
contains
(
"Error"
))
{
throw
new
RuntimeException
(
"linux bridge has existed!"
);
...
...
@@ -137,7 +140,7 @@ public class OvsUtilsImpl implements OvsUtils {
@Override
public
void
setBridgeProtocol
(
String
bridgeName
,
String
protocol
)
{
String
cmd
=
"ovs-vsctl set bridge "
+
bridgeName
+
" protocols="
+
protocol
;
String
cmd
=
"
echo '"
+
passwd
+
"' | sudo -S
ovs-vsctl set bridge "
+
bridgeName
+
" protocols="
+
protocol
;
String
res
=
linuxCtlUtils
.
runCmd
(
cmd
);
if
(
res
.
contains
(
"Error"
))
{
throw
new
RuntimeException
(
res
);
...
...
@@ -146,7 +149,7 @@ public class OvsUtilsImpl implements OvsUtils {
@Override
public
void
setController
(
String
bridgeName
,
String
host
,
int
port
)
{
String
cmd
=
"ovs-vsctl set-controller "
+
bridgeName
+
" tcp:"
+
host
+
":"
+
port
;
String
cmd
=
"
echo '"
+
passwd
+
"' | sudo -S
ovs-vsctl set-controller "
+
bridgeName
+
" tcp:"
+
host
+
":"
+
port
;
String
res
=
linuxCtlUtils
.
runCmd
(
cmd
);
if
(
res
.
contains
(
"Error"
))
{
throw
new
RuntimeException
(
res
);
...
...
@@ -155,7 +158,7 @@ public class OvsUtilsImpl implements OvsUtils {
@Override
public
void
delBridge
(
String
name
)
{
String
cmd
=
"ovs-vsctl del-br "
+
name
;
String
cmd
=
"
echo '"
+
passwd
+
"' | sudo -S
ovs-vsctl del-br "
+
name
;
LOG
.
info
(
"删除网桥[{}]"
,
name
);
String
res
=
linuxCtlUtils
.
runCmd
(
cmd
);
if
(
res
.
contains
(
"Error"
))
{
...
...
@@ -171,7 +174,7 @@ public class OvsUtilsImpl implements OvsUtils {
*/
@Override
public
boolean
addBridgePort
(
String
bridgeName
,
String
port
)
{
String
cmd
=
"ovs-vsctl add-port "
+
bridgeName
+
" "
+
port
;
String
cmd
=
"
echo '"
+
passwd
+
"' | sudo -S
ovs-vsctl add-port "
+
bridgeName
+
" "
+
port
;
String
res
=
linuxCtlUtils
.
runCmd
(
cmd
);
LOG
.
info
(
"为Bridge:{} 添加Port:{}"
,
bridgeName
,
port
);
if
(!
""
.
equals
(
res
))
{
...
...
@@ -183,7 +186,7 @@ public class OvsUtilsImpl implements OvsUtils {
@Override
public
boolean
delBridgePort
(
String
bridgeName
,
String
port
)
{
String
cmd
=
"ovs-vsctl del-port "
+
bridgeName
+
" "
+
port
;
String
cmd
=
"
echo '"
+
passwd
+
"' | sudo -S
ovs-vsctl del-port "
+
bridgeName
+
" "
+
port
;
LOG
.
info
(
"删除Bridge:{} Port:{}"
,
bridgeName
,
port
);
String
res
=
linuxCtlUtils
.
runCmd
(
cmd
);
if
(!
""
.
equals
(
res
))
{
...
...
@@ -203,7 +206,7 @@ public class OvsUtilsImpl implements OvsUtils {
public
String
[]
createVethPair
(
String
br1
,
String
br2
)
{
String
veth1
=
br1
+
"_"
+
br2
;
String
veth2
=
br2
+
"_"
+
br1
;
String
cmd
=
"ip link add "
+
veth1
+
" type veth peer name "
+
veth2
;
String
cmd
=
"
echo '"
+
passwd
+
"' | sudo -S
ip link add "
+
veth1
+
" type veth peer name "
+
veth2
;
LOG
.
info
(
"创建虚拟网卡对[{},{}]"
,
veth1
,
veth2
);
String
res
=
linuxCtlUtils
.
runCmd
(
cmd
);
if
(!
""
.
equals
(
res
))
{
...
...
@@ -221,7 +224,7 @@ public class OvsUtilsImpl implements OvsUtils {
public
boolean
delVethPort
(
String
[]
veths
)
{
String
veth1
=
veths
[
0
];
String
veth2
=
veths
[
1
];
String
cmd
=
"ip link del "
+
veth1
+
" type veth peer name "
+
veth2
;
String
cmd
=
"
echo '"
+
passwd
+
"' | sudo -S
ip link del "
+
veth1
+
" type veth peer name "
+
veth2
;
LOG
.
info
(
"删除虚拟网卡对[{},{}]"
,
veth1
,
veth2
);
String
res
=
linuxCtlUtils
.
runCmd
(
cmd
);
if
(!
""
.
equals
(
res
))
{
...
...
@@ -239,7 +242,7 @@ public class OvsUtilsImpl implements OvsUtils {
*/
@Override
public
boolean
enableLinuxPort
(
String
port
)
{
String
cmd
=
"ifconfig "
+
port
+
" up"
;
String
cmd
=
"
echo '"
+
passwd
+
"' | sudo -S
ifconfig "
+
port
+
" up"
;
LOG
.
info
(
"启动Linux端口:{}"
,
port
);
String
res
=
linuxCtlUtils
.
runCmd
(
cmd
);
if
(!
""
.
equals
(
res
))
{
...
...
@@ -275,7 +278,7 @@ public class OvsUtilsImpl implements OvsUtils {
public
boolean
setVxlan
(
String
bridgeName
,
String
remoteIp
)
{
// TODO: bug
int
id
=
atomicInteger
.
getAndIncrement
();
String
cmd
=
"ovs-vsctl add-port "
+
bridgeName
String
cmd
=
"
echo '"
+
passwd
+
"' | sudo -S
ovs-vsctl add-port "
+
bridgeName
+
" vxlan"
+
id
+
" -- set interface vxlan"
+
id
+
" type=vxlan options:remote_ip="
+
remoteIp
;
System
.
out
.
println
(
cmd
);
LOG
.
info
(
"设置VXLAN[bridgeName:{},remoteIP:{},{}]"
,
bridgeName
,
remoteIp
,
cmd
);
...
...
cnf-utils/src/test/java/top/ninwoo/utils/DockerServiceTests.java
View file @
3c8e74e7
...
...
@@ -7,7 +7,7 @@ import org.springframework.beans.factory.annotation.Autowired;
import
org.springframework.test.context.ContextConfiguration
;
import
org.springframework.test.context.junit4.SpringJUnit4ClassRunner
;
import
top.ninwoo.common.entity.DockerContainer
;
import
top.ninwoo.utils.config.
DockerConfig
;
import
top.ninwoo.utils.config.
CNFUtilsAutoConfiguration
;
import
top.ninwoo.utils.service.DockerService
;
import
top.ninwoo.utils.util.LinuxCtlUtils
;
...
...
@@ -15,7 +15,7 @@ import java.util.ArrayList;
import
java.util.List
;
@RunWith
(
SpringJUnit4ClassRunner
.
class
)
@ContextConfiguration
(
classes
=
DockerConfig
.
class
)
@ContextConfiguration
(
classes
=
CNFUtilsAutoConfiguration
.
class
)
public
class
DockerServiceTests
{
@Autowired
private
LinuxCtlUtils
linuxCtlService
;
...
...
cnf-utils/src/test/java/top/ninwoo/utils/DockerUtilsTest.java
View file @
3c8e74e7
package
top.ninwoo.utils
;
import
org.junit.After
;
import
org.junit.Before
;
import
org.junit.Test
;
import
org.junit.runner.RunWith
;
import
org.springframework.beans.factory.annotation.Autowired
;
...
...
@@ -7,24 +9,37 @@ import org.springframework.test.context.ContextConfiguration;
import
org.springframework.test.context.junit4.SpringJUnit4ClassRunner
;
import
org.springframework.util.Assert
;
import
top.ninwoo.common.entity.DockerContainer
;
import
top.ninwoo.utils.config.
DockerConfig
;
import
top.ninwoo.utils.config.
CNFUtilsAutoConfiguration
;
import
top.ninwoo.utils.util.DockerUtils
;
import
java.util.ArrayList
;
import
java.util.List
;
/**
* @Author joliu
* @Description
* @Date Create in 下午5:54 2019/10/25
*/
@RunWith
(
SpringJUnit4ClassRunner
.
class
)
@ContextConfiguration
(
classes
=
DockerConfig
.
class
)
@ContextConfiguration
(
classes
=
CNFUtilsAutoConfiguration
.
class
)
public
class
DockerUtilsTest
{
private
static
String
cid
=
null
;
@Autowired
DockerUtils
dockerUtils
;
@Before
public
void
prepare
()
{
DockerContainer
container
=
new
DockerContainer
();
container
.
setName
(
"Router_4"
);
container
.
setImage
(
"joliu/networktest"
);
container
.
setCommand
(
"sh"
);
cid
=
dockerUtils
.
runDocker
(
container
).
getId
();
}
@Test
public
void
testGetDockerById
()
{
DockerContainer
dockerById
=
dockerUtils
.
getDockerById
(
"123123"
);
Assert
.
is
Null
(
dockerById
);
DockerContainer
dockerById
=
dockerUtils
.
getDockerById
(
cid
);
Assert
.
is
True
(
dockerById
!=
null
);
}
...
...
@@ -32,6 +47,12 @@ public class DockerUtilsTest {
public
void
testExecInDocker
()
{
final
String
s
=
dockerUtils
.
execInDocker
(
"Router_4"
,
new
String
[]{
"ifconfig"
});
System
.
out
.
println
(
s
);
Assert
.
isTrue
(!(
""
.
equals
(
s
)));
}
@After
public
void
close
()
{
boolean
result
=
dockerUtils
.
deleteDockerById
(
cid
);
Assert
.
isTrue
(
result
);
}
}
cnf-utils/src/test/java/top/ninwoo/utils/EntityTests.java
deleted
100644 → 0
View file @
028a177e
package
top.ninwoo.utils
;
/**
* @Author joliu
* @Description
* @Date Create in 下午10:50 2019/10/27
*/
public
class
EntityTests
{
}
cnf-utils/src/test/java/top/ninwoo/utils/IptablesServiceTests.java
deleted
100644 → 0
View file @
028a177e
package
top.ninwoo.utils
;
import
org.junit.runner.RunWith
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.test.context.ContextConfiguration
;
import
org.springframework.test.context.junit4.SpringJUnit4ClassRunner
;
import
top.ninwoo.utils.config.DockerConfig
;
import
top.ninwoo.utils.service.IptablesService
;
/**
* @Author joliu
* @Description
* @Date Create in 下午3:15 2019/10/30
*/
@RunWith
(
SpringJUnit4ClassRunner
.
class
)
@ContextConfiguration
(
classes
=
DockerConfig
.
class
)
public
class
IptablesServiceTests
{
@Autowired
IptablesService
iptablesService
;
}
cnf-utils/src/test/java/top/ninwoo/utils/IptablesUtilsTests.java
View file @
3c8e74e7
...
...
@@ -10,7 +10,7 @@ import org.springframework.beans.factory.annotation.Autowired;
import
org.springframework.test.context.ContextConfiguration
;
import
org.springframework.test.context.junit4.SpringJUnit4ClassRunner
;
import
top.ninwoo.common.entity.DockerContainer
;
import
top.ninwoo.utils.config.
DockerConfig
;
import
top.ninwoo.utils.config.
CNFUtilsAutoConfiguration
;
import
top.ninwoo.utils.entity.ChainEntity
;
import
top.ninwoo.utils.entity.ChainType
;
import
top.ninwoo.utils.entity.TableType
;
...
...
@@ -26,7 +26,7 @@ import java.util.Map;
* @Date Create in 上午11:54 2019/10/29
*/
@RunWith
(
SpringJUnit4ClassRunner
.
class
)
@ContextConfiguration
(
classes
=
DockerConfig
.
class
)
@ContextConfiguration
(
classes
=
CNFUtilsAutoConfiguration
.
class
)
public
class
IptablesUtilsTests
{
private
static
final
Logger
LOG
=
LoggerFactory
.
getLogger
(
IptablesUtilsTests
.
class
);
...
...
cnf-utils/src/test/java/top/ninwoo/utils/OVSServiceTests.java
View file @
3c8e74e7
...
...
@@ -6,11 +6,10 @@ import org.junit.runner.RunWith;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.test.context.ContextConfiguration
;
import
org.springframework.test.context.junit4.SpringJUnit4ClassRunner
;
import
top.ninwoo.utils.config.
DockerConfig
;
import
top.ninwoo.utils.config.
CNFUtilsAutoConfiguration
;
import
top.ninwoo.utils.entity.BridgePort
;
import
top.ninwoo.utils.entity.Ovs
;
import
top.ninwoo.utils.entity.OvsBridge
;
import
top.ninwoo.utils.service.OVSService
;
import
top.ninwoo.utils.util.OvsUtils
;
...
...
@@ -18,7 +17,7 @@ import java.util.ArrayList;
import
java.util.List
;
@RunWith
(
SpringJUnit4ClassRunner
.
class
)
@ContextConfiguration
(
classes
=
DockerConfig
.
class
)
@ContextConfiguration
(
classes
=
CNFUtilsAutoConfiguration
.
class
)
public
class
OVSServiceTests
{
@Autowired
private
OvsUtils
ovsService
;
...
...
cnf-utils/src/test/java/top/ninwoo/utils/OsUtilsTests.java
View file @
3c8e74e7
...
...
@@ -5,7 +5,7 @@ import org.junit.runner.RunWith;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.test.context.ContextConfiguration
;
import
org.springframework.test.context.junit4.SpringJUnit4ClassRunner
;
import
top.ninwoo.utils.config.
DockerConfig
;
import
top.ninwoo.utils.config.
CNFUtilsAutoConfiguration
;
import
top.ninwoo.utils.util.OSUtils
;
/**
...
...
@@ -14,7 +14,7 @@ import top.ninwoo.utils.util.OSUtils;
* @Date Create in 上午10:45 2019/11/4
*/
@RunWith
(
SpringJUnit4ClassRunner
.
class
)
@ContextConfiguration
(
classes
=
DockerConfig
.
class
)
@ContextConfiguration
(
classes
=
CNFUtilsAutoConfiguration
.
class
)
public
class
OsUtilsTests
{
@Autowired
...
...
@@ -26,7 +26,7 @@ public class OsUtilsTests {
System
.
out
.
println
(
"CPU:"
+
osUtils
.
cpuUsage
()
+
"%"
);
System
.
out
.
println
(
"MEM:"
+
osUtils
.
memoryUsage
()
+
"%"
);
int
i
=
0
;
while
(
i
<
10
)
{
while
(
i
++
<
10
)
{
System
.
out
.
println
(
"NET:"
+
osUtils
.
networkUsage
()
+
"%"
);
}
}
...
...
cnf-utils/src/test/java/top/ninwoo/utils/SpringMain.java
deleted
100644 → 0
View file @
028a177e
package
top.ninwoo.utils
;
import
org.springframework.context.annotation.AnnotationConfigApplicationContext
;
import
top.ninwoo.utils.config.DockerConfig
;
public
class
SpringMain
{
public
static
void
main
(
String
[]
args
)
{
AnnotationConfigApplicationContext
context
=
new
AnnotationConfigApplicationContext
(
DockerConfig
.
class
);
}
}
cnf-utils/src/test/java/top/ninwoo/utils/TcUtilsTests.java
deleted
100644 → 0
View file @
028a177e
package
top.ninwoo.utils
;
import
org.junit.Before
;
import
org.junit.runner.RunWith
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.test.context.ContextConfiguration
;
import
org.springframework.test.context.junit4.SpringJUnit4ClassRunner
;
import
top.ninwoo.utils.config.DockerConfig
;
import
top.ninwoo.utils.util.DockerUtils
;
/**
* @Author joliu
* @Description 这个测试迁移到集群服务中
* @Date Create in 下午4:06 2019/10/30
*/
@RunWith
(
SpringJUnit4ClassRunner
.
class
)
@ContextConfiguration
(
classes
=
DockerConfig
.
class
)
public
class
TcUtilsTests
{
@Autowired
DockerUtils
dockerUtils
;
@Before
public
void
init
()
{
// 创建两个容器
// 创建一个ovs网桥
}
}
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment