knobs_linux_test.go 823 B

12345678910111213141516171819202122232425262728293031323334
  1. package kernel
  2. import (
  3. "testing"
  4. "github.com/sirupsen/logrus"
  5. "gotest.tools/assert"
  6. is "gotest.tools/assert/cmp"
  7. _ "github.com/docker/libnetwork/testutils"
  8. )
  9. func TestReadWriteKnobs(t *testing.T) {
  10. for _, k := range []string{
  11. "net.ipv4.neigh.default.gc_thresh1",
  12. "net.ipv4.neigh.default.gc_thresh2",
  13. "net.ipv4.neigh.default.gc_thresh3",
  14. } {
  15. // Check if the test is able to read the value
  16. v, err := readSystemProperty(k)
  17. if err != nil {
  18. logrus.WithError(err).Warnf("Path %v not readable", k)
  19. // the path is not there, skip this key
  20. continue
  21. }
  22. // Test the write
  23. assert.Check(t, writeSystemProperty(k, "10000"))
  24. newV, err := readSystemProperty(k)
  25. assert.NilError(t, err)
  26. assert.Check(t, is.Equal(newV, "10000"))
  27. // Restore value
  28. assert.Check(t, writeSystemProperty(k, v))
  29. }
  30. }