|
| 1 | +Feature: Latency |
| 2 | + |
| 3 | + Background: |
| 4 | + Given the "signaling" backend is running |
| 5 | + And the "testproxy" backend is running |
| 6 | + |
| 7 | + |
| 8 | + Scenario: Lobby listings include the latency to the peer |
| 9 | + Given the next peer's latency vector is set to: |
| 10 | + """ |
| 11 | + 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10 |
| 12 | + """ |
| 13 | + And "green" is connected as "1u8fw4aph5ypt" and ready for game "b6f7fc97-8545-4ffd-b714-7cf339048556" |
| 14 | + And "green" creates a lobby with these settings: |
| 15 | + """json |
| 16 | + { |
| 17 | + "public": true |
| 18 | + } |
| 19 | + """ |
| 20 | + And "green" receives the network event "lobby" with the argument "h5yzwyizlwao" |
| 21 | + And the next peer's latency vector is set to: |
| 22 | + """ |
| 23 | + 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20 |
| 24 | + """ |
| 25 | + And "blue" is connected as "19yrzmetd2bn7" and ready for game "b6f7fc97-8545-4ffd-b714-7cf339048556" |
| 26 | + |
| 27 | + When "blue" requests lobbies with: |
| 28 | + """json |
| 29 | + {} |
| 30 | + """ |
| 31 | + |
| 32 | + Then "blue" should have received only these lobbies: |
| 33 | + | code | latency | |
| 34 | + | h5yzwyizlwao | 24 | |
| 35 | + |
| 36 | + |
| 37 | + Scenario: Lobby with multiple peers |
| 38 | + Given the next peer's latency vector is set to: |
| 39 | + """ |
| 40 | + 99, 99, 99, 99, 10, 10, 10, 10, 10, 10, 10 |
| 41 | + """ |
| 42 | + And "blue" is connected as "1u8fw4aph5ypt" and ready for game "4307bd86-e1df-41b8-b9df-e22afcf084bd" |
| 43 | + And the next peer's latency vector is set to: |
| 44 | + """ |
| 45 | + 10, 10, 10, 99, 99, 99, 99, 10, 10, 10, 10 |
| 46 | + """ |
| 47 | + And "yellow" is connected as "h5yzwyizlwao" and ready for game "4307bd86-e1df-41b8-b9df-e22afcf084bd" |
| 48 | + And "blue,yellow" are joined in a public lobby |
| 49 | + And the next peer's latency vector is set to: |
| 50 | + """ |
| 51 | + 10, 10, 10, 10, 10, 10, 99, 99, 99, 99, 10 |
| 52 | + """ |
| 53 | + And "green" is connected as "3t3cfgcqup9e" and ready for game "4307bd86-e1df-41b8-b9df-e22afcf084bd" |
| 54 | + |
| 55 | + When "green" requests lobbies with: |
| 56 | + """json |
| 57 | + {} |
| 58 | + """ |
| 59 | + |
| 60 | + Then "green" should have received only these lobbies: |
| 61 | + | code | latency | |
| 62 | + | 19yrzmetd2bn7 | 89 | |
| 63 | + |
| 64 | + |
| 65 | + Scenario: Sort lobbies by latency |
| 66 | + Given the next peer's latency vector is set to: |
| 67 | + """ |
| 68 | + 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30 |
| 69 | + """ |
| 70 | + And "blue" is connected as "1u8fw4aph5ypt" and ready for game "4307bd86-e1df-41b8-b9df-e22afcf084bd" |
| 71 | + And "blue" creates a lobby with these settings: |
| 72 | + """json |
| 73 | + { |
| 74 | + "public": true, |
| 75 | + "customData": { |
| 76 | + "map": "de_nuke" |
| 77 | + } |
| 78 | + } |
| 79 | + """ |
| 80 | + And the next peer's latency vector is set to: |
| 81 | + """ |
| 82 | + 99, 99, 99, 99, 99, 99, 99, 99, 99, 99, 99 |
| 83 | + """ |
| 84 | + And "yellow" is connected as "19yrzmetd2bn7" and ready for game "4307bd86-e1df-41b8-b9df-e22afcf084bd" |
| 85 | + And "yellow" creates a lobby with these settings: |
| 86 | + """json |
| 87 | + { |
| 88 | + "public": true, |
| 89 | + "customData": { |
| 90 | + "map": "de_dust" |
| 91 | + } |
| 92 | + } |
| 93 | + """ |
| 94 | + And the next peer's latency vector is set to: |
| 95 | + """ |
| 96 | + 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10 |
| 97 | + """ |
| 98 | + And "green" is connected as "prb67ouj837u" and ready for game "4307bd86-e1df-41b8-b9df-e22afcf084bd" |
| 99 | + |
| 100 | + When "green" requests lobbies with: |
| 101 | + | filter | {} | |
| 102 | + | sort | { "latency": 1 } | |
| 103 | + | limit | 1 | |
| 104 | + |
| 105 | + Then "green" should have received only these lobbies: |
| 106 | + | code | latency | customData | |
| 107 | + | h5yzwyizlwao | 34 | {"map":"de_nuke"} | |
| 108 | + |
| 109 | + |
| 110 | + Scenario: Latency to your own lobby |
| 111 | + Given the next peer's latency vector is set to: |
| 112 | + """ |
| 113 | + 325, 523, 64, 21, 76, 23, 54, 235, 76, 23, 142 |
| 114 | + """ |
| 115 | + And "green" is connected as "1u8fw4aph5ypt" and ready for game "b6f7fc97-8545-4ffd-b714-7cf339048556" |
| 116 | + And "green" creates a lobby with these settings: |
| 117 | + """json |
| 118 | + { |
| 119 | + "public": true |
| 120 | + } |
| 121 | + """ |
| 122 | + And "green" receives the network event "lobby" with the argument "h5yzwyizlwao" |
| 123 | + |
| 124 | + When "green" requests lobbies with: |
| 125 | + """json |
| 126 | + {} |
| 127 | + """ |
| 128 | + |
| 129 | + Then "green" should have received only these lobbies: |
| 130 | + | code | latency | |
| 131 | + | h5yzwyizlwao | 0 | |
| 132 | + |
| 133 | + |
| 134 | + Scenario: Peers without latency vectors are not included in the estimate |
| 135 | + Given "green" is connected as "1u8fw4aph5ypt" and ready for game "f666036d-d9e1-4d70-b0c3-4a68b24a9884" |
| 136 | + And these lobbies exist: |
| 137 | + | code | game | peers | public | |
| 138 | + | 1u8fw4aph5ypt | f666036d-d9e1-4d70-b0c3-4a68b24a9884 | {"peer1"} | true | |
| 139 | + | 0qva9vyurwbbl | f666036d-d9e1-4d70-b0c3-4a68b24a9884 | {"peer2", "peer3"} | true | |
| 140 | + And these peers exist: |
| 141 | + | peer | game | latency_vector | |
| 142 | + | peer1 | f666036d-d9e1-4d70-b0c3-4a68b24a9884 | null | |
| 143 | + | peer2 | f666036d-d9e1-4d70-b0c3-4a68b24a9884 | null | |
| 144 | + | peer3 | f666036d-d9e1-4d70-b0c3-4a68b24a9884 | {10,10,10,10,10,10,10,10,10,10,10} | |
| 145 | + |
| 146 | + When "green" requests lobbies with: |
| 147 | + | filter | {} | |
| 148 | + | sort | { "latency": 1 } | |
| 149 | + Then "green" should have received only these lobbies: |
| 150 | + | code | latency | |
| 151 | + | 0qva9vyurwbbl | 10 | |
| 152 | + | 1u8fw4aph5ypt | undefined | |
| 153 | + |
| 154 | + |
| 155 | + Scenario: Client without latency vectors gives null latency estimates |
| 156 | + Given the next peer's latency vector is set to: |
| 157 | + """ |
| 158 | + null |
| 159 | + """ |
| 160 | + Given "green" is connected as "1u8fw4aph5ypt" and ready for game "f666036d-d9e1-4d70-b0c3-4a68b24a9884" |
| 161 | + And these lobbies exist: |
| 162 | + | code | game | peers | public | |
| 163 | + | 0qva9vyurwbbl | f666036d-d9e1-4d70-b0c3-4a68b24a9884 | {"peer1", "peer2"} | true | |
| 164 | + And these peers exist: |
| 165 | + | peer | game | latency_vector | |
| 166 | + | peer1 | f666036d-d9e1-4d70-b0c3-4a68b24a9884 | {10,10,10,10,10,10,10,10,10,10,10} | |
| 167 | + |
| 168 | + When "green" requests lobbies with: |
| 169 | + """json |
| 170 | + {} |
| 171 | + """ |
| 172 | + Then "green" should have received only these lobbies: |
| 173 | + | code | latency | |
| 174 | + | 0qva9vyurwbbl | undefined | |
0 commit comments