From a668c596b2f67abfa2aa7e33d4beadf970af5f1b Mon Sep 17 00:00:00 2001 From: Ed Bartosh Date: Mon, 30 Mar 2020 21:30:52 +0300 Subject: [PATCH] fpga_crihook: improve unit tests - increased test coverage to 91.4% - cleaned up the code - removed unused test data Signed-off-by: Ed Bartosh --- cmd/fpga_crihook/main.go | 30 +- cmd/fpga_crihook/main_test.go | 272 ++++++++++++++---- .../testdata/config-correct-DFL.json | 136 --------- .../testdata/config-missing-env.json | 138 --------- .../testdata/gbs-info-broken-json.json | 1 - .../testdata/gbs-info-correct.json | 18 -- .../gbs-info-no-accelerator-clusters.json | 11 - .../gbs-info-no-accelerator-type-uuid.json | 17 -- .../testdata/gbs-info-no-afu-image.json | 4 - .../testdata/gbs-info-no-interface-uuid.json | 17 -- .../f7df405cbd7acf7222f144b0b93acd18.gbs | Bin 0 -> 357 bytes .../stdin-bundle-dir-doesnt-exist.json | 16 -- .../testdata/stdin-no-intel-annotation.json | 16 -- 13 files changed, 226 insertions(+), 450 deletions(-) delete mode 100644 cmd/fpga_crihook/testdata/config-correct-DFL.json delete mode 100644 cmd/fpga_crihook/testdata/config-missing-env.json delete mode 100644 cmd/fpga_crihook/testdata/gbs-info-broken-json.json delete mode 100644 cmd/fpga_crihook/testdata/gbs-info-correct.json delete mode 100644 cmd/fpga_crihook/testdata/gbs-info-no-accelerator-clusters.json delete mode 100644 cmd/fpga_crihook/testdata/gbs-info-no-accelerator-type-uuid.json delete mode 100644 cmd/fpga_crihook/testdata/gbs-info-no-afu-image.json delete mode 100644 cmd/fpga_crihook/testdata/gbs-info-no-interface-uuid.json create mode 100644 cmd/fpga_crihook/testdata/intel.com/fpga/ce48969398f05f33946d560708be108a/f7df405cbd7acf7222f144b0b93acd18.gbs delete mode 100644 cmd/fpga_crihook/testdata/stdin-bundle-dir-doesnt-exist.json delete mode 100644 cmd/fpga_crihook/testdata/stdin-no-intel-annotation.json diff --git a/cmd/fpga_crihook/main.go b/cmd/fpga_crihook/main.go index 1c9c6018..64117186 100644 --- a/cmd/fpga_crihook/main.go +++ b/cmd/fpga_crihook/main.go @@ -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) diff --git a/cmd/fpga_crihook/main_test.go b/cmd/fpga_crihook/main_test.go index 53231ee8..245f861f 100644 --- a/cmd/fpga_crihook/main_test.go +++ b/cmd/fpga_crihook/main_test.go @@ -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) + } + }) + } +} diff --git a/cmd/fpga_crihook/testdata/config-correct-DFL.json b/cmd/fpga_crihook/testdata/config-correct-DFL.json deleted file mode 100644 index 80e90dc2..00000000 --- a/cmd/fpga_crihook/testdata/config-correct-DFL.json +++ /dev/null @@ -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" - } -} diff --git a/cmd/fpga_crihook/testdata/config-missing-env.json b/cmd/fpga_crihook/testdata/config-missing-env.json deleted file mode 100644 index 42ab1feb..00000000 --- a/cmd/fpga_crihook/testdata/config-missing-env.json +++ /dev/null @@ -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" - } -} diff --git a/cmd/fpga_crihook/testdata/gbs-info-broken-json.json b/cmd/fpga_crihook/testdata/gbs-info-broken-json.json deleted file mode 100644 index b957c763..00000000 --- a/cmd/fpga_crihook/testdata/gbs-info-broken-json.json +++ /dev/null @@ -1 +0,0 @@ -#()YE@#YDEP#H21w diff --git a/cmd/fpga_crihook/testdata/gbs-info-correct.json b/cmd/fpga_crihook/testdata/gbs-info-correct.json deleted file mode 100644 index 3cb9ae8b..00000000 --- a/cmd/fpga_crihook/testdata/gbs-info-correct.json +++ /dev/null @@ -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" -} diff --git a/cmd/fpga_crihook/testdata/gbs-info-no-accelerator-clusters.json b/cmd/fpga_crihook/testdata/gbs-info-no-accelerator-clusters.json deleted file mode 100644 index 534756dd..00000000 --- a/cmd/fpga_crihook/testdata/gbs-info-no-accelerator-clusters.json +++ /dev/null @@ -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" -} diff --git a/cmd/fpga_crihook/testdata/gbs-info-no-accelerator-type-uuid.json b/cmd/fpga_crihook/testdata/gbs-info-no-accelerator-type-uuid.json deleted file mode 100644 index 90225540..00000000 --- a/cmd/fpga_crihook/testdata/gbs-info-no-accelerator-type-uuid.json +++ /dev/null @@ -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" -} diff --git a/cmd/fpga_crihook/testdata/gbs-info-no-afu-image.json b/cmd/fpga_crihook/testdata/gbs-info-no-afu-image.json deleted file mode 100644 index dab6e9e0..00000000 --- a/cmd/fpga_crihook/testdata/gbs-info-no-afu-image.json +++ /dev/null @@ -1,4 +0,0 @@ -{ - "version": 1, - "platform-name": "DCP" -} diff --git a/cmd/fpga_crihook/testdata/gbs-info-no-interface-uuid.json b/cmd/fpga_crihook/testdata/gbs-info-no-interface-uuid.json deleted file mode 100644 index 724907f7..00000000 --- a/cmd/fpga_crihook/testdata/gbs-info-no-interface-uuid.json +++ /dev/null @@ -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" -} diff --git a/cmd/fpga_crihook/testdata/intel.com/fpga/ce48969398f05f33946d560708be108a/f7df405cbd7acf7222f144b0b93acd18.gbs b/cmd/fpga_crihook/testdata/intel.com/fpga/ce48969398f05f33946d560708be108a/f7df405cbd7acf7222f144b0b93acd18.gbs new file mode 100644 index 0000000000000000000000000000000000000000..716ab8c5fa061fb74483b5a6c7aea4e78f1047de GIT binary patch literal 357 zcmZ9H&rXCe5XRT5PqFFQNeUDw-ux5yO5(-D7*mFJmsnaXW!DYixqLl`7^Cqv-+VK_ zZ{|sR_fYR{K6kf|N6wS_VzZgqQHQbfj$Ln)t1VMzg05G4O?qZ%J-&en`hC(4&v5AW z2QsoGrP2SU^`{k*7vv58qys5Vb?2fEMxlmj>RM_t)IwH8l|dy9humaTiK2zP;3b!h zPPkNzHtCKI!Fk#dQWiY_4pxZT>Y$KunCIKND-c*^wHj!+3S%@)M6^#!){P6GZYPMW{ E0jZm7mH+?% literal 0 HcmV?d00001 diff --git a/cmd/fpga_crihook/testdata/stdin-bundle-dir-doesnt-exist.json b/cmd/fpga_crihook/testdata/stdin-bundle-dir-doesnt-exist.json deleted file mode 100644 index 03deb94b..00000000 --- a/cmd/fpga_crihook/testdata/stdin-bundle-dir-doesnt-exist.json +++ /dev/null @@ -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": "" -} diff --git a/cmd/fpga_crihook/testdata/stdin-no-intel-annotation.json b/cmd/fpga_crihook/testdata/stdin-no-intel-annotation.json deleted file mode 100644 index 8d91c6f0..00000000 --- a/cmd/fpga_crihook/testdata/stdin-no-intel-annotation.json +++ /dev/null @@ -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": "" -}