-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathstrategy.yaml
177 lines (169 loc) · 6.92 KB
/
strategy.yaml
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
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
config:
log-level: debug
user-id: "github|81417"
download-path: "/tmp/cme"
imandra-service:
command: ["docker", "run", "--interactive", "--rm", "--volume", "/tmp/cme:/tmp/cme", "eu.gcr.io/imandra-core-env/imandra_bin:latest"]
models:
my-CME-exchange:
package:
# Local packages are specified relative to this config file.
path: "."
# Override the `main` field in the model's package.json
main: "src-model/CME_Testgen_Template.ml"
# Additional interfaces to those defined in package.json
interfaces:
testgen_1:
# The 'decompose-combinatoric' step requires the model to have a
# 'testgen' interface.
type: testgen
# init_state : t
init_state: init_ex_state
# run : t * action list -> t
run: run
# valid : t * action list -> bool
valid: valid
my-network:
package:
path: "."
main: "src-model/CME_Network_Template.ml"
interfaces:
testgen_1:
type: testgen
init_state: empty_network_state
run: run
valid: valid
my-simulator:
package:
path: "."
main: "src-model/CME_Simulate_Template.ml"
pipelines:
generate_binary_test_data:
description: |
Starting with a model of the CME Exchange, we
- generate messages to populate the books with orders;
- generate a sequence of change/delete order messages;
- perturb the generated packet sequence by running the packets through a
Network Effects model; and
- run the perturbed packet sequences through the CME simulator model.
steps:
- decompose-combinatoric:
description: |
Populate the exchange with orders.
tcs-per-region: 3
model: my-CME-exchange
# `printer` must be a function defined in the model.
printer: exchange_state_to_ocaml
# `sequence` defines a list of messages to generate and send to the
# model's `run` function.
sequence:
# `expand_sequence` will be expanded into a list of messages.
# One message will be generated for every combination of values
# defined in `expand_fields`.
# `free_fields` are left as symbolic variables for Imandra to
# explore using region decomposition.
- expand_sequence:
constructors: [BookAction, ST_Add]
payload:
type: ord_add_data
free_fields:
oa_price: int
expand_fields:
oa_order_qty: [1]
oa_sec_type: [SecA, SecB]
oa_book_type: [Book_Type_Implied, Book_Type_Multi]
oa_level_num: [1, 2, 3, 4, 5]
oa_level_side: [OrdBuy, OrdSell]
oa_num_orders: [Some 1]
# The message sequence in `after_each` will be generated after
# every message expanded from this `expand_sequence`.
# In this case we randomly choose whether or not to generate an
# incremental update message after each order add message.
# (The update message causes the exchange model to generate an
# outgoing network packet).
after_each:
# An `alternative` sequence will randomly pick one sequence
# from the list of alternatives for this test generation run.
alternative:
- constructors: ["ExchangeAction", "ST_DataSendInc"]
- sequence: []
- decompose-combinatoric:
description: |
Generate some order change/delete messages.
tcs-per-region: 3
model: my-CME-exchange
# At the end of this step, we use the outgoing packets of the exchange
# state to initialize the network model state for the next step.
printer: network_state_ocaml_of_exchange_state
sequence:
# A `reference` sequence refers to a sequence defined in the
# `let_sequences` block below.
- reference: send_snapshots
- reference: change_order
- reference: change_order
- reference: delete_order
- reference: change_order
- reference: change_order
- reference: send_snapshots
let_sequences:
send_snapshots:
sequence:
- constructors: ["ExchangeAction", "ST_Snapshot", "SecA"]
- constructors: ["ExchangeAction", "ST_DataSendSnap"]
- constructors: ["ExchangeAction", "ST_Snapshot", "SecB"]
- constructors: ["ExchangeAction", "ST_DataSendSnap"]
change_order:
# `expand_alternative` is similar to `expand_sequence`, but
# instead of generating a list of messages, a single message is
# picked at random from the possible choices of values defined in
# `expand_fields`.
expand_alternative:
constructors: [ "BookAction" , "ST_Change" ]
payload:
type: ord_change_data
free_fields:
oc_new_qty: "int"
expand_fields:
oc_sec_type: [ "SecA", "SecB" ]
oc_book_type: [ "Book_Type_Implied", "Book_Type_Multi" ]
oc_level_num: [ 1, 2, 3, 4, 5 ]
oc_level_side: [ "OrdBuy", "OrdSell" ]
after_each:
alternative:
- constructors: ["ExchangeAction", "ST_DataSendInc"]
- sequence: []
delete_order:
expand_alternative:
constructors: [ "BookAction" , "ST_Delete" ]
payload:
type: ord_del_data
free_fields:
od_level_num: "int"
expand_fields:
od_sec_type: [ "SecA", "SecB" ]
od_book_type: [ "Book_Type_Implied", "Book_Type_Multi" ]
od_level_side: [ "OrdBuy", "OrdSell" ]
after_each:
alternative:
- constructors: ["ExchangeAction", "ST_DataSendInc"]
- sequence: []
- decompose-combinatoric:
description: |
Take the packets generated by the exchange and apply some
perturbations.
tcs-per-region: 3
model: my-network
printer: testcase_json_string_of_network_state
sequence:
- repeat:
count: 3
constructors: [ "NoEffect" ]
- repeat:
count: 2
# Here we let Imandra fully explore all variants of the message
# type symbolically.
payload:
type: net_effect
- repeat:
count: 3
constructors: [ "NoEffect" ]