summaryrefslogtreecommitdiff
path: root/tests/ovsdb-schema.at
blob: 9957ebdd4d35a965338d82eb574bf8e723e6119c (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
AT_BANNER([OVSDB -- schemas])

OVSDB_CHECK_POSITIVE_CPY([schema with valid refTables],
  [[parse-schema \
      '{"name": "mydb",
        "version": "4.2.1",
        "tables": {
          "a": {
            "columns": {
              "map": {
                "type": {
                  "key": {
                    "type": "uuid",
                    "refTable": "b"},
                  "value": {
                    "type": "uuid",
                    "refTable": "a"}}}}},
          "b": {
            "columns": {
              "aRef": {
                "type": {
                  "key": {
                    "type": "uuid",
                    "refTable": "a"}}}}}}}']],
  [[{"name":"mydb","tables":{"a":{"columns":{"map":{"type":{"key":{"refTable":"b","type":"uuid"},"value":{"refTable":"a","type":"uuid"}}}}},"b":{"columns":{"aRef":{"type":{"key":{"refTable":"a","type":"uuid"}}}}}},"version":"4.2.1"}]])

dnl Ephemeral strong references to root set tables are OK.
dnl Ephemeral strong references to non-root set tables are forced to be
dnl persistent.
OVSDB_CHECK_POSITIVE_CPY([schema with ephemeral strong references],
  [[parse-schema \
      '{"name": "mydb",
        "version": "4.2.1",
        "tables": {
          "a": {
            "columns": {
              "x": {
                "type": {
                  "key": {
                    "type": "uuid",
                    "refTable": "b"}},
                "ephemeral": true},
              "y": {
                "type": {
                  "key": {
                    "type": "uuid",
                    "refTable": "a"}},
                "ephemeral": true}}},
          "b": {
            "columns": {
              "aRef": {
                "type": {
                  "key": {
                    "type": "uuid",
                    "refTable": "a"}}}},
              "isRoot": true}}}']],
  [[{"name":"mydb","tables":{"a":{"columns":{"x":{"ephemeral":true,"type":{"key":{"refTable":"b","type":"uuid"}}},"y":{"type":{"key":{"refTable":"a","type":"uuid"}}}}},"b":{"columns":{"aRef":{"type":{"key":{"refTable":"a","type":"uuid"}}}},"isRoot":true}},"version":"4.2.1"}]])

dnl Immutable weak references are forced to be mutable.
OVSDB_CHECK_POSITIVE_CPY([schema with immutable weak references],
  [[parse-schema \
      '{"name": "mydb",
	"version": "4.2.1",
	"tables": {
	  "a": {
	    "columns": {
	      "x": {
		"type": {
		  "key": {
		    "type": "uuid",
		    "refTable": "a",
		    "refType": "weak"}},
		"mutable": false}}}}}']],
  [[{"name":"mydb","tables":{"a":{"columns":{"x":{"type":{"key":{"refTable":"a","refType":"weak","type":"uuid"}}}}}},"version":"4.2.1"}]])

dnl Schemas without version numbers are accepted for backward
dnl compatibility, but this is a deprecated feature.
OVSDB_CHECK_POSITIVE_CPY([schema without version number],
  [[parse-schema \
      '{"name": "mydb",
        "tables": {
          "x": {
            "columns": {
              "y": {
                "type": "integer"}}}}}']],
  [{"name":"mydb","tables":{"x":{"columns":{"y":{"type":"integer"}}}}}])
     
OVSDB_CHECK_NEGATIVE_CPY([schema with invalid refTables],
  [[parse-schema \
      '{"name": "mydb",
        "tables": {
          "a": {
            "columns": {
              "map": {
                "type": {
                  "key": {
                    "type": "uuid",
                    "refTable": "c"},
                  "value": {
                    "type": "uuid",
                    "refTable": "a"}}}}},
          "b": {
            "columns": {
              "aRef": {
                "type": {
                  "key": {
                    "type": "uuid",
                    "refTable": "a"}}}}}}}']],
  [[syntax error: column map key refers to undefined table c]])
     
OVSDB_CHECK_NEGATIVE_CPY([schema with invalid version number],
  [[parse-schema \
      '{"name": "mydb",
        "tables": {
          "x": {
            "columns": {
              "y": {
                "type": "integer"}}}},
        "version": "xxx"}']],
  [[schema version "xxx" not in format x.y.z]])