mirror of
https://github.com/aljazceru/kata-containers.git
synced 2025-12-26 18:44:47 +01:00
Look at the provided cgroup path to determine whether systemd is being used to manage the cgroups. With this, systemd cgroups are being detected and created appropriately for the sandbox. Fixes: #599 Signed-off-by: Eric Ernsteernst <eric@amperecomputing.com> (forward port of https://github.com/kata-containers/runtime/pull/2817) Signed-off-by: Francesco Giudici <fgiudici@redhat.com>
39 lines
611 B
Go
39 lines
611 B
Go
// Copyright (c) 2020 Intel Corporation
|
|
//
|
|
// SPDX-License-Identifier: Apache-2.0
|
|
//
|
|
|
|
package cgroups
|
|
|
|
import (
|
|
"testing"
|
|
|
|
"github.com/stretchr/testify/assert"
|
|
)
|
|
|
|
//very very basic test; should be expanded
|
|
func TestNew(t *testing.T) {
|
|
assert := assert.New(t)
|
|
|
|
// create a cgroupfs cgroup manager
|
|
c := &Config{
|
|
Cgroups: nil,
|
|
CgroupPath: "",
|
|
}
|
|
|
|
mgr, err := New(c)
|
|
assert.NoError(err)
|
|
assert.NotNil(mgr.mgr)
|
|
|
|
// create a systemd cgroup manager
|
|
s := &Config{
|
|
Cgroups: nil,
|
|
CgroupPath: "system.slice:kubepod:container",
|
|
}
|
|
|
|
mgr, err = New(s)
|
|
assert.NoError(err)
|
|
assert.NotNil(mgr.mgr)
|
|
|
|
}
|