|
662 | 662 | end |
663 | 663 | end |
664 | 664 |
|
| 665 | + context "prioritization" do |
| 666 | + it "should order based on dependency" do |
| 667 | + # 5.3.1 |
| 668 | + # if streams B and C are dependent on stream A, and if stream |
| 669 | + # D is created with a dependency on stream A, this results in a |
| 670 | + # dependency order of A followed by B, C, and D in any order. |
| 671 | + a_stream = client.new_stream |
| 672 | + b_stream = client.new_stream(dependency: a_stream.id) |
| 673 | + c_stream = client.new_stream(dependency: a_stream.id) |
| 674 | + d_stream = client.new_stream(dependency: a_stream.id) |
| 675 | + |
| 676 | + expect([b_stream, c_stream, d_stream, a_stream].sort).to eq( |
| 677 | + [a_stream, b_stream, c_stream, d_stream] |
| 678 | + ) |
| 679 | + expect([b_stream, d_stream, c_stream, a_stream].sort).to eq( |
| 680 | + [a_stream, b_stream, d_stream, c_stream] |
| 681 | + ) |
| 682 | + end |
| 683 | + |
| 684 | + it "should push exclusive streams up the stack" do |
| 685 | + # he exclusive flag causes the stream to become the |
| 686 | + # sole dependency of its parent stream, causing other dependencies to |
| 687 | + # become dependent on the exclusive stream. In the previous example, |
| 688 | + # if stream D is created with an exclusive dependency on stream A, this |
| 689 | + # results in D becoming the dependency parent of B and C. |
| 690 | + a_stream = client.new_stream |
| 691 | + b_stream = client.new_stream(dependency: a_stream.id) |
| 692 | + c_stream = client.new_stream(dependency: a_stream.id) |
| 693 | + d_stream = client.new_stream(dependency: a_stream.id, exclusive: true) |
| 694 | + |
| 695 | + expect([b_stream, c_stream, d_stream, a_stream].sort).to eq( |
| 696 | + [a_stream, d_stream, b_stream, c_stream] |
| 697 | + ) |
| 698 | + end |
| 699 | + |
| 700 | + it "should prioritze based on weight" do |
| 701 | + # Streams with the same parent SHOULD be allocated resources |
| 702 | + # proportionally based on their weight. Thus, if stream B depends on |
| 703 | + # stream A with weight 4, stream C depends on stream A with weight 12, |
| 704 | + # and no progress can be made on stream A, stream B ideally receives |
| 705 | + # one-third of the resources allocated to stream C. |
| 706 | + a_stream = client.new_stream |
| 707 | + b_stream = client.new_stream(dependency: a_stream.id, weight: 4) |
| 708 | + c_stream = client.new_stream(dependency: a_stream.id, weight: 12) |
| 709 | + |
| 710 | + expect([b_stream, c_stream, a_stream].sort).to eq( |
| 711 | + [a_stream, c_stream, b_stream] |
| 712 | + ) |
| 713 | + end |
| 714 | + end |
| 715 | + |
665 | 716 | context "client API" do |
666 | 717 | it ".reprioritize should emit PRIORITY frame" do |
667 | 718 | expect(stream).to receive(:send) do |frame| |
|
0 commit comments