提交 7714d611 编写于 作者: O openeuler-ci-bot 提交者: Gitee

!5 isulad-tools: replace lcrd to isulad

Merge pull request !5 from zhangsong234/fix/rename_lcrc_to_lcrd
......@@ -24,7 +24,7 @@
### general
* reorginzed the isulad-tools code (MR: #75)
* use`isulad-tools` in `isulad-tools_wrapper` instead of `lcrc exec` (MR: #76)
* use`isulad-tools` in `isulad-tools_wrapper` instead of `isula exec` (MR: #76)
* fix filelock can't lock accross the process issue (MR: #78)
### hooks
......@@ -99,7 +99,7 @@
### isulad-tools
* use device-hook instead of "lcrc update" to keep resource persistent in container.
* use device-hook instead of "isula update" to keep resource persistent in container.
* add syslog support, all log will be written to syslog.
* add "make rpm" support in Makefile.
......
......@@ -55,23 +55,23 @@ func New(name string) (*Container, error) {
return nil, fmt.Errorf("Invalid container name (%s), only %s are allowed", name, restrictedNameChars)
}
graphDriverPath, err := getLcrdGraphDriverPath()
graphDriverPath, err := getIsuladGraphDriverPath()
var id, storagePath string
var pid int
var spec *specs.Spec
storagePath = filepath.Join(graphDriverPath, "engines", "lcr")
id, err = getLcrdContainerID(name)
id, err = getIsuladContainerID(name)
if err != nil {
return nil, err
}
pid, err = getLcrdContainerPid(name)
pid, err = getIsuladContainerPid(name)
if err != nil {
return nil, err
}
spec, err = getLcrdContainerSpec(id)
spec, err = getIsuladContainerSpec(id)
if err != nil {
logrus.Warnf("fail to get lcrd container %v spec: %v", id, err)
logrus.Warnf("fail to get isulad container %v spec: %v", id, err)
}
container := &Container{
......@@ -141,12 +141,15 @@ func (c *Container) Unlock() error {
// GetCgroupPath returns the cgroup-parent segment of the container.
// For isulad container, it is a configurable segment.
func (c *Container) GetCgroupPath() (string, error) {
cmd := exec.Command("lcrc", "inspect", "-f", "{{json .HostConfig.CgroupParent}}", c.name)
cmd := exec.Command("isula", "inspect", "-f", "{{json .HostConfig.CgroupParent}}", c.name)
out, err := cmd.CombinedOutput()
if err != nil {
return "", fmt.Errorf("%s: %v", string(out), err)
}
cgroupPath := strings.Trim(string(out), "\n")
if len(cgroupPath) >= 2 {
cgroupPath = cgroupPath[1 : len(cgroupPath)-1]
}
if cgroupPath == "" {
// by default, the cgroup path is "/lxc/<id>"
cgroupPath = "/lxc"
......@@ -161,9 +164,9 @@ func (c *Container) GetSpec() *specs.Spec {
return c.spec
}
// getLcrdContainerID returns the lcrd container ID via the container name
func getLcrdContainerID(name string) (string, error) {
cmd := exec.Command("lcrc", "inspect", "-f", "{{json .Id}}", name)
// getIsuladContainerID returns the isulad container ID via the container name
func getIsuladContainerID(name string) (string, error) {
cmd := exec.Command("isula", "inspect", "-f", "{{json .Id}}", name)
out, err := cmd.CombinedOutput()
if err != nil {
return "", fmt.Errorf("%s: %v", string(out), err)
......@@ -171,9 +174,9 @@ func getLcrdContainerID(name string) (string, error) {
return strings.Trim(strings.Trim(string(out), "\n"), "\""), nil
}
// getLcrdContainerPid returns the lcrd container process id via the container name
func getLcrdContainerPid(name string) (int, error) {
cmd := exec.Command("lcrc", "inspect", "-f", "{{json .State.Pid}}", name)
// getIsuladContainerPid returns the isulad container process id via the container name
func getIsuladContainerPid(name string) (int, error) {
cmd := exec.Command("isula", "inspect", "-f", "{{json .State.Pid}}", name)
out, err := cmd.CombinedOutput()
if err != nil {
return -1, fmt.Errorf("%s: %v", string(out), err)
......@@ -186,8 +189,8 @@ func getLcrdContainerPid(name string) (int, error) {
return pid, nil
}
func getLcrdContainerSpec(id string) (spec *specs.Spec, err error) {
graphDriverPath, err := getLcrdGraphDriverPath()
func getIsuladContainerSpec(id string) (spec *specs.Spec, err error) {
graphDriverPath, err := getIsuladGraphDriverPath()
if err != nil {
return nil, err
}
......@@ -210,11 +213,11 @@ func getLcrdContainerSpec(id string) (spec *specs.Spec, err error) {
return spec, nil
}
func getLcrdGraphDriverPath() (string, error) {
cmd := exec.Command("lcrc", "info")
func getIsuladGraphDriverPath() (string, error) {
cmd := exec.Command("isula", "info")
out, err := cmd.CombinedOutput()
if err != nil {
return "", fmt.Errorf("Exec lcrc info failed: %v", err)
return "", fmt.Errorf("Exec isula info failed: %v", err)
}
// Find "iSulad Root Dir: /xx/xx" line. and out is still has the rest characters.
if index := strings.Index(string(out), "iSulad Root Dir:"); index != -1 {
......@@ -228,7 +231,7 @@ func getLcrdGraphDriverPath() (string, error) {
return rootdir, nil
}
}
return "", fmt.Errorf("Faild to parse lcrc info, no \"iSulad Root Dir:\" found")
return "", fmt.Errorf("Faild to parse isula info, no \"iSulad Root Dir:\" found")
}
// SetContainerPath set container path
......
......@@ -13,7 +13,7 @@
#!/bin/bash
HOOK_DIR=/var/lib/lcrd/hooks
HOOK_DIR=/var/lib/isulad/hooks
ISULAD_TOOLS_DIR=/usr/local/bin
ISULAD_TOOLS_WRAPPER="/lib/udev"
HOOK_SPEC="/etc/isulad-tools"
......
......@@ -28,7 +28,7 @@ This is isulad tools, to make it work, you need a isulad and util-linux
make init && make
%install
HOOK_DIR=$RPM_BUILD_ROOT/var/lib/lcrd/hooks
HOOK_DIR=$RPM_BUILD_ROOT/var/lib/isulad/hooks
ISULAD_TOOLS_DIR=$RPM_BUILD_ROOT/usr/local/bin
ISULAD_TOOLS_WRAPPER=$RPM_BUILD_ROOT/lib/udev
......@@ -46,18 +46,18 @@ install -m 0750 hack/isulad-tools_wrapper ${ISULAD_TOOLS_WRAPPER}/isulad-tools_
%preun
%post
GRAPH=`lcrc info | grep -Eo "iSulad Root Dir:.+" | grep -Eo "\/.*"`
GRAPH=`isula info | grep -Eo "iSulad Root Dir:.+" | grep -Eo "\/.*"`
if [ "$GRAPH" == "" ]; then
GRAPH="/var/lib/lcrd"
GRAPH="/var/lib/isulad"
fi
if [[ "$GRAPH" != "/var/lib/lcrd" ]]; then
if [[ "$GRAPH" != "/var/lib/isulad" ]]; then
mkdir -p -m 0550 $GRAPH/hooks
install -m 0550 -p /var/lib/lcrd/hooks/isulad-hooks $GRAPH/hooks
install -m 0550 -p /var/lib/isulad/hooks/isulad-hooks $GRAPH/hooks
echo
echo "=================== WARNING! ================================================"
echo " 'iSulad Root Dir' is $GRAPH, move /var/lib/lcrd/hooks/isulad-hooks to $GRAPH/hooks"
echo " 'iSulad Root Dir' is $GRAPH, move /var/lib/isulad/hooks/isulad-hooks to $GRAPH/hooks"
echo "============================================================================="
echo
fi
......@@ -98,8 +98,8 @@ chmod 0640 ${HOOK_SPEC}/hookspec.json
%files
%defattr(0550,root,root,0550)
/usr/local/bin/isulad-tools
%attr(0550,root,root) /var/lib/lcrd/hooks
%attr(0550,root,root) /var/lib/lcrd/hooks/isulad-hooks
%attr(0550,root,root) /var/lib/isulad/hooks
%attr(0550,root,root) /var/lib/isulad/hooks/isulad-hooks
%attr(0550,root,root) /lib/udev/isulad-tools_wrapper
......
......@@ -50,13 +50,13 @@ Full hook config:
## Try it!
First you need an enhanced `lcrc` with newly added `--hook-spec` flag,
First you need an enhanced `isula` with newly added `--hook-spec` flag,
after that, you can run it like this:
1.run isulad container with hook spec in `example` directory
```
$ lcrc run -d --name test_device --hook-spec $PWD/example/hookspec.json busybox sleep 20000
$ isula run -d --name test_device --hook-spec $PWD/example/hookspec.json busybox sleep 20000
```
2.use isulad-tools to add device or binds to container
......@@ -67,7 +67,7 @@ isulad-tools add-device test_device /dev/zero:/dev/test_zero:rwm /dev/zero:/dev/
3.restart the container. to check the device is still in container.
```
lcrc restart test_device
isula restart test_device
```
Let's check the [`hookspec.json`](example/hookspec.json) file:
......@@ -76,7 +76,7 @@ Let's check the [`hookspec.json`](example/hookspec.json) file:
{
"prestart": [
{
"path": "/var/lib/lcrd/hooks/device-hook",
"path": "/var/lib/isulad/hooks/device-hook",
"args": ["device-hook"],
"env": []
}
......
{
"prestart": [
{
"path": "/var/lib/lcrd/hooks/isulad-hooks",
"path": "/var/lib/isulad/hooks/isulad-hooks",
"args": ["isulad-hooks", "--state", "prestart", "--log", "/var/log/device-hook.log"],
"env": []
}
],
"poststart":[
{
"path": "/var/lib/lcrd/hooks/isulad-hooks",
"path": "/var/lib/isulad/hooks/isulad-hooks",
"args": ["isulad-hooks", "--state", "prestart", "--log", "/var/log/device-hook.log"],
"env": []
}
],
"poststop":[
{
"path": "/var/lib/lcrd/hooks/isulad-hooks",
"path": "/var/lib/isulad/hooks/isulad-hooks",
"args": ["isulad-hooks", "--state", "poststop", "--log", "/var/log/device-hook.log"],
"env": []
}
......
......@@ -347,7 +347,7 @@ func AdjustUserns(state *configs.HookState, hookConfig *hconfig.ContainerHookCon
if err != nil {
return err
}
if strings.Contains(containerStoragePath, "lcrd") {
if strings.Contains(containerStoragePath, "isulad") {
return nil
}
......
......@@ -51,7 +51,7 @@ func relabelIsuladBinary(path, bin string) error {
}
func restartIsulad() error {
restart := selinuxCommand{"systemctl", []string{"restart", "lcrd"}}
restart := selinuxCommand{"systemctl", []string{"restart", "isulad"}}
cmd := exec.Command(restart.cmd, restart.argv...)
logrus.Infof("%s %v", restart.cmd, restart.argv)
if err := cmd.Run(); err != nil {
......@@ -94,7 +94,7 @@ func relabel(path string) error {
return nil
}
modifyContexts := []selinuxContext{
{"init_exec_t", path + "/lcrd"},
{"init_exec_t", path + "/isulad"},
}
con := utils.NewContext(attr)
for _, context := range modifyContexts {
......
......@@ -19,21 +19,21 @@
TEST_NAME="test_devices_many"
test_001(){
container_ID=`lcrc run --name one --hook-spec /var/lib/lcrd/hooks/hookspec.json -d $UBUNTU_IMAGE bash -c "sleep 10000"`
container_ID=`isula run --name one --hook-spec /var/lib/isulad/hooks/hookspec.json -d $UBUNTU_IMAGE bash -c "sleep 10000"`
container_status $container_ID
if [ "${status}x" != "runningx" ]; then
fail $TEST_NAME "01:FAIL"
fi
container_ID=`lcrc ps | grep one | awk '{print $1}'`
container_ID=`isula ps | grep one | awk '{print $1}'`
$ISULAD_TOOLS add-device $container_ID $DEV_SDA1:/dev/sda1:rw $DEV_SDA2:/dev/sda2:rw > /dev/null
out=`lcrc exec one bash -c "ls /dev/sda1"`
out=`isula exec one bash -c "ls /dev/sda1"`
if [ "$out" == "/dev/sda1" ]; then
success $TEST_NAME "01-1:PASS"
else
fail $TEST_NAME "01-1:FAIL"
fi
out=`lcrc exec one bash -c "ls /dev/sda2"`
out=`isula exec one bash -c "ls /dev/sda2"`
if [ "$out" == "/dev/sda2" ]; then
success $TEST_NAME "01-2:PASS"
else
......@@ -41,7 +41,7 @@ test_001(){
fi
#test remove-device
$ISULAD_TOOLS remove-device $container_ID $DEV_SDA1:/dev/sda1:rw /dev/zero:/dev/sda2:rw > /dev/null
lcrc exec one bash -c "ls /dev/sda1 && /dev/sda2" >&$TEST_FOLDER/ab.txt
isula exec one bash -c "ls /dev/sda1 && /dev/sda2" >&$TEST_FOLDER/ab.txt
out=`cat $TEST_FOLDER/ab.txt`
out=${out##*:}
out=${out%%or*}
......@@ -59,24 +59,24 @@ test_001(){
else
fail $TEST_NAME "01-4:FAIL"
fi
lcrc rm -f one > /dev/null
isula rm -f one > /dev/null
}
test_002(){
#test Multiple container mount the same direct
container_ID1=`lcrc run --name one --hook-spec /var/lib/lcrd/hooks/hookspec.json -d $UBUNTU_IMAGE bash -c "sleep 10000"`
container_ID1=`isula run --name one --hook-spec /var/lib/isulad/hooks/hookspec.json -d $UBUNTU_IMAGE bash -c "sleep 10000"`
container_status $container_ID1
if [ "${status}x" != "runningx" ]; then
fail $TEST_NAME "02:FAIL"
fi
container_ID2=`lcrc run --name two --hook-spec /var/lib/lcrd/hooks/hookspec.json -d $UBUNTU_IMAGE bash -c "sleep 10000"`
container_ID2=`isula run --name two --hook-spec /var/lib/isulad/hooks/hookspec.json -d $UBUNTU_IMAGE bash -c "sleep 10000"`
container_status $container_ID2
if [ "${status}x" != "runningx" ]; then
fail $TEST_NAME "021:FAIL"
fi
out=`$ISULAD_TOOLS add-device $container_ID1 $DEV_SDA1:/dev/sda1:rw > /dev/null`
out=`lcrc exec one bash -c "ls /dev/sda1"`
out=`isula exec one bash -c "ls /dev/sda1"`
if [ "$out" != "/dev/sda1" ]; then
fail $TEST_NAME "02-1:FAIL"
else
......@@ -84,7 +84,7 @@ test_002(){
fi
out=`$ISULAD_TOOLS add-device $container_ID2 $DEV_SDA1:/dev/sda1:rw > /dev/null`
out1=`lcrc exec two bash -c "ls /dev/sda1"`
out1=`isula exec two bash -c "ls /dev/sda1"`
if [ "$out1" != "/dev/sda1" ]; then
fail $TEST_NAME "02-2:FAIL"
else
......@@ -92,7 +92,7 @@ test_002(){
fi
$ISULAD_TOOLS remove-device $container_ID1 $DEV_SDA1:/dev/sda1:rw > /dev/null
lcrc exec $container_ID1 bash -c "ls /dev/sda1" > /dev/null 2>&1
isula exec $container_ID1 bash -c "ls /dev/sda1" > /dev/null 2>&1
out=`echo $?`
if [ $out -eq 0 ];then
fail $TEST_NAME "02-3:FAIL"
......@@ -100,7 +100,7 @@ test_002(){
success $TEST_NAME "02-3:PASS"
fi
out1=`lcrc exec two bash -c "ls /dev/sda1"`
out1=`isula exec two bash -c "ls /dev/sda1"`
if [ "$out1" == "/dev/sda1" ]; then
success $TEST_NAME "02-4:PASS"
else
......@@ -108,24 +108,24 @@ test_002(){
fi
#test stop start
lcrc stop two > /dev/null
isula stop two > /dev/null
container_status $container_ID2
if [ "${status}x" != "exitedx" ]; then
fail $TEST_NAME "02-5:FAIL"
fi
lcrc start two > /dev/null
isula start two > /dev/null
container_status $container_ID2
if [ "${status}x" != "runningx" ]; then
fail $TEST_NAME "02-6:FAIL"
fi
out1=`lcrc exec two bash -c "ls /dev/sda1"`
out1=`isula exec two bash -c "ls /dev/sda1"`
if [ "$out1" == "/dev/sda1" ]; then
success $TEST_NAME "02-7:PASS"
else
fail $TEST_NAME "02-7:FAIL"
fi
lcrc rm -f one > /dev/null
lcrc rm -f two > /dev/null
isula rm -f one > /dev/null
isula rm -f two > /dev/null
}
......
......@@ -20,14 +20,14 @@ TEST_NAME="test_devices"
test_001(){
# test add-device.
out=`lcrc run --name one --hook-spec /var/lib/lcrd/hooks/hookspec.json -d $UBUNTU_IMAGE bash -c "sleep 100000"`
out=`isula run --name one --hook-spec /var/lib/isulad/hooks/hookspec.json -d $UBUNTU_IMAGE bash -c "sleep 100000"`
container_status $out
if [ "${status}x" != "runningx" ]; then
fail $TEST_NAME "01:FAIL"
fi
$ISULAD_TOOLS add-device $out $DEV_SDA1:/dev/sda1:rw> /dev/null
out1=`lcrc exec one sh -c "ls /dev/sda1"`
out1=`isula exec one sh -c "ls /dev/sda1"`
if [ "$out1" == "/dev/sda1" ]; then
success $TEST_NAME "01-1:PASS"
else
......@@ -36,19 +36,19 @@ test_001(){
#test remove-device
$ISULAD_TOOLS remove-device $out $DEV_SDA1:/dev/sda1:rwm > /dev/null
out1=`lcrc exec one sh -c "ls -l /dev/sda1" > /dev/null 2>&1`
out1=`isula exec one sh -c "ls -l /dev/sda1" > /dev/null 2>&1`
if [ "$out1" == "" ]; then
success $TEST_NAME "01-2:PASS"
else
fail $TEST_NAME "01-2:FAIL"
fi
lcrc rm -f one > /dev/null
isula rm -f one > /dev/null
}
test_002(){
#test exited container
out=`lcrc run --name one --hook-spec /var/lib/lcrd/hooks/hookspec.json -d $UBUNTU_IMAGE`
out=`isula run --name one --hook-spec /var/lib/isulad/hooks/hookspec.json -d $UBUNTU_IMAGE`
sleep 3
container_status $out
if [ "${status}x" != "exitedx" ]; then
......@@ -61,13 +61,13 @@ test_002(){
else
fail $TEST_NAME "02-1:FAIL"
fi
lcrc rm one > /dev/null
isula rm one > /dev/null
rm -f ab.txt >/dev/null
}
test_003(){
#test created container
out=`lcrc create --name one --hook-spec /var/lib/lcrd/hooks/hookspec.json -ti $UBUNTU_IMAGE`
out=`isula create --name one --hook-spec /var/lib/isulad/hooks/hookspec.json -ti $UBUNTU_IMAGE`
container_status $out
if [ "${status}x" != "createdx" ]; then
fail $TEST_NAME "03:FAIL"
......@@ -82,36 +82,36 @@ test_003(){
rm -f ab.txt > /dev/null
#created->up container
lcrc start one > /dev/null
out=`lcrc ps | grep one | awk '{print $1}'`
isula start one > /dev/null
out=`isula ps | grep one | awk '{print $1}'`
out1=`$ISULAD_TOOLS add-device $out $DEV_SDA1:/dev/sda1:rwm`
out1=`lcrc exec one sh -c "ls /dev/sda1"`
out1=`isula exec one sh -c "ls /dev/sda1"`
if [ "$out1" == "/dev/sda1" ]; then
success $TEST_NAME "03-2:PASS"
else
fail $TEST_NAME "03-2:FAIL"
fi
lcrc rm -f one > /dev/null
isula rm -f one > /dev/null
}
test_004(){
#test r
out=`lcrc run --name one --hook-spec /var/lib/lcrd/hooks/hookspec.json -d $UBUNTU_IMAGE bash -c "sleep 10000"`
out=`isula run --name one --hook-spec /var/lib/isulad/hooks/hookspec.json -d $UBUNTU_IMAGE bash -c "sleep 10000"`
container_status $out
if [ "${status}x" != "runningx" ]; then
fail $TEST_NAME "04:FAIL"
fi
$ISULAD_TOOLS add-device $out $DEV_SDA1:/dev/sda1:r > /dev/null
out1=`lcrc exec one sh -c "ls /dev/sda1"`
out1=`isula exec one sh -c "ls /dev/sda1"`
if [ "$out1" != "/dev/sda1" ]; then
fail $TEST_NAME "04-1:FAIL"
else
success $TEST_NAME "04-1:PASS"
fi
$ISULAD_TOOLS remove-device $out $DEV_SDA1:/dev/sda1:r > /dev/null
out=`lcrc exec one sh -c "ls /dev/sda1" > /dev/null 2>&1`
out=`isula exec one sh -c "ls /dev/sda1" > /dev/null 2>&1`
if [ "$out" == "" ]; then
success $TEST_NAME "04-2:PASS"
else
......@@ -120,15 +120,15 @@ test_004(){
rm -rf ab.txt > /dev/null
#test rw
out=`lcrc ps | grep one | awk '{print $1}'`
out=`isula ps | grep one | awk '{print $1}'`
$ISULAD_TOOLS add-device $out $DEV_SDA1:/dev/sda1:rw > /dev/null
out=`lcrc exec one sh -c "ls /dev/sda1"`
out=`isula exec one sh -c "ls /dev/sda1"`
if [ "$out" != "/dev/sda1" ]; then
fail $TEST_NAME "04-3:FAIL"
else
success $TEST_NAME "04-3:PASS"
fi
lcrc exec one bash -c "dd if=/dev/sda1 of=/dev/null bs=1M count=10" >&`pwd`/ab.txt
isula exec one bash -c "dd if=/dev/sda1 of=/dev/null bs=1M count=10" >&`pwd`/ab.txt
out=`cat ab.txt | awk -F',' 'END{print $1}'`
out=`echo $out | awk -F ' ' '{print $1}'`
if [ "$out" == "10485760" ]; then
......@@ -136,13 +136,13 @@ test_004(){
else
fail $TEST_NAME "04-4:FAIL"
fi
lcrc rm -f one > /dev/null
isula rm -f one > /dev/null
rm -f ab.txt > /dev/null
}
test_006(){
#test not exist device
out=`lcrc run --name one --hook-spec /var/lib/lcrd/hooks/hookspec.json -d $UBUNTU_IMAGE bash -c "sleep 100000"`
out=`isula run --name one --hook-spec /var/lib/isulad/hooks/hookspec.json -d $UBUNTU_IMAGE bash -c "sleep 100000"`
container_status $out
if [ "${status}x" == "runningx" ]; then
success $TEST_NAME "06:PASS"
......@@ -157,10 +157,10 @@ test_006(){
fail $TEST_NAME "06-1:FAIL"
fi
rm -f ab.txt > /dev/null
lcrc rm -f one > /dev/null
isula rm -f one > /dev/null
#test no r w
out=`lcrc run --name one --hook-spec /var/lib/lcrd/hooks/hookspec.json -d $UBUNTU_IMAGE bash -c "sleep 100000"`
out=`isula run --name one --hook-spec /var/lib/isulad/hooks/hookspec.json -d $UBUNTU_IMAGE bash -c "sleep 100000"`
container_status $out
if [ "${status}x" != "runningx" ]; then
fail $TEST_NAME "06-2:FAIL"
......@@ -168,7 +168,7 @@ test_006(){
success $TEST_NAME "06-2:PASS"
fi
$ISULAD_TOOLS add-device $out $DEV_SDA:/dev/sda > /dev/null
lcrc exec one bash -c "dd if=/dev/sda of=/dev/null bs=1M count=10" >&$TMP/ab.txt
isula exec one bash -c "dd if=/dev/sda of=/dev/null bs=1M count=10" >&$TMP/ab.txt
out=`cat $TMP/ab.txt | awk -F',' 'END{print $1}'`
out=`echo $out | awk -F ' ' '{print $1}'`
if [ "$out" == "10485760" ]; then
......@@ -176,7 +176,7 @@ test_006(){
else
fail $TEST_NAME "06-3:FAIL"
fi
lcrc rm -f one > /dev/null
isula rm -f one > /dev/null
}
......
......@@ -29,10 +29,10 @@ setupImage(){
declare -a Images=($UBUNTU_IMAGE $BUSYBOX_IMAGE)
for img in "${Images[@]}";
do
out=`lcrc images | grep $img`
out=`isula images | grep $img`
if [ "x$out" = "x" ]; then
echo "Image [" $img "] does not exist, pull it from hub."
lcrc pull $img
isula pull $img
fi
done
......@@ -40,9 +40,9 @@ setupImage(){
setup_device_hook(){
mkdir -p /var/lib/lcrd/hooks
cp $CUR/../hooks/isulad-hooks/example/hookspec.json /var/lib/lcrd/hooks/
cp $CUR/../build/isulad-hooks /var/lib/lcrd/hooks/
mkdir -p /var/lib/isulad/hooks
cp $CUR/../hooks/isulad-hooks/example/hookspec.json /var/lib/isulad/hooks/
cp $CUR/../build/isulad-hooks /var/lib/isulad/hooks/
}
main_test(){
......
......@@ -23,7 +23,7 @@
test_001(){
#testcase01
CONTAINER_ID=`lcrc run -d $BUSYBOX_IMAGE top`
CONTAINER_ID=`isula run -d $BUSYBOX_IMAGE top`
$ISULAD_TOOLS --debug --log $TMP/isulad-tools.log add-nic \
--type veth --name eth10 --ip 192.168.182.2/24 \
--mac "aa:bb:cc:dd:ee:aa" --bridge "docker0" --mtu 1350 \
......@@ -34,7 +34,7 @@ test_001(){
success $TEST_NAME "01-1:PASS"
fi
out=`lcrc exec $CONTAINER_ID ip a s eth10`
out=`isula exec $CONTAINER_ID ip a s eth10`
if [ $? -ne 0 ]; then
fail $TEST_NAME "01-2:FAIL"
else
......@@ -69,7 +69,7 @@ test_001(){
else
success $TEST_NAME "01-6:PASS"
fi
lcrc rm -f $CONTAINER_ID > /dev/null 2>&1
isula rm -f $CONTAINER_ID > /dev/null 2>&1
}
test_002(){
......@@ -82,7 +82,7 @@ test_002(){
if [ $? -ne 0 ]; then
fail "02-1:FAIL"
fi
CONTAINER_ID=`lcrc run -d $BUSYBOX_IMAGE top`
CONTAINER_ID=`isula run -d $BUSYBOX_IMAGE top`
$ISULAD_TOOLS --debug --log $TMP/isulad-tools.log add-nic \
--type veth --name eth11 --ip 192.168.182.2/24 \
--mac "aa:bb:cc:dd:ee:aa" --bridge $OVS_BR --mtu 1350 \
......@@ -93,7 +93,7 @@ test_002(){
success $TEST_NAME "02-1:PASS"
fi
out=`lcrc exec $CONTAINER_ID ip a s eth11`
out=`isula exec $CONTAINER_ID ip a s eth11`
if [ $? -ne 0 ]; then
fail $TEST_NAME "02-2:FAIL"
else
......@@ -108,7 +108,7 @@ test_002(){
else
success $TEST_NAME "02-3:PASS"
fi
lcrc rm -f $CONTAINER_ID > /dev/null 2>&1
isula rm -f $CONTAINER_ID > /dev/null 2>&1
ovs-vsctl --if-exists del-br $OVS_BR
}
......
......@@ -20,13 +20,13 @@
TEST_NAME="test_path_many"
test_001(){
container_ID=`lcrc run --name one --hook-spec /var/lib/lcrd/hooks/hookspec.json -d $UBUNTU_IMAGE bash -c "sleep 10000"`
container_ID=`isula run --name one --hook-spec /var/lib/isulad/hooks/hookspec.json -d $UBUNTU_IMAGE bash -c "sleep 10000"`
container_status $container_ID
if [ "${status}x" != "runningx" ]; then
fail $TEST_NAME "01:FAIL"
fi
container_ID=`lcrc ps | grep one | awk '{print $1}'`
container_ID=`isula ps | grep one | awk '{print $1}'`
TEST_FOLDER1=$TMP/$TEST_NAME/001/test1
TEST_FOLDER2=$TMP/$TEST_NAME/001/test2
......@@ -44,14 +44,14 @@ test_001(){
else
success $TEST_NAME "01-1:PASS"
fi
out=`lcrc exec one bash -c "cat /tmp/c.txt"`
out=`isula exec one bash -c "cat /tmp/c.txt"`
if [ "$out" == "cc" ]; then
success $TEST_NAME "01-2:PASS"
else
fail $TEST_NAME "01-2:FAIL"
fi
out=`lcrc exec one bash -c "cat /home/b.txt"`
out=`isula exec one bash -c "cat /home/b.txt"`
if [ "$out" == "hello" ]; then
success $TEST_NAME "01-3:PASS"
else
......@@ -60,7 +60,7 @@ test_001(){
#test remove-path
$ISULAD_TOOLS remove-path $container_ID $TEST_FOLDER2:/tmp:rw $TEST_FOLDER1:/home:rw > /dev/null
out=`lcrc exec one bash -c "ls /tmp && ls /home"`
out=`isula exec one bash -c "ls /tmp && ls /home"`
if [ "$out" == "" ]; then
success $TEST_NAME "01-4:PASS"
else
......@@ -74,24 +74,24 @@ test_001(){
else
success $TEST_NAME "01-6:PASS"
fi
out=`lcrc exec $container_ID bash -c "ls /tmp"`
out=`isula exec $container_ID bash -c "ls /tmp"`
if [ "$out" == "b.txt" ]; then
success $TEST_NAME "01-7:PASS"
else
fail $TEST_NAME "01-7:FAIL"
fi
lcrc rm -f one > /dev/null
isula rm -f one > /dev/null
}
test_002(){
#test Multiple container mount the same direct
container_ID1=`lcrc run --name one1 --hook-spec /var/lib/lcrd/hooks/hookspec.json -d $UBUNTU_IMAGE bash -c "sleep 1000"`
container_ID1=`isula run --name one1 --hook-spec /var/lib/isulad/hooks/hookspec.json -d $UBUNTU_IMAGE bash -c "sleep 1000"`
container_status $container_ID1
if [ "${status}x" != "runningx" ]; then
fail $TEST_NAME "02:FAIL"
fi
container_ID2=`lcrc run --name two --hook-spec /var/lib/lcrd/hooks/hookspec.json -d $UBUNTU_IMAGE bash -c "sleep 1000"`
container_ID2=`isula run --name two --hook-spec /var/lib/isulad/hooks/hookspec.json -d $UBUNTU_IMAGE bash -c "sleep 1000"`
container_status $container_ID2
if [ "${status}x" != "runningx" ]; then
fail $TEST_NAME "021:FAIL"
......@@ -101,7 +101,7 @@ test_002(){
echo hello > $TEST_FOLDER1/b.txt
$ISULAD_TOOLS add-path $container_ID1 $TEST_FOLDER1:/tmp:rw > /dev/null
out=`lcrc exec one1 sh -c "ls /tmp"`
out=`isula exec one1 sh -c "ls /tmp"`
if [ "$out" != "b.txt" ]; then
fail $TEST_NAME "02-1:FAIL"
else
......@@ -109,7 +109,7 @@ test_002(){
fi
$ISULAD_TOOLS add-path $container_ID2 $TEST_FOLDER1:/tmp:rw > /dev/null
out1=`lcrc exec two sh -c "cd tmp && ls"`
out1=`isula exec two sh -c "cd tmp && ls"`
if [ "$out1" != "b.txt" ]; then
fail $TEST_NAME "02-2:FAIL"
else
......@@ -123,7 +123,7 @@ test_002(){
success $TEST_NAME "02-3:PASS"
fi
out1=`lcrc exec two sh -c "cd tmp && ls"`
out1=`isula exec two sh -c "cd tmp && ls"`
if [ "$out1" == "b.txt" ]; then
success $TEST_NAME "02-4:PASS"
else
......@@ -131,29 +131,29 @@ test_002(){
fi
#test stop start
lcrc stop two > /dev/null
isula stop two > /dev/null
container_status $container_ID2
if [ "${status}x" != "exitedx" ]; then
fail $TEST_NAME "02-5:FAIL"
fi
lcrc start two > /dev/null
isula start two > /dev/null
container_status $container_ID2
if [ "${status}x" != "runningx" ]; then
fail $TEST_NAME "02-6:FAIL"
fi
out1=`lcrc exec two sh -c "cd tmp && ls"`
out1=`isula exec two sh -c "cd tmp && ls"`
if [ "$out1" == "b.txt" ]; then
success $TEST_NAME "02-7:PASS"
else
fail $TEST_NAME "02-7:FAIL"
fi
lcrc rm -f one1 > /dev/null
lcrc rm -f two > /dev/null
isula rm -f one1 > /dev/null
isula rm -f two > /dev/null
}
test_003(){
#test one direct is ro ,the other is direct is rw
out=`lcrc run --name one --hook-spec /var/lib/lcrd/hooks/hookspec.json -d $UBUNTU_IMAGE bash -c "sleep 1000"`
out=`isula run --name one --hook-spec /var/lib/isulad/hooks/hookspec.json -d $UBUNTU_IMAGE bash -c "sleep 1000"`
container_status $out
if [ "${status}x" != "runningx" ]; then
fail $TEST_NAME "03:FAIL"
......@@ -169,26 +169,26 @@ test_003(){
echo cc > $TEST_FOLDER2/c.txt
$ISULAD_TOOLS add-path $out $TEST_FOLDER1:/tmp:rw $TEST_FOLDER2:/home:ro > /dev/null 2>&1
out1=`lcrc exec one bash -c "cat /tmp/b.txt"`
out1=`isula exec one bash -c "cat /tmp/b.txt"`
if [ "$out1" != "hello" ]; then
fail $TEST_NAME "03-1:FAIL"
fi
out1=`lcrc exec one bash -c "cat /home/c.txt"`
out1=`isula exec one bash -c "cat /home/c.txt"`
if [ "$out1" != "cc" ]; then
fail $TEST_NAME "03-2:FAIL"
fi
lcrc exec one bash -c "cd /home && echo hello>c.txt" > /dev/null 2>&1
isula exec one bash -c "cd /home && echo hello>c.txt" > /dev/null 2>&1
if [ $? -eq 0 ]; then
fail $TEST_NAME "03-3:FAIL"
fi
out=`lcrc exec one bash -c "cd /home && cat c.txt"`
out=`isula exec one bash -c "cd /home && cat c.txt"`
if [ "$out" == "cc" ]; then
success $TEST_NAME "03-4:PASS"
else
fail $TEST_NAME "03-4:FAIL"
fi
lcrc rm -f one > /dev/null
isula rm -f one > /dev/null
}
main(){
......
......@@ -20,13 +20,13 @@
TEST_NAME="test_path"
test_001(){
out=`lcrc run --name one --hook-spec /var/lib/lcrd/hooks/hookspec.json -d $UBUNTU_IMAGE bash -c "sleep 100000"`
out=`isula run --name one --hook-spec /var/lib/isulad/hooks/hookspec.json -d $UBUNTU_IMAGE bash -c "sleep 100000"`
container_status $out
if [ "${status}x" != "runningx" ]; then
fail $TEST_NAME "01:FAIL"
fi
out1=`lcrc ps | grep one | awk '{print $1}'`
out1=`isula ps | grep one | awk '{print $1}'`
TEST_FOLDER=$TMP/$TEST_NAME/001
if [ -d $TEST_FOLDER ]; then
rm -rf $TEST_FOLDER > /dev/null
......@@ -41,7 +41,7 @@ test_001(){
fail $TEST_NAME "01-1:FAIL"
fi
out=`lcrc exec one sh -c "cat /tmp/b.txt"`
out=`isula exec one sh -c "cat /tmp/b.txt"`
if [ "$out" == "hello" ]; then
success $TEST_NAME "01-2:PASS"
else
......@@ -50,7 +50,7 @@ test_001(){
#test remove-path
$ISULAD_TOOLS remove-path $out1 $TEST_FOLDER:/tmp > /dev/null
out=`lcrc exec one sh -c "cd tmp && ls" > /dev/null 2>&1 `
out=`isula exec one sh -c "cd tmp && ls" > /dev/null 2>&1 `
if [ "$out" == "" ]; then
success $TEST_NAME "01-3:PASS"
else
......@@ -58,12 +58,12 @@ test_001(){
fi
# clean up container.
lcrc rm -f one > /dev/null
isula rm -f one > /dev/null
}
test_002(){
#test exited container
out=`lcrc run --name one --hook-spec /var/lib/lcrd/hooks/hookspec.json -d $UBUNTU_IMAGE`
out=`isula run --name one --hook-spec /var/lib/isulad/hooks/hookspec.json -d $UBUNTU_IMAGE`
sleep 3
container_status $out
if [ "${status}x" != "exitedx" ]; then
......@@ -77,12 +77,12 @@ test_002(){
else
fail $TEST_NAME "02-1:Fail"
fi
lcrc rm one > /dev/null
isula rm one > /dev/null
}
test_003(){
#test created container
out=`lcrc create --name one --hook-spec /var/lib/lcrd/hooks/hookspec.json -ti $UBUNTU_IMAGE`
out=`isula create --name one --hook-spec /var/lib/isulad/hooks/hookspec.json -ti $UBUNTU_IMAGE`
container_status $out
if [ "${status}x" != "createdx" ]; then
success $TEST_NAME "03:PASS"
......@@ -102,11 +102,11 @@ test_003(){
echo hello > $TEST_FOLDER/b.txt
#created->up container
out1=`lcrc start one`
out1=`isula start one`
sleep 1
out=`lcrc ps | grep one | awk '{print $1}'`
out=`isula ps | grep one | awk '{print $1}'`
$ISULAD_TOOLS add-path $out $TEST_FOLDER:/tmp:ro > /dev/null 2>&1
out1=`lcrc exec $out sh -c "cat /tmp/b.txt"`
out1=`isula exec $out sh -c "cat /tmp/b.txt"`
if [ "$out1" == "hello" ]; then
success $TEST_NAME "03-2:PASS"
else
......@@ -114,7 +114,7 @@ test_003(){
fi
#test ro
lcrc exec one sh -c "cd tmp && ls && echo abcddd> b.txt" > /dev/null 2>&1
isula exec one sh -c "cd tmp && ls && echo abcddd> b.txt" > /dev/null 2>&1
out=`echo $?`
if [ $out -ne 0 ]; then
success $TEST_NAME "03-2:PASS"
......@@ -122,20 +122,20 @@ test_003(){
fail $TEST_NAME "03-2:FAIL"
fi
out=`lcrc ps | grep one | awk '{print $1}'`
lcrc rm -f one > /dev/null
out=`isula ps | grep one | awk '{print $1}'`
isula rm -f one > /dev/null
}
test_005(){
#test mount a Empty dirct
out=`lcrc run --name one --hook-spec /var/lib/lcrd/hooks/hookspec.json -d $UBUNTU_IMAGE bash -c "sleep 10000"`
out=`isula run --name one --hook-spec /var/lib/isulad/hooks/hookspec.json -d $UBUNTU_IMAGE bash -c "sleep 10000"`
container_status $out
if [ "${status}x" != "runningx" ]; then
fail $TEST_NAME "05:FAIL"
fi
mkdir -p /tmp/isulad_test/test
$ISULAD_TOOLS add-path $out /tmp/isulad_test/test:/tmp:rw > /dev/null 2>&1
out1=`lcrc exec one bash -c "mount | awk 'END{print $1}'"`
out1=`isula exec one bash -c "mount | awk 'END{print $1}'"`
out1=${out1%on*}
out2=${out1##*/}
if [ "$out1" == "/dev/$out2" ]; then
......@@ -143,28 +143,28 @@ test_005(){
else
fail $TEST_NAME "05-1:FAIL"
fi
lcrc rm -f one > /dev/null
isula rm -f one > /dev/null
}
test_006(){
#test can not add ro and rw
out=`lcrc run --name one --hook-spec /var/lib/lcrd/hooks/hookspec.json -d $UBUNTU_IMAGE bash -c "sleep 10000"`
out=`isula run --name one --hook-spec /var/lib/isulad/hooks/hookspec.json -d $UBUNTU_IMAGE bash -c "sleep 10000"`
container_status $out
if [ "${status}x" != "runningx" ]; then
fail $TEST_NAME "06:FAIL"
fi
out=`lcrc exec $out sh -c "cd tmp && ls && echo cc > b.txt && cat b.txt"`
out=`isula exec $out sh -c "cd tmp && ls && echo cc > b.txt && cat b.txt"`
if [ "$out" == "cc" ]; then
success $TEST_NAME "06-1:PASS"
else
fail $TEST_NAME "06-1:FAIL"
fi
lcrc rm -f one > /dev/null
isula rm -f one > /dev/null
}
test_007(){
#test remove dirct
out=`lcrc run --name one --hook-spec /var/lib/lcrd/hooks/hookspec.json -d $UBUNTU_IMAGE bash -c "sleep 10000"`
out=`isula run --name one --hook-spec /var/lib/isulad/hooks/hookspec.json -d $UBUNTU_IMAGE bash -c "sleep 10000"`
container_status $out
if [ "${status}x" != "runningx" ]; then
fail $TEST_NAME "07:FAIL"
......@@ -183,14 +183,14 @@ test_007(){
if [ $out -ne 0 ]; then
fail $TEST_NAME "07-1:FAIL"
fi
out=`lcrc exec one bash -c "cat /tmp/b.txt"`
out=`isula exec one bash -c "cat /tmp/b.txt"`
if [ "$out" != "hello" ]; then
fail $TEST_NAME "07-2:FAIL"
fi
# remove the path from container.
$ISULAD_TOOLS remove-path one $TEST_FOLDER:/tmp:rw > /dev/null
out=`lcrc exec one bash -c "ls -l /tmp"`
out=`isula exec one bash -c "ls -l /tmp"`
if [ "$out" == "total 0" ]; then
success $TEST_NAME "07-3:PASS"
else
......@@ -198,12 +198,12 @@ test_007(){
fi
# clean up container.
lcrc rm -f one > /dev/null
isula rm -f one > /dev/null
}
test_008(){
out=`lcrc run --name one --hook-spec /var/lib/lcrd/hooks/hookspec.json -d $UBUNTU_IMAGE bash -c "sleep 100000"`
out2=`lcrc ps | grep one | awk '{print $1}'`
out=`isula run --name one --hook-spec /var/lib/isulad/hooks/hookspec.json -d $UBUNTU_IMAGE bash -c "sleep 100000"`
out2=`isula ps | grep one | awk '{print $1}'`
$ISULAD_TOOLS add-path $out2 $out1:/tmp:rw > /dev/null 2>&1
out=`echo $?`
if [ $out -ne 0 ]; then
......@@ -211,7 +211,7 @@ test_008(){
else
fail $TEST_NAME "08-1:FAIL"
fi
lcrc rm -f one > /dev/null
isula rm -f one > /dev/null
}
main(){
test_001
......
......@@ -23,12 +23,12 @@ test_001(){
ip link set $BR up
ip a a 192.168.182.1/24 dev $BR
CONTAINER_ID=`lcrc run -d --net none $BUSYBOX_IMAGE top`
CONTAINER_ID=`isula run -d --net none $BUSYBOX_IMAGE top`
$ISULAD_TOOLS --debug --log $TMP/isulad-tools.log add-nic \
--type veth --name eth0 --ip 192.168.182.2/24 \
--mac "aa:bb:cc:dd:ee:aa" --bridge $BR --mtu 1450 \
$CONTAINER_ID
lcrc exec --privileged $CONTAINER_ID ip route delete 192.168.182.0/24
isula exec --privileged $CONTAINER_ID ip route delete 192.168.182.0/24
$ISULAD_TOOLS add-route $CONTAINER_ID '[{"dest":"192.168.182.0/24", "src":"192.168.182.2","dev":"eth0"}]'
if [ $? -ne 0 ]; then
fail $TEST_NAME "01-1:FAIL"
......@@ -44,14 +44,14 @@ test_001(){
# success $TEST_NAME "01-1:PASS"
#fi
rules=`lcrc exec $CONTAINER_ID ip route`
rules=`isula exec $CONTAINER_ID ip route`
echo $rules | grep "192.168.182.0/24 dev eth0 src 192.168.182.2" > /dev/null 2>&1
if [ $? -ne 0 ]; then
fail $TEST_NAME "01-2:FAIL"
else
success $TEST_NAME "01-2:PASS"
fi
lcrc rm -f $CONTAINER_ID > /dev/null 2>&1
isula rm -f $CONTAINER_ID > /dev/null 2>&1
brctl delbr $BR > /dev/null 2>&1
}
......
......@@ -15,7 +15,7 @@
container_status(){
id=$1
status=`lcrc inspect ${id:00:12} | grep Status | awk -F ":" '{print $2}'`
status=`isula inspect ${id:00:12} | grep Status | awk -F ":" '{print $2}'`
status=${status#*\"}
status=${status%%\"*}
}
......
......@@ -25,7 +25,7 @@ import (
"github.com/opencontainers/runtime-spec/specs-go"
)
// lcrc info may result in dead lock when start with restart policy
// isula info may result in dead lock when start with restart policy
// try to get isulad root path with hook path
func getGraphDriverPath() (string, error) {
path, err := os.Executable()
......@@ -33,7 +33,7 @@ func getGraphDriverPath() (string, error) {
return "", err
}
// get /var/lib/lcrd from /var/lib/lcrd/hooks/isulad-hooks
// get /var/lib/isulad from /var/lib/isulad/hooks/isulad-hooks
dir := filepath.Dir(filepath.Dir(path))
return dir, nil
}
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册