flok 0.0.57 → 0.0.60
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/app/kern/services/vm.rb +4 -6
- data/docs/controllers.md +20 -3
- data/docs/services/vm.md +9 -1
- data/lib/flok/user_compiler.rb +3 -1
- data/lib/flok/user_compiler_templates/ctable.js.erb +1 -0
- data/lib/flok/version.rb +1 -1
- data/spec/env/kern.rb +1 -1
- data/spec/kern/assets/current_action_nav.rb +31 -0
- data/spec/kern/assets/vm/controller19c.rb +1 -1
- data/spec/kern/assets/vm/controller19d.rb +35 -0
- data/spec/kern/assets/vm/controller19e.rb +51 -0
- data/spec/kern/assets/vm/controller19f.rb +75 -0
- data/spec/kern/assets/vm/controller19g.rb +75 -0
- data/spec/kern/controller_spec.rb +23 -0
- data/spec/kern/vm_service_spec.rb +192 -4
- metadata +12 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 4bd11ac051bc4621d21cdad6ad4ed89aa3a75ec8
|
4
|
+
data.tar.gz: 46df13c26bd3569e367ed09075271d5151ba88ea
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: cc1553107062ccc60ab610da94d63d0550fd2d96ed8fc9665bc1b3a9e122ad59deb08c9b65fdc1cc31a484be77e1753afe9a28733bdc9b73bf38f16f1b765d5e
|
7
|
+
data.tar.gz: b0902d76d7626b552d4909f572375810cc3eee34d6dee014908d3812c62850c665737a222644b8b6562f49ba811bd01d7b902711379b65addf08ac630517ed87
|
data/app/kern/services/vm.rb
CHANGED
@@ -15,7 +15,7 @@ service :vm do
|
|
15
15
|
|
16
16
|
vm_bp_to_nmap = {};
|
17
17
|
|
18
|
-
|
18
|
+
vm_read_sync_in_progress = [];
|
19
19
|
|
20
20
|
//Notification listeners, converts ns+key to an array of base pointers
|
21
21
|
vm_notify_map = {
|
@@ -84,10 +84,8 @@ service :vm do
|
|
84
84
|
//res is page
|
85
85
|
function int_per_get_res(s, ns, res) {
|
86
86
|
//Controller made a read_sync request, fulfull it
|
87
|
-
if (
|
88
|
-
|
89
|
-
int_event(read_sync_in_progress, "read_sync_res", {page: res, ns: ns});
|
90
|
-
read_sync_in_progress = false;
|
87
|
+
if (vm_read_sync_in_progress.length > 0) {
|
88
|
+
int_event(vm_read_sync_in_progress.pop(), "read_sync_res", {page: res, ns: ns});
|
91
89
|
}
|
92
90
|
|
93
91
|
//If the key didn't exist, ignore it
|
@@ -599,11 +597,11 @@ service :vm do
|
|
599
597
|
}
|
600
598
|
<% end %>
|
601
599
|
|
602
|
-
read_sync_in_progress = bp;
|
603
600
|
var cache_entry = vm_cache[params.ns][params.id];
|
604
601
|
if (cache_entry !== undefined) {
|
605
602
|
int_event(bp, "read_sync_res", {ns: params.ns, page: cache_entry});
|
606
603
|
} else {
|
604
|
+
vm_read_sync_in_progress.unshift(bp);
|
607
605
|
SEND("main", "if_per_get", "vm", params.ns, params.id);
|
608
606
|
}
|
609
607
|
}
|
data/docs/controllers.md
CHANGED
@@ -33,12 +33,29 @@ controller "tab_controller" do
|
|
33
33
|
}
|
34
34
|
|
35
35
|
#You can also define macros for shared action traits
|
36
|
-
macro
|
37
|
-
on "shared_clicked"
|
36
|
+
macro :my_macro do
|
37
|
+
on "shared_clicked", %{
|
38
38
|
Goto("home")
|
39
|
-
|
39
|
+
}
|
40
40
|
end
|
41
41
|
|
42
|
+
#More advanced macros can use the `current_action` to check
|
43
|
+
#which action you are on
|
44
|
+
macro :my_nav_macro do
|
45
|
+
on "home_clicked", %{
|
46
|
+
if (current_action !== "home") {
|
47
|
+
Goto("home")
|
48
|
+
}
|
49
|
+
}
|
50
|
+
|
51
|
+
on "about_clicked", %{
|
52
|
+
if (current_action !== "home") {
|
53
|
+
Goto("about")
|
54
|
+
}
|
55
|
+
}
|
56
|
+
end
|
57
|
+
|
58
|
+
|
42
59
|
#Optional
|
43
60
|
#Called after on_entry, but before any action is entered. This is a pseudo
|
44
61
|
#action and assumes that everything you do inside will be performed fully
|
data/docs/services/vm.md
CHANGED
@@ -151,7 +151,9 @@ use the modification helpers. These modification helpers implement copy on write
|
|
151
151
|
* If in `@debug` mode, the variable `vm_write_list` contains an array dictionary of the last page passed to the pager (tail is latest).
|
152
152
|
|
153
153
|
###`read_sync`
|
154
|
-
Read from the disk synchronously, or memory if it exists, and return the value in `read_sync_res`. This will not watch the page.
|
154
|
+
Read from the disk synchronously, or memory if it exists, and return the value in `read_sync_res`. This will not watch the page. Multiple read_syncs
|
155
|
+
in the same frame are allowed but discouraged as the order that pages are received back may not necessarily be the order they were synhronously
|
156
|
+
requested. This is because a cached page will be returned by the call stack while a synchronous read has to go through the event queue.
|
155
157
|
* Parameters
|
156
158
|
* `ns` - Namespace of the page
|
157
159
|
* `id` - id of the page
|
@@ -174,6 +176,12 @@ Pageout is embodied in the function named `vm_pageout()`. This will asynchronous
|
|
174
176
|
* `vm_notify_map` - The dictionary used to lookup what controllers need to be notified about changes. Stored in `vm_notify_map[ns][id]` which yields an array of controller base pointers.
|
175
177
|
* `vm_bp_to_nmap` - A dictionary that maps a `bp` key (usually from a controller) to a dictionary. This dictionary contains a mapping of `bp => ns => id` to an array that contains `[node, index]` where `node` is a reference to `vm_notify_map[ns][id]`. This inverted map must (a) provide a way for `unwatch` to quickly remove entries from itself and (b) provide a way for all entries in `vm_notify_map` to be removed when something (usually a controller) disconrnects.
|
176
178
|
must support `unwatch` removal which we only receive the `bp`, `ns`, and `key`.
|
179
|
+
* `vm_read_sync_in_progress` - A queue of controller base pointers that are awaiting a response from `read_sync`. This may contain multiple
|
180
|
+
controllers if one controller makes multiple `read_sync` requests within one *frame* as `int_event` only queues the outbounds events
|
181
|
+
and dosen't immediately send them. Not that this makes it not synchronous, just the order of execution is not like a call stack and more
|
182
|
+
like a synchronous high priority deferred queue. The *frontmost* of the array is the lowest index, and the *backmost* is the highest index. In
|
183
|
+
javascript, this means that new requests are placed via `vm_read_sync_in_progress.unshift(new_bp)` and when requests are serviced, they are
|
184
|
+
serviced via the `var bp = vm_read_sync_in_progress.pop()`.
|
177
185
|
|
178
186
|
##Helper Methods
|
179
187
|
|
data/lib/flok/user_compiler.rb
CHANGED
@@ -462,7 +462,9 @@ module Flok
|
|
462
462
|
def method_missing method, *args, &block
|
463
463
|
if macro = @controller.macros[method]
|
464
464
|
#Call the macro in our context
|
465
|
-
|
465
|
+
@current_action = name
|
466
|
+
self.instance_eval(¯o)
|
467
|
+
@current_action = nil
|
466
468
|
else
|
467
469
|
raise "No macro found named: #{method}"
|
468
470
|
end
|
data/lib/flok/version.rb
CHANGED
data/spec/env/kern.rb
CHANGED
@@ -137,7 +137,7 @@ shared_context "kern" do
|
|
137
137
|
end
|
138
138
|
end
|
139
139
|
|
140
|
-
expect(name).to eq(msg_name)
|
140
|
+
expect(name).to eq(msg_name), "name: #{name.inspect} of message received did not match #{msg_name.inspect}, args where #{args.inspect}"
|
141
141
|
expect(args).to eq(msg_args)
|
142
142
|
expect(priority).to eq(@cp)
|
143
143
|
|
@@ -0,0 +1,31 @@
|
|
1
|
+
controller :my_controller do
|
2
|
+
macro :nav do
|
3
|
+
#This one should only go to home if we are
|
4
|
+
#not on home already
|
5
|
+
on "home_clicked", %{
|
6
|
+
if (current_action !== "home") {
|
7
|
+
Goto("home");
|
8
|
+
}
|
9
|
+
}
|
10
|
+
|
11
|
+
#This one should always go home, even if we are
|
12
|
+
#on home already
|
13
|
+
on "home_reload_clicked", %{
|
14
|
+
Goto("home");
|
15
|
+
}
|
16
|
+
|
17
|
+
on "about_clicked", %{
|
18
|
+
if (current_action !== "about") {
|
19
|
+
Goto("about");
|
20
|
+
}
|
21
|
+
}
|
22
|
+
end
|
23
|
+
|
24
|
+
action :home do
|
25
|
+
nav
|
26
|
+
end
|
27
|
+
|
28
|
+
action :about do
|
29
|
+
nav
|
30
|
+
end
|
31
|
+
end
|
@@ -0,0 +1,35 @@
|
|
1
|
+
controller :my_controller do
|
2
|
+
services :vm
|
3
|
+
|
4
|
+
on_entry %{
|
5
|
+
}
|
6
|
+
|
7
|
+
action :my_action do
|
8
|
+
on_entry %{
|
9
|
+
var info = {
|
10
|
+
ns: "spec",
|
11
|
+
id: "test"
|
12
|
+
}
|
13
|
+
|
14
|
+
Request("vm", "read_sync", info);
|
15
|
+
}
|
16
|
+
|
17
|
+
on "read_sync_res", %{
|
18
|
+
Goto("other");
|
19
|
+
}
|
20
|
+
end
|
21
|
+
|
22
|
+
action :other do
|
23
|
+
on_entry %{
|
24
|
+
}
|
25
|
+
|
26
|
+
on "get_test", %{
|
27
|
+
//Second request should not trigger disk read as by this point, the cache would have been written
|
28
|
+
var infox = {
|
29
|
+
ns: "spec",
|
30
|
+
id: "test"
|
31
|
+
}
|
32
|
+
Request("vm", "read_sync", infox);
|
33
|
+
}
|
34
|
+
end
|
35
|
+
end
|
@@ -0,0 +1,51 @@
|
|
1
|
+
#Multiple controllers making a sync_read request of two different pages
|
2
|
+
#Not that the same page wouldn't trigger two sync reads, (because it will),
|
3
|
+
#but because we want to avoid any issues in the future.
|
4
|
+
controller :my_controller do
|
5
|
+
services :vm
|
6
|
+
spots "content"
|
7
|
+
|
8
|
+
on_entry %{
|
9
|
+
}
|
10
|
+
|
11
|
+
action :my_action do
|
12
|
+
on_entry %{
|
13
|
+
var info = {
|
14
|
+
ns: "spec",
|
15
|
+
id: "test1"
|
16
|
+
}
|
17
|
+
|
18
|
+
//request page with id:test1
|
19
|
+
Request("vm", "read_sync", info);
|
20
|
+
|
21
|
+
Embed("my_other_controller", "content", {});
|
22
|
+
}
|
23
|
+
|
24
|
+
on "read_sync_res", %{
|
25
|
+
my_controller_read_sync_res = params;
|
26
|
+
}
|
27
|
+
end
|
28
|
+
end
|
29
|
+
|
30
|
+
controller :my_other_controller do
|
31
|
+
services :vm
|
32
|
+
|
33
|
+
on_entry %{
|
34
|
+
}
|
35
|
+
|
36
|
+
action :my_action do
|
37
|
+
on_entry %{
|
38
|
+
var info = {
|
39
|
+
ns: "spec",
|
40
|
+
id: "test2"
|
41
|
+
}
|
42
|
+
|
43
|
+
//request page with id:test2
|
44
|
+
Request("vm", "read_sync", info);
|
45
|
+
}
|
46
|
+
|
47
|
+
on "read_sync_res", %{
|
48
|
+
my_other_controller_read_sync_res = params;
|
49
|
+
}
|
50
|
+
end
|
51
|
+
end
|
@@ -0,0 +1,75 @@
|
|
1
|
+
controller :controller0 do
|
2
|
+
services :vm
|
3
|
+
spots "first", "second"
|
4
|
+
|
5
|
+
action :index do
|
6
|
+
on_entry %{
|
7
|
+
//request page 'A' on frame0 of controller0
|
8
|
+
var info = {
|
9
|
+
ns: "spec",
|
10
|
+
id: "A"
|
11
|
+
}
|
12
|
+
//get page A
|
13
|
+
Request("vm", "read_sync", info);
|
14
|
+
|
15
|
+
//embed controller1 & controler2
|
16
|
+
Embed("controller1", "first", {});
|
17
|
+
Embed("controller2", "second", {});
|
18
|
+
}
|
19
|
+
|
20
|
+
on "read_sync_res", %{
|
21
|
+
controller0_read_sync_res = params;
|
22
|
+
}
|
23
|
+
end
|
24
|
+
end
|
25
|
+
|
26
|
+
controller :controller1 do
|
27
|
+
services :vm
|
28
|
+
|
29
|
+
action :index do
|
30
|
+
on_entry %{
|
31
|
+
controller1_base = __base__;
|
32
|
+
}
|
33
|
+
|
34
|
+
#action is dispatched on frame1
|
35
|
+
on "get", %{
|
36
|
+
//request page 'A' on frame1 of controller1
|
37
|
+
var info = {
|
38
|
+
ns: "spec",
|
39
|
+
id: "A"
|
40
|
+
}
|
41
|
+
//get page A (again, read from cache)
|
42
|
+
Request("vm", "read_sync", info);
|
43
|
+
}
|
44
|
+
|
45
|
+
on "read_sync_res", %{
|
46
|
+
controller1_read_sync_res = params;
|
47
|
+
}
|
48
|
+
end
|
49
|
+
end
|
50
|
+
|
51
|
+
controller :controller2 do
|
52
|
+
services :vm
|
53
|
+
|
54
|
+
action :index do
|
55
|
+
on_entry %{
|
56
|
+
controller2_base = __base__;
|
57
|
+
}
|
58
|
+
|
59
|
+
#action is dispatched on frame1
|
60
|
+
on "get", %{
|
61
|
+
//request page 'B' on frame1 of controller2
|
62
|
+
var info = {
|
63
|
+
ns: "spec",
|
64
|
+
id: "B"
|
65
|
+
}
|
66
|
+
|
67
|
+
//get page B
|
68
|
+
Request("vm", "read_sync", info);
|
69
|
+
}
|
70
|
+
|
71
|
+
on "read_sync_res", %{
|
72
|
+
controller2_read_sync_res = params;
|
73
|
+
}
|
74
|
+
end
|
75
|
+
end
|
@@ -0,0 +1,75 @@
|
|
1
|
+
controller :controller0 do
|
2
|
+
services :vm
|
3
|
+
spots "first", "second"
|
4
|
+
|
5
|
+
action :index do
|
6
|
+
on_entry %{
|
7
|
+
//request page 'B' on frame0 of controller0
|
8
|
+
var info = {
|
9
|
+
ns: "spec",
|
10
|
+
id: "B"
|
11
|
+
}
|
12
|
+
//get page B
|
13
|
+
Request("vm", "read_sync", info);
|
14
|
+
|
15
|
+
//embed controller1 & controler2
|
16
|
+
Embed("controller1", "first", {});
|
17
|
+
Embed("controller2", "second", {});
|
18
|
+
}
|
19
|
+
|
20
|
+
on "read_sync_res", %{
|
21
|
+
controller0_read_sync_res = params;
|
22
|
+
}
|
23
|
+
end
|
24
|
+
end
|
25
|
+
|
26
|
+
controller :controller1 do
|
27
|
+
services :vm
|
28
|
+
|
29
|
+
action :index do
|
30
|
+
on_entry %{
|
31
|
+
controller1_base = __base__;
|
32
|
+
}
|
33
|
+
|
34
|
+
#action is dispatched on frame1
|
35
|
+
on "get", %{
|
36
|
+
//request page 'A' on frame1 of controller1
|
37
|
+
var info = {
|
38
|
+
ns: "spec",
|
39
|
+
id: "A"
|
40
|
+
}
|
41
|
+
//get page A (again, read from cache)
|
42
|
+
Request("vm", "read_sync", info);
|
43
|
+
}
|
44
|
+
|
45
|
+
on "read_sync_res", %{
|
46
|
+
controller1_read_sync_res = params;
|
47
|
+
}
|
48
|
+
end
|
49
|
+
end
|
50
|
+
|
51
|
+
controller :controller2 do
|
52
|
+
services :vm
|
53
|
+
|
54
|
+
action :index do
|
55
|
+
on_entry %{
|
56
|
+
controller2_base = __base__;
|
57
|
+
}
|
58
|
+
|
59
|
+
#action is dispatched on frame1
|
60
|
+
on "get", %{
|
61
|
+
//request page 'B' on frame1 of controller2
|
62
|
+
var info = {
|
63
|
+
ns: "spec",
|
64
|
+
id: "B"
|
65
|
+
}
|
66
|
+
|
67
|
+
//get page B
|
68
|
+
Request("vm", "read_sync", info);
|
69
|
+
}
|
70
|
+
|
71
|
+
on "read_sync_res", %{
|
72
|
+
controller2_read_sync_res = params;
|
73
|
+
}
|
74
|
+
end
|
75
|
+
end
|
@@ -868,4 +868,27 @@ RSpec.describe "kern:controller_spec" do
|
|
868
868
|
}
|
869
869
|
}.to raise_error(/choose_action.*Goto/)
|
870
870
|
end
|
871
|
+
|
872
|
+
it "Does support using a macro that contains current_action" do
|
873
|
+
ctx = flok_new_user File.read('./spec/kern/assets/current_action_nav.rb')
|
874
|
+
dump = ctx.evald %{
|
875
|
+
base = _embed("my_controller", 0, {}, null);
|
876
|
+
|
877
|
+
int_dispatch([3, "int_event", base, "about_clicked", {}]);
|
878
|
+
int_dispatch([3, "int_event", base, "home_clicked", {}]);
|
879
|
+
int_dispatch([3, "int_event", base, "home_clicked", {}]);
|
880
|
+
int_dispatch([3, "int_event", base, "home_reload_clicked", {}]);
|
881
|
+
int_dispatch([3, "int_event", base, "about_clicked", {}]);
|
882
|
+
int_dispatch([3, "int_event", base, "home_reload_clicked", {}]);
|
883
|
+
}
|
884
|
+
|
885
|
+
#Expect not to get an event from the choose_action
|
886
|
+
@driver.ignore_up_to "if_event"
|
887
|
+
@driver.mexpect("if_event", [Integer, "action", {"from" => nil, "to" => "home"}])
|
888
|
+
@driver.mexpect("if_event", [Integer, "action", {"from" => "home", "to" => "about"}])
|
889
|
+
@driver.mexpect("if_event", [Integer, "action", {"from" => "about", "to" => "home"}])
|
890
|
+
@driver.mexpect("if_event", [Integer, "action", {"from" => "home", "to" => "home"}])
|
891
|
+
@driver.mexpect("if_event", [Integer, "action", {"from" => "home", "to" => "about"}])
|
892
|
+
@driver.mexpect("if_event", [Integer, "action", {"from" => "about", "to" => "home"}])
|
893
|
+
end
|
871
894
|
end
|
@@ -655,7 +655,7 @@ RSpec.describe "kern:vm_service" do
|
|
655
655
|
@driver.mexpect("if_per_get", ["vm", "spec", "test"], 2)
|
656
656
|
end
|
657
657
|
|
658
|
-
it "Does send a read request from disk cache when synchronously reading a key for the first time" do
|
658
|
+
it "Does send a read request from disk cache when synchronously reading a key for the first time via read_sync" do
|
659
659
|
ctx = flok_new_user File.read('./spec/kern/assets/vm/controller19c.rb'), File.read("./spec/kern/assets/vm/config4.rb")
|
660
660
|
|
661
661
|
ctx.eval %{
|
@@ -678,17 +678,205 @@ RSpec.describe "kern:vm_service" do
|
|
678
678
|
"entries" => [],
|
679
679
|
}]
|
680
680
|
|
681
|
-
@driver.ignore_up_to "if_per_get", 0
|
682
681
|
@driver.mexpect("if_per_get", ["vm", "spec", "test2"], 0)
|
683
682
|
|
683
|
+
@driver.int "int_per_get_res", ["vm", "spec", {
|
684
|
+
"_id" => "default",
|
685
|
+
"_hash" => nil,
|
686
|
+
"_next" => nil,
|
687
|
+
"entries" => [],
|
688
|
+
}]
|
689
|
+
|
684
690
|
dump = ctx.evald %{
|
685
|
-
dump.
|
691
|
+
dump.vm_read_sync_in_progress = vm_read_sync_in_progress;
|
686
692
|
dump.read_sync_res_params = read_sync_res_params;
|
687
693
|
}
|
688
694
|
|
689
|
-
expect(dump["
|
695
|
+
expect(dump["vm_read_sync_in_progress"]).to eq([])
|
696
|
+
expect(dump["read_sync_res_params"].length).to eq(2)
|
690
697
|
expect(dump["read_sync_res_params"][0]["ns"]).to eq("spec")
|
691
698
|
expect(dump["read_sync_res_params"][0]["page"]["_id"]).to eq("default")
|
699
|
+
expect(dump["read_sync_res_params"][1]["ns"]).to eq("spec")
|
700
|
+
expect(dump["read_sync_res_params"][1]["page"]["_id"]).to eq("default")
|
701
|
+
end
|
702
|
+
|
703
|
+
it "Calling read_sync on an entry that already exists in cache will not trigger a disk read" do
|
704
|
+
ctx = flok_new_user File.read('./spec/kern/assets/vm/controller19d.rb'), File.read("./spec/kern/assets/vm/config4.rb")
|
705
|
+
|
706
|
+
ctx.eval %{
|
707
|
+
base = _embed("my_controller", 1, {}, null);
|
708
|
+
|
709
|
+
//Call pageout *now*
|
710
|
+
vm_pageout();
|
711
|
+
|
712
|
+
//Drain queue
|
713
|
+
int_dispatch([]);
|
714
|
+
}
|
715
|
+
|
716
|
+
#Expect to have gotten one disk read request
|
717
|
+
@driver.ignore_up_to "if_per_get", 0
|
718
|
+
@driver.mexpect("if_per_get", ["vm", "spec", "test"], 0)
|
719
|
+
|
720
|
+
#Send the disk read response back controller19d:14
|
721
|
+
@driver.int "int_per_get_res", ["vm", "spec", {
|
722
|
+
"_id" => "test",
|
723
|
+
"_hash" => nil,
|
724
|
+
"_next" => nil,
|
725
|
+
"entries" => [],
|
726
|
+
}]
|
727
|
+
|
728
|
+
#Send the 'get_test' event which should trigger a disk read
|
729
|
+
ctx.eval %{
|
730
|
+
int_dispatch([3, "int_event", base, "get_test", {}])
|
731
|
+
}
|
732
|
+
|
733
|
+
#We should not get second if_per_get request because the data was already cached
|
734
|
+
#by the first request
|
735
|
+
expect {
|
736
|
+
@driver.ignore_up_to "if_per_get", 0
|
737
|
+
}.to raise_exception
|
738
|
+
end
|
739
|
+
|
740
|
+
it "Calling read_sync on two consecutive controllers within the same frame (i.e no change for int_dispatch to be invoked to drain queue), will result in both controllers getting correct copy of data and not out of order sync_reads as they have to be pulled from the vm_read_sync_in_progress queue to discover the read_sync request base pointer" do
|
741
|
+
ctx = flok_new_user File.read('./spec/kern/assets/vm/controller19e.rb'), File.read("./spec/kern/assets/vm/config4.rb")
|
742
|
+
|
743
|
+
ctx.eval %{
|
744
|
+
base = _embed("my_controller", 1, {}, null);
|
745
|
+
|
746
|
+
//Drain queue
|
747
|
+
int_dispatch([]);
|
748
|
+
}
|
749
|
+
|
750
|
+
#Expect to have gotten two disk read request, one for test1 and one for test2
|
751
|
+
@driver.ignore_up_to "if_per_get", 0
|
752
|
+
@driver.mexpect("if_per_get", ["vm", "spec", "test1"], 0)
|
753
|
+
@driver.ignore_up_to "if_per_get", 0
|
754
|
+
@driver.mexpect("if_per_get", ["vm", "spec", "test2"], 0)
|
755
|
+
|
756
|
+
#Send the disk read response back for the first controller (my_controller)
|
757
|
+
@driver.int "int_per_get_res", ["vm", "spec", {
|
758
|
+
"_id" => "test1",
|
759
|
+
"_hash" => nil,
|
760
|
+
"_next" => nil,
|
761
|
+
"entries" => [],
|
762
|
+
}]
|
763
|
+
|
764
|
+
#Send the disk read response back for the second controller (my_other_controller)
|
765
|
+
@driver.int "int_per_get_res", ["vm", "spec", {
|
766
|
+
"_id" => "test2",
|
767
|
+
"_hash" => nil,
|
768
|
+
"_next" => nil,
|
769
|
+
"entries" => [],
|
770
|
+
}]
|
771
|
+
|
772
|
+
#The read_sync of each controller should match up with the page it requested
|
773
|
+
dump = @ctx.evald %{
|
774
|
+
dump.my_controller_read_sync_res = my_controller_read_sync_res;
|
775
|
+
dump.my_other_controller_read_sync_res = my_other_controller_read_sync_res;
|
776
|
+
}
|
777
|
+
|
778
|
+
expect(dump["my_controller_read_sync_res"]["page"]["_id"]).to eq("test1")
|
779
|
+
expect(dump["my_other_controller_read_sync_res"]["page"]["_id"]).to eq("test2")
|
780
|
+
end
|
781
|
+
|
782
|
+
it "Calling read_sync on frame0 for page 'A' on controller0 and then on frame1 for page 'A' on controller1 and page 'B' on controller2 will result in all controllers receiving the correct pages" do
|
783
|
+
ctx = flok_new_user File.read('./spec/kern/assets/vm/controller19f.rb'), File.read("./spec/kern/assets/vm/config4.rb")
|
784
|
+
|
785
|
+
dump = ctx.evald %{
|
786
|
+
dump.controller0_base = _embed("controller0", 1, {}, null);
|
787
|
+
dump.controller1_base = controller1_base;
|
788
|
+
dump.controller2_base = controller2_base;
|
789
|
+
|
790
|
+
//Drain queue
|
791
|
+
int_dispatch([]);
|
792
|
+
}
|
793
|
+
|
794
|
+
#Expect the first request for controller0 for pageA
|
795
|
+
@driver.ignore_up_to "if_per_get", 0
|
796
|
+
@driver.mexpect("if_per_get", ["vm", "spec", "A"], 0)
|
797
|
+
|
798
|
+
#Send the disk read response back for controller0 pageA
|
799
|
+
@driver.int "int_per_get_res", ["vm", "spec", {
|
800
|
+
"_id" => "A",
|
801
|
+
"_hash" => nil,
|
802
|
+
"_next" => nil,
|
803
|
+
"entries" => [],
|
804
|
+
}]
|
805
|
+
|
806
|
+
#Now signal to controller1 & controller2 to grab their pages
|
807
|
+
@driver.int "int_event", [dump["controller1_base"], "get", {}]
|
808
|
+
@driver.int "int_event", [dump["controller2_base"], "get", {}]
|
809
|
+
|
810
|
+
#We shouldn't receive 'A' because it will be retrieved by the cache read
|
811
|
+
@driver.ignore_up_to "if_per_get", 0
|
812
|
+
@driver.mexpect("if_per_get", ["vm", "spec", "B"], 0)
|
813
|
+
|
814
|
+
#Send the disk read response back for frame1 'B' for controller2
|
815
|
+
@driver.int "int_per_get_res", ["vm", "spec", {
|
816
|
+
"_id" => "B",
|
817
|
+
"_hash" => nil,
|
818
|
+
"_next" => nil,
|
819
|
+
"entries" => [],
|
820
|
+
}]
|
821
|
+
|
822
|
+
#The read_sync of each controller should match up with the page it requested
|
823
|
+
dump = @ctx.evald %{
|
824
|
+
dump.controller1_read_sync_res = controller1_read_sync_res;
|
825
|
+
dump.controller2_read_sync_res = controller2_read_sync_res;
|
826
|
+
}
|
827
|
+
|
828
|
+
expect(dump["controller1_read_sync_res"]["page"]["_id"]).to eq("A")
|
829
|
+
expect(dump["controller2_read_sync_res"]["page"]["_id"]).to eq("B")
|
830
|
+
end
|
831
|
+
|
832
|
+
it "Calling read_sync on frame0 for page 'B' on controller0 and then on frame1 for page 'A' on controller1 and page 'B' on controller2 will result in all controllers receiving the correct pages (reversed order from above)" do
|
833
|
+
ctx = flok_new_user File.read('./spec/kern/assets/vm/controller19g.rb'), File.read("./spec/kern/assets/vm/config4.rb")
|
834
|
+
|
835
|
+
dump = ctx.evald %{
|
836
|
+
dump.controller0_base = _embed("controller0", 1, {}, null);
|
837
|
+
dump.controller1_base = controller1_base;
|
838
|
+
dump.controller2_base = controller2_base;
|
839
|
+
|
840
|
+
//Drain queue
|
841
|
+
int_dispatch([]);
|
842
|
+
}
|
843
|
+
|
844
|
+
#Expect the first request for controller0 for pageB
|
845
|
+
@driver.ignore_up_to "if_per_get", 0
|
846
|
+
@driver.mexpect("if_per_get", ["vm", "spec", "B"], 0)
|
847
|
+
|
848
|
+
#Send the disk read response back for controller0 pageB
|
849
|
+
@driver.int "int_per_get_res", ["vm", "spec", {
|
850
|
+
"_id" => "B",
|
851
|
+
"_hash" => nil,
|
852
|
+
"_next" => nil,
|
853
|
+
"entries" => [],
|
854
|
+
}]
|
855
|
+
|
856
|
+
#Now signal to controller1 & controller2 to grab their pages
|
857
|
+
@driver.int "int_event", [dump["controller1_base"], "get", {}]
|
858
|
+
@driver.int "int_event", [dump["controller2_base"], "get", {}]
|
859
|
+
|
860
|
+
#We shouldn't receive 'B' because it will be retrieved by the cache read
|
861
|
+
@driver.ignore_up_to "if_per_get", 0
|
862
|
+
@driver.mexpect("if_per_get", ["vm", "spec", "A"], 0)
|
863
|
+
|
864
|
+
#Send the disk read response back for frame1 'A' for controller2
|
865
|
+
@driver.int "int_per_get_res", ["vm", "spec", {
|
866
|
+
"_id" => "A",
|
867
|
+
"_hash" => nil,
|
868
|
+
"_next" => nil,
|
869
|
+
"entries" => [],
|
870
|
+
}]
|
871
|
+
|
872
|
+
#The read_sync of each controller should match up with the page it requested
|
873
|
+
dump = @ctx.evald %{
|
874
|
+
dump.controller1_read_sync_res = controller1_read_sync_res;
|
875
|
+
dump.controller2_read_sync_res = controller2_read_sync_res;
|
876
|
+
}
|
877
|
+
|
878
|
+
expect(dump["controller1_read_sync_res"]["page"]["_id"]).to eq("A")
|
879
|
+
expect(dump["controller2_read_sync_res"]["page"]["_id"]).to eq("B")
|
692
880
|
end
|
693
881
|
|
694
882
|
it "Does send a sync read request from disk cache when watching a key for the first time with sync: true" do
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: flok
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.60
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- seo
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2015-07-
|
11
|
+
date: 2015-07-16 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: execjs
|
@@ -1144,6 +1144,7 @@ files:
|
|
1144
1144
|
- spec/kern/assets/controller_spots.rb
|
1145
1145
|
- spec/kern/assets/controller_spots_embed.rb
|
1146
1146
|
- spec/kern/assets/controller_spots_embed_removed.rb
|
1147
|
+
- spec/kern/assets/current_action_nav.rb
|
1147
1148
|
- spec/kern/assets/embed_info.rb
|
1148
1149
|
- spec/kern/assets/event_gw.rb
|
1149
1150
|
- spec/kern/assets/forward_and_back.rb
|
@@ -1206,6 +1207,10 @@ files:
|
|
1206
1207
|
- spec/kern/assets/vm/controller19.rb
|
1207
1208
|
- spec/kern/assets/vm/controller19b.rb
|
1208
1209
|
- spec/kern/assets/vm/controller19c.rb
|
1210
|
+
- spec/kern/assets/vm/controller19d.rb
|
1211
|
+
- spec/kern/assets/vm/controller19e.rb
|
1212
|
+
- spec/kern/assets/vm/controller19f.rb
|
1213
|
+
- spec/kern/assets/vm/controller19g.rb
|
1209
1214
|
- spec/kern/assets/vm/controller2.rb
|
1210
1215
|
- spec/kern/assets/vm/controller20.rb
|
1211
1216
|
- spec/kern/assets/vm/controller21.rb
|
@@ -2067,6 +2072,7 @@ test_files:
|
|
2067
2072
|
- spec/kern/assets/controller_spots.rb
|
2068
2073
|
- spec/kern/assets/controller_spots_embed.rb
|
2069
2074
|
- spec/kern/assets/controller_spots_embed_removed.rb
|
2075
|
+
- spec/kern/assets/current_action_nav.rb
|
2070
2076
|
- spec/kern/assets/embed_info.rb
|
2071
2077
|
- spec/kern/assets/event_gw.rb
|
2072
2078
|
- spec/kern/assets/forward_and_back.rb
|
@@ -2129,6 +2135,10 @@ test_files:
|
|
2129
2135
|
- spec/kern/assets/vm/controller19.rb
|
2130
2136
|
- spec/kern/assets/vm/controller19b.rb
|
2131
2137
|
- spec/kern/assets/vm/controller19c.rb
|
2138
|
+
- spec/kern/assets/vm/controller19d.rb
|
2139
|
+
- spec/kern/assets/vm/controller19e.rb
|
2140
|
+
- spec/kern/assets/vm/controller19f.rb
|
2141
|
+
- spec/kern/assets/vm/controller19g.rb
|
2132
2142
|
- spec/kern/assets/vm/controller2.rb
|
2133
2143
|
- spec/kern/assets/vm/controller20.rb
|
2134
2144
|
- spec/kern/assets/vm/controller21.rb
|