mirror of
https://github.com/intel/intel-device-plugins-for-kubernetes.git
synced 2025-06-03 03:59:37 +00:00
fpga_crihook: improve unit tests
- increased test coverage to 91.4% - cleaned up the code - removed unused test data Signed-off-by: Ed Bartosh <eduard.bartosh@intel.com>
This commit is contained in:
parent
70ac83bdc6
commit
a668c596b2
@ -26,7 +26,6 @@ import (
|
||||
"github.com/intel/intel-device-plugins-for-kubernetes/pkg/fpga/bitstream"
|
||||
"github.com/pkg/errors"
|
||||
"k8s.io/klog"
|
||||
utilsexec "k8s.io/utils/exec"
|
||||
)
|
||||
|
||||
const (
|
||||
@ -57,6 +56,9 @@ type Config struct {
|
||||
} `json:"linux"`
|
||||
}
|
||||
|
||||
// newPortFun defines a function type that returns fpga.Port
|
||||
type newPortFun func(string) (fpga.Port, error)
|
||||
|
||||
// Device defines structure for Config.Linux.Devices entries
|
||||
type Device struct {
|
||||
// these fields are set by the hook
|
||||
@ -88,7 +90,7 @@ func decodeJSONStream(reader io.Reader, dest interface{}) error {
|
||||
type hookEnv struct {
|
||||
bitstreamDir string
|
||||
config string
|
||||
execer utilsexec.Interface
|
||||
newPort newPortFun
|
||||
}
|
||||
|
||||
type fpgaParams struct {
|
||||
@ -97,11 +99,11 @@ type fpgaParams struct {
|
||||
portDevice string
|
||||
}
|
||||
|
||||
func newHookEnv(bitstreamDir string, config string, execer utilsexec.Interface) *hookEnv {
|
||||
func newHookEnv(bitstreamDir string, config string, newPort newPortFun) *hookEnv {
|
||||
return &hookEnv{
|
||||
bitstreamDir: bitstreamDir,
|
||||
config: config,
|
||||
execer: execer,
|
||||
newPort: newPort,
|
||||
}
|
||||
}
|
||||
|
||||
@ -152,10 +154,6 @@ func (he *hookEnv) getFPGAParams(config *Config) ([]fpgaParams, error) {
|
||||
return nil, errors.Errorf("No %s* environment variables are set", fpgaAfuEnvPrefix)
|
||||
}
|
||||
|
||||
if len(afuEnv) != len(regionEnv) {
|
||||
return nil, errors.Errorf("Environment variables %s* and %s* don't match", fpgaRegionEnvPrefix, fpgaAfuEnvPrefix)
|
||||
}
|
||||
|
||||
params := []fpgaParams{}
|
||||
for num, region := range regionEnv {
|
||||
afu, ok := afuEnv[num]
|
||||
@ -176,7 +174,7 @@ func (he *hookEnv) getFPGAParams(config *Config) ([]fpgaParams, error) {
|
||||
if dev.processed {
|
||||
continue
|
||||
}
|
||||
port, err := fpga.NewPort(deviceName)
|
||||
port, err := he.newPort(deviceName)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
@ -245,7 +243,7 @@ func (he *hookEnv) process(reader io.Reader) error {
|
||||
}
|
||||
|
||||
for _, params := range paramslist {
|
||||
port, err := fpga.NewPort(params.portDevice)
|
||||
port, err := he.newPort(params.portDevice)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
@ -256,21 +254,21 @@ func (he *hookEnv) process(reader io.Reader) error {
|
||||
return nil
|
||||
}
|
||||
|
||||
bitstream, err := bitstream.GetFPGABitstream(he.bitstreamDir, params.region, params.afu)
|
||||
bstream, err := bitstream.GetFPGABitstream(he.bitstreamDir, params.region, params.afu)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
defer bitstream.Close()
|
||||
defer bstream.Close()
|
||||
|
||||
err = port.PR(bitstream, false)
|
||||
err = port.PR(bstream, false)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
programmedAfu = port.GetAcceleratorTypeUUID()
|
||||
|
||||
if programmedAfu != bitstream.AcceleratorTypeUUID() {
|
||||
return errors.Errorf("programmed function %s instead of %s", programmedAfu, bitstream.AcceleratorTypeUUID())
|
||||
if programmedAfu != bstream.AcceleratorTypeUUID() {
|
||||
return errors.Errorf("programmed function %s instead of %s", programmedAfu, bstream.AcceleratorTypeUUID())
|
||||
}
|
||||
}
|
||||
|
||||
@ -286,7 +284,7 @@ func main() {
|
||||
os.Setenv("PATH", "/sbin:/usr/sbin:/usr/local/sbin:/usr/local/bin:/usr/bin:/bin")
|
||||
}
|
||||
|
||||
he := newHookEnv(fpgaBitStreamDirectory, configJSON, utilsexec.New())
|
||||
he := newHookEnv(fpgaBitStreamDirectory, configJSON, fpga.NewPort)
|
||||
|
||||
if err := he.process(os.Stdin); err != nil {
|
||||
klog.Errorf("%+v", err)
|
||||
|
@ -16,13 +16,13 @@ package main
|
||||
|
||||
import (
|
||||
"flag"
|
||||
"fmt"
|
||||
"io/ioutil"
|
||||
"os"
|
||||
"path"
|
||||
"testing"
|
||||
"time"
|
||||
|
||||
"github.com/intel/intel-device-plugins-for-kubernetes/pkg/fpga"
|
||||
"github.com/intel/intel-device-plugins-for-kubernetes/pkg/fpga/bitstream"
|
||||
"github.com/pkg/errors"
|
||||
)
|
||||
|
||||
@ -158,7 +158,7 @@ func TestGetConfig(t *testing.T) {
|
||||
t.Fatalf("can't decode %s: %+v", fname, err)
|
||||
}
|
||||
|
||||
he := newHookEnv("", tc.configJSON, nil)
|
||||
he := newHookEnv("", tc.configJSON, fpga.NewPort)
|
||||
|
||||
config, err := he.getConfig(stdinJ)
|
||||
if err != nil {
|
||||
@ -177,10 +177,53 @@ func TestGetConfig(t *testing.T) {
|
||||
}
|
||||
}
|
||||
|
||||
// testFpgaPort represent Fake FPGA Port device for testing purposes
|
||||
type testFpgaPort struct {
|
||||
fpga.Port
|
||||
callNo int
|
||||
interfaceUUIDS []string
|
||||
accelTypeUUIDS []string
|
||||
failProgramming bool
|
||||
}
|
||||
|
||||
// GetInterfaceUUID returns Interface UUID
|
||||
func (p *testFpgaPort) GetInterfaceUUID() (id string) {
|
||||
uuid := p.interfaceUUIDS[p.callNo]
|
||||
p.callNo++
|
||||
return uuid
|
||||
}
|
||||
|
||||
// GetAcceleratorTypeUUID returns AFU UUID
|
||||
func (p *testFpgaPort) GetAcceleratorTypeUUID() string {
|
||||
uuid := p.accelTypeUUIDS[p.callNo]
|
||||
p.callNo++
|
||||
return uuid
|
||||
}
|
||||
|
||||
// PR fakes programming specified bitstream
|
||||
func (p *testFpgaPort) PR(bs bitstream.File, dryRun bool) error {
|
||||
if p.failProgramming {
|
||||
return errors.New("fail to program device")
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
func newTestPort(dev string) (fpga.Port, error) {
|
||||
return &testFpgaPort{
|
||||
interfaceUUIDS: []string{"ce48969398f05f33946d560708be108a"},
|
||||
accelTypeUUIDS: []string{"d8424dc4a4a3c413f89e433683f9040b"},
|
||||
}, nil
|
||||
}
|
||||
|
||||
func TestGetFPGAParams(t *testing.T) {
|
||||
tmpdir := fmt.Sprintf("/tmp/fpgacriohook-TestGetFPGAParams-%d", time.Now().Unix())
|
||||
sysfsOPAE := path.Join(tmpdir, "sys", "class", "fpga")
|
||||
// sysfsDFL := path.Join(tmpdir, "sys", "class", "fpga_region")
|
||||
tmpdir, err := ioutil.TempDir("", "TestGetFPGAParams")
|
||||
if err != nil {
|
||||
t.Fatalf("can't create temporary directory: %+v", err)
|
||||
}
|
||||
defer os.RemoveAll(tmpdir)
|
||||
|
||||
sysfsTest := path.Join(tmpdir, "sys", "class", "fpga")
|
||||
|
||||
tcases := []struct {
|
||||
name string
|
||||
sysfs string
|
||||
@ -194,79 +237,49 @@ func TestGetFPGAParams(t *testing.T) {
|
||||
expectedAFU string
|
||||
expectedPortDevice string
|
||||
}{
|
||||
// {
|
||||
// name: "correct OPAE setup",
|
||||
// sysfs: sysfsOPAE,
|
||||
// stdinJSON: "stdin-correct.json",
|
||||
// configJSON: "config-correct.json",
|
||||
// sysfsdirs: []string{
|
||||
// "intel-fpga-dev.0/intel-fpga-fme.0/pr",
|
||||
// "intel-fpga-dev.0/intel-fpga-port.0",
|
||||
// },
|
||||
// sysfsfiles: map[string][]byte{
|
||||
// "intel-fpga-dev.0/intel-fpga-fme.0/pr/interface_id": []byte("ce48969398f05f33946d560708be108a"),
|
||||
// "intel-fpga-dev.0/intel-fpga-port.0/afu_id": []byte("f7df405cbd7acf7222f144b0b93acd18"),
|
||||
// "intel-fpga-dev.0/intel-fpga-port.0/dev": []byte("100:0"),
|
||||
// },
|
||||
// expectedErr: false,
|
||||
// expectedRegion: "ce48969398f05f33946d560708be108a",
|
||||
// expectedAFU: "f7df405cbd7acf7222f144b0b93acd18",
|
||||
// expectedPortDevice: "intel-fpga-port.0",
|
||||
// },
|
||||
// {
|
||||
// name: "correct DFL setup",
|
||||
// sysfs: sysfsDFL,
|
||||
// stdinJSON: "stdin-correct.json",
|
||||
// configJSON: "config-correct-DFL.json",
|
||||
// sysfsdirs: []string{
|
||||
// "region0/dfl-fme.0/dfl-fme-region.1/fpga_region/region1",
|
||||
// "region0/dfl-port.0",
|
||||
// },
|
||||
// sysfsfiles: map[string][]byte{
|
||||
// "region0/dfl-fme.0/dfl-fme-region.1/fpga_region/region1/compat_id": []byte("ce48969398f05f33946d560708be108a"),
|
||||
// "region0/dfl-port.0/afu_id": []byte("f7df405cbd7acf7222f144b0b93acd18"),
|
||||
// "region0/dfl-port.0/dev": []byte("100:0"),
|
||||
// },
|
||||
// expectedErr: false,
|
||||
// expectedRegion: "ce48969398f05f33946d560708be108a",
|
||||
// expectedAFU: "f7df405cbd7acf7222f144b0b93acd18",
|
||||
// expectedPortDevice: "dfl-port.0",
|
||||
// },
|
||||
// {
|
||||
// name: "incorrect interface id",
|
||||
// sysfs: sysfsOPAE,
|
||||
// stdinJSON: "stdin-correct.json",
|
||||
// configJSON: "config-correct.json",
|
||||
// sysfsdirs: []string{"intel-fpga-dev.0/intel-fpga-fme.0/pr"},
|
||||
// sysfsfiles: map[string][]byte{
|
||||
// "intel-fpga-dev.0/intel-fpga-fme.0/pr/interface_id": []byte("incorrectinterfaceuuid"),
|
||||
// },
|
||||
// expectedErr: true,
|
||||
// },
|
||||
{
|
||||
name: "valid setup",
|
||||
sysfs: sysfsTest,
|
||||
stdinJSON: "stdin-correct.json",
|
||||
configJSON: "config-correct.json",
|
||||
sysfsdirs: []string{
|
||||
"intel-fpga-dev.0/test-fpga-fme.0/pr",
|
||||
"intel-fpga-dev.0/test-fpga-port.0",
|
||||
},
|
||||
sysfsfiles: map[string][]byte{
|
||||
"intel-fpga-dev.0/test-fpga-fme.0/pr/interface_id": []byte("ce48969398f05f33946d560708be108a"),
|
||||
"intel-fpga-dev.0/test-fpga-port.0/afu_id": []byte("f7df405cbd7acf7222f144b0b93acd18"),
|
||||
"intel-fpga-dev.0/test-fpga-port.0/dev": []byte("100:0"),
|
||||
},
|
||||
expectedErr: false,
|
||||
expectedRegion: "ce48969398f05f33946d560708be108a",
|
||||
expectedAFU: "f7df405cbd7acf7222f144b0b93acd18",
|
||||
expectedPortDevice: "intel-fpga-port.0",
|
||||
},
|
||||
{
|
||||
name: "no region in config",
|
||||
sysfs: sysfsOPAE,
|
||||
sysfs: sysfsTest,
|
||||
stdinJSON: "stdin-correct.json",
|
||||
configJSON: "config-no-region.json",
|
||||
expectedErr: true,
|
||||
},
|
||||
{
|
||||
name: "no AFU in config",
|
||||
sysfs: sysfsOPAE,
|
||||
sysfs: sysfsTest,
|
||||
stdinJSON: "stdin-correct.json",
|
||||
configJSON: "config-no-afu.json",
|
||||
expectedErr: true,
|
||||
},
|
||||
{
|
||||
name: "no FPGA devices in config",
|
||||
sysfs: sysfsOPAE,
|
||||
sysfs: sysfsTest,
|
||||
stdinJSON: "stdin-correct.json",
|
||||
configJSON: "config-no-FPGA-devices.json",
|
||||
expectedErr: true,
|
||||
},
|
||||
{
|
||||
name: "region and AFU don't match",
|
||||
sysfs: sysfsOPAE,
|
||||
sysfs: sysfsTest,
|
||||
stdinJSON: "stdin-correct.json",
|
||||
configJSON: "config-region-afu-dont-match.json",
|
||||
expectedErr: true,
|
||||
@ -284,7 +297,7 @@ func TestGetFPGAParams(t *testing.T) {
|
||||
t.Fatalf("can't create temp files: %+v", err)
|
||||
}
|
||||
|
||||
he := newHookEnv("", tc.configJSON, nil)
|
||||
he := newHookEnv("", tc.configJSON, newTestPort)
|
||||
|
||||
stdinJ, err := getStdin(stdin)
|
||||
if err != nil {
|
||||
@ -318,3 +331,142 @@ func TestGetFPGAParams(t *testing.T) {
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
func TestProcess(t *testing.T) {
|
||||
tmpdir, err := ioutil.TempDir("", "testProcess")
|
||||
if err != nil {
|
||||
t.Fatalf("can't create temporary directory: %+v", err)
|
||||
}
|
||||
defer os.RemoveAll(tmpdir)
|
||||
|
||||
sysfs := path.Join(tmpdir, "sys", "class", "fpga")
|
||||
tcases := []struct {
|
||||
name string
|
||||
stdinJSON string
|
||||
configJSON string
|
||||
sysfsdirs []string
|
||||
sysfsfiles map[string][]byte
|
||||
newPort newPortFun
|
||||
expectedErr bool
|
||||
}{
|
||||
{
|
||||
name: "Reprogramming",
|
||||
stdinJSON: "stdin-correct.json",
|
||||
configJSON: "config-correct.json",
|
||||
sysfsdirs: []string{"intel-fpga-dev.0/intel-fpga-fme.0/pr"},
|
||||
sysfsfiles: map[string][]byte{
|
||||
"intel-fpga-dev.0/intel-fpga-fme.0/pr/interface_id": []byte("ce48969398f05f33946d560708be108a"),
|
||||
},
|
||||
newPort: func(dev string) (fpga.Port, error) {
|
||||
return &testFpgaPort{
|
||||
interfaceUUIDS: []string{"ce48969398f05f33946d560708be108a"},
|
||||
accelTypeUUIDS: []string{
|
||||
"d8424dc4a4a3c413f89e433683f9040b",
|
||||
"f7df405cbd7acf7222f144b0b93acd18"},
|
||||
}, nil
|
||||
},
|
||||
},
|
||||
{
|
||||
name: "Broken stdin",
|
||||
stdinJSON: "stdin-broken-json.json",
|
||||
expectedErr: true,
|
||||
},
|
||||
{
|
||||
name: "Broken config",
|
||||
stdinJSON: "stdin-correct.json",
|
||||
configJSON: "config-broken-json.json",
|
||||
expectedErr: true,
|
||||
},
|
||||
{
|
||||
name: "Failing to get FPGA params",
|
||||
stdinJSON: "stdin-correct.json",
|
||||
configJSON: "config-no-region.json",
|
||||
expectedErr: true,
|
||||
},
|
||||
{
|
||||
name: "Already programmed",
|
||||
stdinJSON: "stdin-correct.json",
|
||||
configJSON: "config-correct.json",
|
||||
sysfsdirs: []string{"intel-fpga-dev.0/intel-fpga-fme.0/pr"},
|
||||
sysfsfiles: map[string][]byte{
|
||||
"intel-fpga-dev.0/intel-fpga-fme.0/pr/interface_id": []byte("ce48969398f05f33946d560708be108a"),
|
||||
},
|
||||
newPort: func(dev string) (fpga.Port, error) {
|
||||
return &testFpgaPort{
|
||||
interfaceUUIDS: []string{"ce48969398f05f33946d560708be108a"},
|
||||
accelTypeUUIDS: []string{"f7df405cbd7acf7222f144b0b93acd18"},
|
||||
}, nil
|
||||
},
|
||||
},
|
||||
{
|
||||
name: "Non-existing bitstream",
|
||||
stdinJSON: "stdin-correct.json",
|
||||
configJSON: "config-non-existing-bitstream.json",
|
||||
newPort: func(dev string) (fpga.Port, error) {
|
||||
return &testFpgaPort{
|
||||
interfaceUUIDS: []string{"ce48969398f05f33946d560708be108a"},
|
||||
accelTypeUUIDS: []string{
|
||||
"d8424dc4a4a3c413f89e433683f9040b",
|
||||
"f7df405cbd7acf7222f144b0b93acd18"},
|
||||
}, nil
|
||||
},
|
||||
expectedErr: true,
|
||||
},
|
||||
{
|
||||
name: "Programming fails",
|
||||
stdinJSON: "stdin-correct.json",
|
||||
configJSON: "config-correct.json",
|
||||
newPort: func(dev string) (fpga.Port, error) {
|
||||
return &testFpgaPort{
|
||||
interfaceUUIDS: []string{"ce48969398f05f33946d560708be108a"},
|
||||
accelTypeUUIDS: []string{
|
||||
"d8424dc4a4a3c413f89e433683f9040b",
|
||||
"f7df405cbd7acf7222f144b0b93acd18"},
|
||||
failProgramming: true,
|
||||
}, nil
|
||||
},
|
||||
expectedErr: true,
|
||||
},
|
||||
{
|
||||
name: "Device is not reprogrammed",
|
||||
stdinJSON: "stdin-correct.json",
|
||||
configJSON: "config-correct.json",
|
||||
newPort: func(dev string) (fpga.Port, error) {
|
||||
return &testFpgaPort{
|
||||
interfaceUUIDS: []string{"ce48969398f05f33946d560708be108a"},
|
||||
accelTypeUUIDS: []string{
|
||||
"d8424dc4a4a3c413f89e433683f9040b",
|
||||
"d8424dc4a4a3c413f89e433683f9040b"},
|
||||
}, nil
|
||||
},
|
||||
expectedErr: true,
|
||||
},
|
||||
}
|
||||
|
||||
for _, tc := range tcases {
|
||||
t.Run(tc.name, func(t *testing.T) {
|
||||
stdin, err := os.Open(path.Join("testdata", tc.stdinJSON))
|
||||
if err != nil {
|
||||
t.Fatalf("can't open file %s: %v", tc.stdinJSON, err)
|
||||
}
|
||||
|
||||
err = createTestDirs(sysfs, tc.sysfsdirs, tc.sysfsfiles)
|
||||
if err != nil {
|
||||
t.Fatalf("can't create temp files: %+v", err)
|
||||
}
|
||||
|
||||
he := newHookEnv("testdata/intel.com/fpga", tc.configJSON, tc.newPort)
|
||||
|
||||
err = he.process(stdin)
|
||||
|
||||
if err != nil && !tc.expectedErr {
|
||||
t.Errorf("[%s]: unexpected error: %+v", tc.name, err)
|
||||
}
|
||||
|
||||
err = os.RemoveAll(tmpdir)
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
})
|
||||
}
|
||||
}
|
||||
|
136
cmd/fpga_crihook/testdata/config-correct-DFL.json
vendored
136
cmd/fpga_crihook/testdata/config-correct-DFL.json
vendored
@ -1,136 +0,0 @@
|
||||
{
|
||||
"ociVersion": "1.0.0",
|
||||
"process": {
|
||||
"user": {
|
||||
"uid": 0,
|
||||
"gid": 0
|
||||
},
|
||||
"args": [
|
||||
"sh",
|
||||
"/usr/bin/test_fpga.sh"
|
||||
],
|
||||
"env": [
|
||||
"PATH=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin",
|
||||
"TERM=xterm",
|
||||
"HOSTNAME=test-fpga-region",
|
||||
"FPGA_REGION_1=ce48969398f05f33946d560708be108a",
|
||||
"FPGA_AFU_1=f7df405cbd7acf7222f144b0b93acd18",
|
||||
"KUBERNETES_SERVICE_PORT=443",
|
||||
"KUBERNETES_PORT_443_TCP_PROTO=tcp",
|
||||
"OPAE_URL=https://github.com/OPAE/opae-sdk/releases/download/1.0.0-5"
|
||||
],
|
||||
"oomScoreAdj": 999
|
||||
},
|
||||
"hostname": "test-fpga-region",
|
||||
"mounts": [
|
||||
{
|
||||
"destination": "/proc",
|
||||
"type": "proc",
|
||||
"source": "proc"
|
||||
},
|
||||
{
|
||||
"destination": "/dev",
|
||||
"type": "tmpfs",
|
||||
"source": "tmpfs",
|
||||
"options": [
|
||||
"nosuid",
|
||||
"strictatime",
|
||||
"mode=755",
|
||||
"size=65536k"
|
||||
]
|
||||
},
|
||||
{
|
||||
"destination": "/sys",
|
||||
"type": "sysfs",
|
||||
"source": "sysfs",
|
||||
"options": [
|
||||
"nosuid",
|
||||
"noexec",
|
||||
"nodev",
|
||||
"ro"
|
||||
]
|
||||
}
|
||||
],
|
||||
"hooks": {
|
||||
"prestart": [
|
||||
{
|
||||
"path": "/usr/local/bin/fpga_crihook",
|
||||
"args": [
|
||||
"/usr/local/bin/fpga_crihook"
|
||||
],
|
||||
"env": [
|
||||
"stage=prestart"
|
||||
]
|
||||
}
|
||||
]
|
||||
},
|
||||
"annotations": {
|
||||
"io.kubernetes.container.hash": "22e3c9bc",
|
||||
"io.kubernetes.container.name": "test-container",
|
||||
"io.kubernetes.container.restartCount": "0",
|
||||
"io.kubernetes.container.terminationMessagePolicy": "File",
|
||||
"io.kubernetes.cri-o.ContainerID": "a15ee43034ade4083279bdbb7cf656a971809cfb00eb97a7751bb46dd74c9150",
|
||||
"io.kubernetes.cri-o.ContainerType": "container",
|
||||
"io.kubernetes.cri-o.Created": "2018-06-20T15:08:41.361981842+03:00",
|
||||
"io.kubernetes.cri-o.LogPath": "/var/log/pods/a869ac70-7482-11e8-a041-c81f66f62fcc/test-container/0.log",
|
||||
"io.kubernetes.cri-o.Metadata": "{\"name\":\"test-container\"}",
|
||||
"io.kubernetes.cri-o.SandboxID": "a30829b039e1c631432fe7ab5c748a393c105ed90ec42a6cc95bd7d33356b94e",
|
||||
"io.kubernetes.cri-o.SandboxName": "k8s_POD_test-fpga-region_default_a869ac70-7482-11e8-a041-c81f66f62fcc_0",
|
||||
"io.kubernetes.cri-o.SeccompProfilePath": "",
|
||||
"io.kubernetes.cri-o.Stdin": "false",
|
||||
"io.kubernetes.cri-o.StdinOnce": "false",
|
||||
"io.kubernetes.cri-o.TTY": "false",
|
||||
"io.kubernetes.pod.name": "test-fpga-region",
|
||||
"io.kubernetes.pod.namespace": "default",
|
||||
"io.kubernetes.pod.terminationGracePeriod": "30",
|
||||
"io.kubernetes.pod.uid": "a869ac70-7482-11e8-a041-c81f66f62fcc"
|
||||
},
|
||||
"linux": {
|
||||
"resources": {
|
||||
"devices": [
|
||||
{
|
||||
"allow": false,
|
||||
"access": "rwm"
|
||||
},
|
||||
{
|
||||
"allow": true,
|
||||
"type": "c",
|
||||
"major": 243,
|
||||
"minor": 0,
|
||||
"access": "mrw"
|
||||
}
|
||||
],
|
||||
"memory": {
|
||||
"limit": 0
|
||||
},
|
||||
"cpu": {
|
||||
"shares": 1024,
|
||||
"quota": 100000,
|
||||
"period": 100000
|
||||
},
|
||||
"pids": {
|
||||
"limit": 1024
|
||||
}
|
||||
},
|
||||
"cgroupsPath": "/kubepods/burstable/poda869ac70-7482-11e8-a041-c81f66f62fcc/crio-a15ee43034ade4083279bdbb7cf656a971809cfb00eb97a7751bb46dd74c9150",
|
||||
"namespaces": [
|
||||
{
|
||||
"type": "pid"
|
||||
},
|
||||
{
|
||||
"type": "mount"
|
||||
}
|
||||
],
|
||||
"devices": [
|
||||
{
|
||||
"path": "/dev/dfl-port.0",
|
||||
"type": "c",
|
||||
"major": 243,
|
||||
"minor": 0,
|
||||
"uid": 0,
|
||||
"gid": 0
|
||||
}
|
||||
],
|
||||
"rootfsPropagation": "rslave"
|
||||
}
|
||||
}
|
138
cmd/fpga_crihook/testdata/config-missing-env.json
vendored
138
cmd/fpga_crihook/testdata/config-missing-env.json
vendored
@ -1,138 +0,0 @@
|
||||
{
|
||||
"ociVersion": "1.0.0",
|
||||
"process": {
|
||||
"user": {
|
||||
"uid": 0,
|
||||
"gid": 0
|
||||
},
|
||||
"args": [
|
||||
"sh",
|
||||
"/usr/bin/test_fpga.sh"
|
||||
],
|
||||
"env": [
|
||||
"PATH=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin",
|
||||
"TERM=xterm",
|
||||
"HOSTNAME=test-fpga-region",
|
||||
"FPGA_REGION_1=ce48969398f05f33946d560708be108a",
|
||||
"FPGA_AFU_1=f7df405cbd7acf7222f144b0b93acd18",
|
||||
"FPGA_REGION_2=ce48969398f05f33946d560708be108a",
|
||||
"FPGA_AFU_3=f7df405cbd7acf7222f144b0b93acd18",
|
||||
"KUBERNETES_SERVICE_PORT=443",
|
||||
"KUBERNETES_PORT_443_TCP_PROTO=tcp",
|
||||
"OPAE_URL=https://github.com/OPAE/opae-sdk/releases/download/1.0.0-5"
|
||||
],
|
||||
"oomScoreAdj": 999
|
||||
},
|
||||
"hostname": "test-fpga-region",
|
||||
"mounts": [
|
||||
{
|
||||
"destination": "/proc",
|
||||
"type": "proc",
|
||||
"source": "proc"
|
||||
},
|
||||
{
|
||||
"destination": "/dev",
|
||||
"type": "tmpfs",
|
||||
"source": "tmpfs",
|
||||
"options": [
|
||||
"nosuid",
|
||||
"strictatime",
|
||||
"mode=755",
|
||||
"size=65536k"
|
||||
]
|
||||
},
|
||||
{
|
||||
"destination": "/sys",
|
||||
"type": "sysfs",
|
||||
"source": "sysfs",
|
||||
"options": [
|
||||
"nosuid",
|
||||
"noexec",
|
||||
"nodev",
|
||||
"ro"
|
||||
]
|
||||
}
|
||||
],
|
||||
"hooks": {
|
||||
"prestart": [
|
||||
{
|
||||
"path": "/usr/local/bin/fpga_crihook",
|
||||
"args": [
|
||||
"/usr/local/bin/fpga_crihook"
|
||||
],
|
||||
"env": [
|
||||
"stage=prestart"
|
||||
]
|
||||
}
|
||||
]
|
||||
},
|
||||
"annotations": {
|
||||
"io.kubernetes.container.hash": "22e3c9bc",
|
||||
"io.kubernetes.container.name": "test-container",
|
||||
"io.kubernetes.container.restartCount": "0",
|
||||
"io.kubernetes.container.terminationMessagePolicy": "File",
|
||||
"io.kubernetes.cri-o.ContainerID": "a15ee43034ade4083279bdbb7cf656a971809cfb00eb97a7751bb46dd74c9150",
|
||||
"io.kubernetes.cri-o.ContainerType": "container",
|
||||
"io.kubernetes.cri-o.Created": "2018-06-20T15:08:41.361981842+03:00",
|
||||
"io.kubernetes.cri-o.LogPath": "/var/log/pods/a869ac70-7482-11e8-a041-c81f66f62fcc/test-container/0.log",
|
||||
"io.kubernetes.cri-o.Metadata": "{\"name\":\"test-container\"}",
|
||||
"io.kubernetes.cri-o.SandboxID": "a30829b039e1c631432fe7ab5c748a393c105ed90ec42a6cc95bd7d33356b94e",
|
||||
"io.kubernetes.cri-o.SandboxName": "k8s_POD_test-fpga-region_default_a869ac70-7482-11e8-a041-c81f66f62fcc_0",
|
||||
"io.kubernetes.cri-o.SeccompProfilePath": "",
|
||||
"io.kubernetes.cri-o.Stdin": "false",
|
||||
"io.kubernetes.cri-o.StdinOnce": "false",
|
||||
"io.kubernetes.cri-o.TTY": "false",
|
||||
"io.kubernetes.pod.name": "test-fpga-region",
|
||||
"io.kubernetes.pod.namespace": "default",
|
||||
"io.kubernetes.pod.terminationGracePeriod": "30",
|
||||
"io.kubernetes.pod.uid": "a869ac70-7482-11e8-a041-c81f66f62fcc"
|
||||
},
|
||||
"linux": {
|
||||
"resources": {
|
||||
"devices": [
|
||||
{
|
||||
"allow": false,
|
||||
"access": "rwm"
|
||||
},
|
||||
{
|
||||
"allow": true,
|
||||
"type": "c",
|
||||
"major": 243,
|
||||
"minor": 0,
|
||||
"access": "mrw"
|
||||
}
|
||||
],
|
||||
"memory": {
|
||||
"limit": 0
|
||||
},
|
||||
"cpu": {
|
||||
"shares": 1024,
|
||||
"quota": 100000,
|
||||
"period": 100000
|
||||
},
|
||||
"pids": {
|
||||
"limit": 1024
|
||||
}
|
||||
},
|
||||
"cgroupsPath": "/kubepods/burstable/poda869ac70-7482-11e8-a041-c81f66f62fcc/crio-a15ee43034ade4083279bdbb7cf656a971809cfb00eb97a7751bb46dd74c9150",
|
||||
"namespaces": [
|
||||
{
|
||||
"type": "pid"
|
||||
},
|
||||
{
|
||||
"type": "mount"
|
||||
}
|
||||
],
|
||||
"devices": [
|
||||
{
|
||||
"path": "/dev/intel-fpga-port.0",
|
||||
"type": "c",
|
||||
"major": 243,
|
||||
"minor": 0,
|
||||
"uid": 0,
|
||||
"gid": 0
|
||||
}
|
||||
],
|
||||
"rootfsPropagation": "rslave"
|
||||
}
|
||||
}
|
@ -1 +0,0 @@
|
||||
#()YE@#YDEP#H21w
|
18
cmd/fpga_crihook/testdata/gbs-info-correct.json
vendored
18
cmd/fpga_crihook/testdata/gbs-info-correct.json
vendored
@ -1,18 +0,0 @@
|
||||
{
|
||||
"version": 1,
|
||||
"afu-image": {
|
||||
"clock-frequency-high": 312,
|
||||
"clock-frequency-low": 156,
|
||||
"power": 0,
|
||||
"interface-uuid": "ce489693-98f0-5f33-946d-560708be108a",
|
||||
"magic-no": 488605312,
|
||||
"accelerator-clusters": [
|
||||
{
|
||||
"total-contexts": 1,
|
||||
"name": "nlb_3",
|
||||
"accelerator-type-uuid": "f7df405c-bd7a-cf72-22f1-44b0b93acd18"
|
||||
}
|
||||
]
|
||||
},
|
||||
"platform-name": "DCP"
|
||||
}
|
@ -1,11 +0,0 @@
|
||||
{
|
||||
"version": 1,
|
||||
"afu-image": {
|
||||
"clock-frequency-high": 312,
|
||||
"clock-frequency-low": 156,
|
||||
"power": 0,
|
||||
"interface-uuid": "ce489693-98f0-5f33-946d-560708be108a",
|
||||
"magic-no": 488605312
|
||||
},
|
||||
"platform-name": "DCP"
|
||||
}
|
@ -1,17 +0,0 @@
|
||||
{
|
||||
"version": 1,
|
||||
"afu-image": {
|
||||
"clock-frequency-high": 312,
|
||||
"clock-frequency-low": 156,
|
||||
"power": 0,
|
||||
"interface-uuid": "ce489693-98f0-5f33-946d-560708be108a",
|
||||
"magic-no": 488605312,
|
||||
"accelerator-clusters": [
|
||||
{
|
||||
"total-contexts": 1,
|
||||
"name": "nlb_3"
|
||||
}
|
||||
]
|
||||
},
|
||||
"platform-name": "DCP"
|
||||
}
|
@ -1,4 +0,0 @@
|
||||
{
|
||||
"version": 1,
|
||||
"platform-name": "DCP"
|
||||
}
|
@ -1,17 +0,0 @@
|
||||
{
|
||||
"version": 1,
|
||||
"afu-image": {
|
||||
"clock-frequency-high": 312,
|
||||
"clock-frequency-low": 156,
|
||||
"power": 0,
|
||||
"magic-no": 488605312,
|
||||
"accelerator-clusters": [
|
||||
{
|
||||
"total-contexts": 1,
|
||||
"name": "nlb_3",
|
||||
"accelerator-type-uuid": "f7df405c-bd7a-cf72-22f1-44b0b93acd18"
|
||||
}
|
||||
]
|
||||
},
|
||||
"platform-name": "DCP"
|
||||
}
|
Binary file not shown.
@ -1,16 +0,0 @@
|
||||
{
|
||||
"annotations": {
|
||||
"io.kubernetes.container.hash": "b202a1fa",
|
||||
"io.kubernetes.container.name": "test-container",
|
||||
"io.kubernetes.container.restartCount": "0",
|
||||
"io.kubernetes.pod.name": "test-fpga-region",
|
||||
"io.kubernetes.pod.namespace": "default",
|
||||
"io.kubernetes.pod.terminationGracePeriod": "30",
|
||||
"io.kubernetes.pod.uid": "942e94c1-72d3-11e8-b221-c81f66f62fcc"
|
||||
},
|
||||
"bundle": "doesn't exist",
|
||||
"id": "1c40dd8efd268a47d7fb9f75d00f50c20af49d07d8d3c5fb948e68abb6d5ecf9",
|
||||
"ociVersion": "1.0.0",
|
||||
"pid": 39638,
|
||||
"status": ""
|
||||
}
|
@ -1,16 +0,0 @@
|
||||
{
|
||||
"annotations": {
|
||||
"io.kubernetes.container.hash": "b202a1fa",
|
||||
"io.kubernetes.container.name": "test-container",
|
||||
"io.kubernetes.container.restartCount": "0",
|
||||
"io.kubernetes.pod.name": "test-fpga-region",
|
||||
"io.kubernetes.pod.namespace": "default",
|
||||
"io.kubernetes.pod.terminationGracePeriod": "30",
|
||||
"io.kubernetes.pod.uid": "942e94c1-72d3-11e8-b221-c81f66f62fcc"
|
||||
},
|
||||
"bundle": "testdata",
|
||||
"id": "1c40dd8efd268a47d7fb9f75d00f50c20af49d07d8d3c5fb948e68abb6d5ecf9",
|
||||
"ociVersion": "1.0.0",
|
||||
"pid": 39638,
|
||||
"status": ""
|
||||
}
|
Loading…
Reference in New Issue
Block a user