pact_broker 2.39.0 → 2.40.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 7e280e7c13bd55791cab9e6133c2a63c62e18c89
4
- data.tar.gz: 34f9831b62572f892ccd85a4a71f8f05e0660210
3
+ metadata.gz: 9640609d3cd63f00f72cd919503c9753e7f14901
4
+ data.tar.gz: c538742c6e384659661609b059e24ca1c5732ae2
5
5
  SHA512:
6
- metadata.gz: 358dff2b700249596936bf1cd380568a01220941a0f63e4d70ed3366f5e69b1a8fa2855976011779439dfd01e43cae4e2c79b370a9f1920bcb98a199da92f132
7
- data.tar.gz: f5a45fde10fde4d65afef8cc1ce3202da9dd46163c5f0096f6c421a305dc87a1f0528502bfcc0a15d4771b7a95e0e42864a6de1f218e56a1daadee73e5b69225
6
+ metadata.gz: 9a6918c28db99e46a2c28c6ac608aadec4efe8780369328956a8617bd1f17dd3bb8899c80f0e597920d0005e9856e0cce56303f108df98240d32556808f1fd46
7
+ data.tar.gz: 99cc9f3892e31cd11c449de7f4da9469f70d96df2ec6501df37225f3d98b5068ac71fbf42e1f359e5acbe7c29f572aa2d6baaa066a180c3ffa65fea29e777979
@@ -1,3 +1,27 @@
1
+ <a name="v2.40.0"></a>
2
+ ### v2.40.0 (2019-10-26)
3
+
4
+
5
+ #### Features
6
+
7
+ * **matrix**
8
+ * default page to showing 'latest by consumer version and provider' as it is much quicker and less confusing. ([dd879250](/../../commit/dd879250))
9
+
10
+ * optimise query to find latest verification for consumer version tag ([301b30ca](/../../commit/301b30ca))
11
+
12
+ * **matrix badge**
13
+ * optimise database query ([2b7f8e23](/../../commit/2b7f8e23))
14
+
15
+
16
+ #### Bug Fixes
17
+
18
+ * **matrix**
19
+ * exceptions on matrix page due to recent query optimisation ([3c504ba5](/../../commit/3c504ba5))
20
+
21
+ * **frontend**
22
+ * remove 'v' prefix on versions during render (#313) ([e109a8cd](/../../commit/e109a8cd))
23
+
24
+
1
25
  <a name="v2.39.0"></a>
2
26
  ### v2.39.0 (2019-10-21)
3
27
 
@@ -0,0 +1,38 @@
1
+ # The latest verification id for each consumer version tag
2
+ # This is not:
3
+ # find latest pacticipant version with given tag
4
+ # -> find the latest pact
5
+ # -> find the latest verification
6
+ # because the latest pacticipant version with the tag might not have a pact,
7
+ # and the latest pact might not have a verification.
8
+
9
+ # This is:
10
+ # join the tags and the pacticipant versions and the verifications and find the "latest" row
11
+
12
+ LATEST_VERIFICATION_IDS_FOR_CONSUMER_VERSION_TAGS_V1 = "select
13
+ pv.pacticipant_id as provider_id,
14
+ lpp.consumer_id,
15
+ t.name as consumer_version_tag_name,
16
+ max(v.id) as latest_verification_id
17
+ from verifications v
18
+ join latest_pact_publications_by_consumer_versions lpp
19
+ on v.pact_version_id = lpp.pact_version_id
20
+ join tags t
21
+ on lpp.consumer_version_id = t.version_id
22
+ join versions pv
23
+ on v.provider_version_id = pv.id
24
+ group by pv.pacticipant_id, lpp.consumer_id, t.name"
25
+
26
+ LATEST_VERIFICATION_IDS_FOR_CONSUMER_VERSION_TAGS_V2 = "select
27
+ pv.pacticipant_id as provider_id,
28
+ lpp.consumer_id,
29
+ t.name as consumer_version_tag_name,
30
+ max(v.id) as latest_verification_id
31
+ from verifications v
32
+ join latest_pact_publication_ids_for_consumer_versions lpp
33
+ on v.pact_version_id = lpp.pact_version_id
34
+ join tags t
35
+ on lpp.consumer_version_id = t.version_id
36
+ join versions pv
37
+ on v.provider_version_id = pv.id
38
+ group by pv.pacticipant_id, lpp.consumer_id, t.name"
@@ -1,22 +1,8 @@
1
+ require_relative '../ddl_statements'
2
+
1
3
  Sequel.migration do
2
4
  up do
3
- # The latest verification id for each consumer version tag
4
- # This is not the latest verification for the latest pact with a given tag,
5
- # this is the latest verification for any pact with the tag
6
- create_view(:latest_verification_ids_for_consumer_version_tags,
7
- "select
8
- pv.pacticipant_id as provider_id,
9
- lpp.consumer_id,
10
- t.name as consumer_version_tag_name,
11
- max(v.id) as latest_verification_id
12
- from verifications v
13
- join latest_pact_publications_by_consumer_versions lpp
14
- on v.pact_version_id = lpp.pact_version_id
15
- join tags t
16
- on lpp.consumer_version_id = t.version_id
17
- join versions pv
18
- on v.provider_version_id = pv.id
19
- group by pv.pacticipant_id, lpp.consumer_id, t.name")
5
+ create_view(:latest_verification_ids_for_consumer_version_tags, LATEST_VERIFICATION_IDS_FOR_CONSUMER_VERSION_TAGS_V1)
20
6
 
21
7
  # The most recent verification for each consumer/consumer version tag/provider
22
8
  latest_verifications = from(:verifications)
@@ -0,0 +1,11 @@
1
+ require_relative '../ddl_statements'
2
+
3
+ Sequel.migration do
4
+ up do
5
+ create_or_replace_view(:latest_verification_ids_for_consumer_version_tags, LATEST_VERIFICATION_IDS_FOR_CONSUMER_VERSION_TAGS_V2)
6
+ end
7
+
8
+ down do
9
+ create_or_replace_view(:latest_verification_ids_for_consumer_version_tags, LATEST_VERIFICATION_IDS_FOR_CONSUMER_VERSION_TAGS_V1)
10
+ end
11
+ end
@@ -47,7 +47,7 @@ module PactBroker
47
47
  end
48
48
 
49
49
  def name
50
- "Pact between #{consumer.name} (v#{consumer_version_number}) and #{provider.name}"
50
+ "Pact between #{consumer.name} (#{consumer_version_number}) and #{provider.name}"
51
51
  end
52
52
 
53
53
  def version_and_updated_date
@@ -58,12 +58,6 @@ module PactBroker
58
58
  .left_outer_join(:tags, {version_id: :consumer_version_id})
59
59
  .where(Sequel.qualify(:tags, :name) => nil)
60
60
  end
61
-
62
- def provider_version_tag tag_name
63
- filter = name_like(Sequel.qualify(:ptags, :name), tag_name)
64
- join_params = { Sequel[:ptags][:version_id] => Sequel[model.table_name][:provider_version_id] }
65
- join(:tags, join_params, {table_alias: :ptags}).where(filter)
66
- end
67
61
  end
68
62
 
69
63
  def pact_version_sha
@@ -204,7 +204,7 @@ module PactBroker
204
204
  end
205
205
 
206
206
  def verification_executed_at
207
- verification.execution_date
207
+ verification&.execution_date
208
208
  end
209
209
 
210
210
  # Add logic for ignoring case
@@ -215,7 +215,7 @@ module PactBroker
215
215
  end
216
216
 
217
217
  def to_s
218
- "#{consumer_name} v#{consumer_version_number} #{provider_name} #{provider_version_number} #{success}"
218
+ "#{consumer_name} #{consumer_version_number} #{provider_name} #{provider_version_number} #{success}"
219
219
  end
220
220
 
221
221
  def compare_number_desc number1, number2
@@ -42,7 +42,7 @@ module PactBroker
42
42
 
43
43
  get "/provider/:provider_name/consumer/:consumer_name" do
44
44
  selectors = [{ pacticipant_name: params[:consumer_name] }, { pacticipant_name: params[:provider_name] } ]
45
- options = {latestby: nil, limit: 100}
45
+ options = {latestby: 'cvpv', limit: 100}
46
46
  lines = matrix_service.find(selectors, options)
47
47
  lines = PactBroker::UI::ViewDomain::MatrixLines.new(lines)
48
48
  locals = {
@@ -151,11 +151,11 @@ module PactBroker
151
151
  def verification_tooltip
152
152
  case @relationship.pseudo_branch_verification_status
153
153
  when :success
154
- "Successfully verified by #{provider_name} (v#{short_version_number(@relationship.latest_verification_provider_version_number)})"
154
+ "Successfully verified by #{provider_name} (#{short_version_number(@relationship.latest_verification_provider_version_number)})"
155
155
  when :stale
156
- "Pact has changed since last successful verification by #{provider_name} (v#{short_version_number(@relationship.latest_verification_provider_version_number)})"
156
+ "Pact has changed since last successful verification by #{provider_name} (#{short_version_number(@relationship.latest_verification_provider_version_number)})"
157
157
  when :failed
158
- "Verification by #{provider_name} (v#{short_version_number(@relationship.latest_verification_provider_version_number)}) failed"
158
+ "Verification by #{provider_name} (#{short_version_number(@relationship.latest_verification_provider_version_number)}) failed"
159
159
  else
160
160
  nil
161
161
  end
@@ -17,7 +17,7 @@ module PactBroker
17
17
  end
18
18
 
19
19
  def provider_name
20
- @line[:provider_name]
20
+ @line.provider_name
21
21
  end
22
22
 
23
23
  def provider_name_url
@@ -25,7 +25,7 @@ module PactBroker
25
25
  end
26
26
 
27
27
  def consumer_name
28
- @line[:consumer_name]
28
+ @line.consumer_name
29
29
  end
30
30
 
31
31
  def consumer_name_url
@@ -33,24 +33,24 @@ module PactBroker
33
33
  end
34
34
 
35
35
  def pact_version_sha
36
- @line[:pact_version_sha]
36
+ @line.pact_version_sha
37
37
  end
38
38
 
39
39
  # verification number, used in verification_url method
40
40
  def number
41
- @line[:verification_number]
41
+ @line.verification_number
42
42
  end
43
43
 
44
44
  def pact_revision_number
45
- @line[:pact_revision_number]
45
+ @line.pact_revision_number
46
46
  end
47
47
 
48
48
  def consumer_name
49
- @line[:consumer_name]
49
+ @line.consumer_name
50
50
  end
51
51
 
52
52
  def consumer_version_number
53
- @line[:consumer_version_number]
53
+ @line.consumer_version_number
54
54
  end
55
55
 
56
56
  def display_consumer_version_number
@@ -63,15 +63,15 @@ module PactBroker
63
63
  end
64
64
 
65
65
  def consumer_version_order
66
- @line[:consumer_version_order]
66
+ @line.consumer_version_order
67
67
  end
68
68
 
69
69
  def provider_name
70
- @line[:provider_name]
70
+ @line.provider_name
71
71
  end
72
72
 
73
73
  def provider_version_number
74
- @line[:provider_version_number]
74
+ @line.provider_version_number
75
75
  end
76
76
 
77
77
  def display_provider_version_number
@@ -79,7 +79,7 @@ module PactBroker
79
79
  end
80
80
 
81
81
  def provider_version_order
82
- @line[:provider_version_order]
82
+ @line.provider_version_order
83
83
  end
84
84
 
85
85
  def provider_version_number_url
@@ -88,39 +88,39 @@ module PactBroker
88
88
  end
89
89
 
90
90
  def provider_version_order
91
- if @line[:verification_executed_at]
92
- @line[:verification_executed_at].to_time.to_i
91
+ if @line.verification_executed_at
92
+ @line.verification_executed_at.to_time.to_i
93
93
  else
94
94
  0
95
95
  end
96
96
  end
97
97
 
98
98
  def latest_consumer_version_tags
99
- @line[:consumer_version_tags]
100
- .select{ | tag | tag[:latest] }
99
+ @line.consumer_version_tags
100
+ .select{ | tag | tag.latest }
101
101
  .collect{ | tag | MatrixTag.new(tag.to_hash.merge(pacticipant_name: consumer_name, version_number: consumer_version_number)) }
102
102
  end
103
103
 
104
104
  def other_consumer_version_tags
105
- @line[:consumer_version_tags]
106
- .select{ | tag | !tag[:latest] }
105
+ @line.consumer_version_tags
106
+ .select{ | tag | !tag.latest }
107
107
  .collect{ | tag | MatrixTag.new(tag.to_hash.merge(pacticipant_name: consumer_name, version_number: consumer_version_number)) }
108
108
  end
109
109
 
110
110
  def latest_provider_version_tags
111
- @line[:provider_version_tags]
112
- .select{ | tag | tag[:latest] }
111
+ @line.provider_version_tags
112
+ .select{ | tag | tag.latest }
113
113
  .collect{ | tag | MatrixTag.new(tag.to_hash.merge(pacticipant_name: provider_name, version_number: provider_version_number)) }
114
114
  end
115
115
 
116
116
  def other_provider_version_tags
117
- @line[:provider_version_tags]
118
- .select{ | tag | !tag[:latest] }
117
+ @line.provider_version_tags
118
+ .select{ | tag | !tag.latest }
119
119
  .collect{ | tag | MatrixTag.new(tag.to_hash.merge(pacticipant_name: provider_name, version_number: provider_version_number)) }
120
120
  end
121
121
 
122
122
  def orderable_fields
123
- [consumer_name, consumer_version_order, pact_revision_number, provider_name, @line[:verification_id]]
123
+ [consumer_name, consumer_version_order, pact_revision_number, provider_name, @line.verification_id]
124
124
  end
125
125
 
126
126
  def <=> other
@@ -128,12 +128,12 @@ module PactBroker
128
128
  end
129
129
 
130
130
  def pseudo_branch_verification_status
131
- if @line[:verification_executed_at]
132
- DateHelper.distance_of_time_in_words(@line[:verification_executed_at], DateTime.now) + " ago"
131
+ if @line.verification_executed_at
132
+ DateHelper.distance_of_time_in_words(@line.verification_executed_at, DateTime.now) + " ago"
133
133
  else
134
134
  ''
135
135
  end
136
- # case @line[:success]
136
+ # case @line.success
137
137
  # when true then "Verified"
138
138
  # when false then "Failed"
139
139
  # else ''
@@ -145,7 +145,7 @@ module PactBroker
145
145
  end
146
146
 
147
147
  def pact_publication_date
148
- relative_date(@line[:pact_created_at])
148
+ relative_date(@line.pact_created_at)
149
149
  end
150
150
 
151
151
  def pact_publication_date_url
@@ -157,11 +157,11 @@ module PactBroker
157
157
  end
158
158
 
159
159
  def pact_published_order
160
- @line[:pact_created_at].to_time.to_i
160
+ @line.pact_created_at.to_time.to_i
161
161
  end
162
162
 
163
163
  def verification_status_class
164
- case @line[:success]
164
+ case @line.success
165
165
  when true then 'success'
166
166
  when false then 'danger'
167
167
  else ''
@@ -177,7 +177,7 @@ module PactBroker
177
177
  end
178
178
 
179
179
  def inherited_verification_message
180
- if @line[:verification_executed_at] && @line[:pact_created_at] > @line[:verification_executed_at]
180
+ if @line.verification_executed_at && @line.pact_created_at > @line.verification_executed_at
181
181
  "The verification date is before the pact publication date because this verification has been inherited from a previously verified pact with identical content."
182
182
  end
183
183
  end
@@ -101,19 +101,27 @@ module PactBroker
101
101
  end
102
102
 
103
103
  def find_latest_verification_for_tags consumer_name, provider_name, consumer_version_tag, provider_version_tag
104
- view_name = PactBroker::Verifications::AllVerifications.table_name
105
- query = PactBroker::Verifications::AllVerifications
104
+ view_name = PactBroker::Domain::Verification.table_name
105
+ consumer = pacticipant_repository.find_by_name(consumer_name)
106
+ provider = pacticipant_repository.find_by_name(provider_name)
107
+
108
+ consumer_tag_filter = PactBroker::Repositories::Helpers.name_like(Sequel.qualify(:consumer_tags, :name), consumer_version_tag)
109
+ provider_tag_filter = PactBroker::Repositories::Helpers.name_like(Sequel.qualify(:provider_tags, :name), provider_version_tag)
110
+
111
+ query = PactBroker::Domain::Verification
106
112
  .select_all_qualified
107
- .join(:versions, {Sequel[:provider_versions][:id] => Sequel[view_name][:provider_version_id]}, {table_alias: :provider_versions})
108
- .join(:latest_pact_publications_by_consumer_versions, { Sequel[view_name][:pact_version_id] => Sequel[:latest_pact_publications_by_consumer_versions][:pact_version_id] })
109
- .consumer(consumer_name)
110
- .provider(provider_name)
111
- .tag(consumer_version_tag)
112
- .provider_version_tag(provider_version_tag)
113
+ .join(:versions, { Sequel[:provider_versions][:id] => Sequel[view_name][:provider_version_id] }, { table_alias: :provider_versions })
114
+ .join(:latest_verification_id_for_pact_version_and_provider_version, { Sequel[:lv][:verification_id] => Sequel[view_name][:id] }, { table_alias: :lv })
115
+ .join(:latest_pact_publication_ids_for_consumer_versions, { Sequel[view_name][:pact_version_id] => Sequel[:lp][:pact_version_id] }, { table_alias: :lp })
116
+ .join(:versions, { Sequel[:consumer_versions][:id] => Sequel[:lp][:consumer_version_id] }, { table_alias: :consumer_versions })
117
+ .join(:tags, { Sequel[:consumer_tags][:version_id] => Sequel[:lp][:consumer_version_id]}, { table_alias: :consumer_tags })
118
+ .join(:tags, { Sequel[:provider_tags][:version_id] => Sequel[view_name][:provider_version_id]}, { table_alias: :provider_tags })
119
+ .where(consumer: consumer, provider: provider)
120
+ .where(consumer_tag_filter)
121
+ .where(provider_tag_filter)
113
122
 
114
123
  query.reverse_order(
115
- Sequel[:latest_pact_publications_by_consumer_versions][:consumer_version_order],
116
- Sequel[:latest_pact_publications_by_consumer_versions][:revision_number],
124
+ Sequel[:consumer_versions][:order],
117
125
  Sequel[:provider_versions][:order],
118
126
  Sequel[view_name][:execution_date]
119
127
  ).limit(1).single_record
@@ -1,3 +1,3 @@
1
1
  module PactBroker
2
- VERSION = '2.39.0'
2
+ VERSION = '2.40.0'
3
3
  end
@@ -59,8 +59,8 @@ module PactBroker
59
59
  subject { Diff.new.process(pact_params.merge(base_url: 'http://example.org'), comparison_pact_params) }
60
60
 
61
61
  it "compares the two pacts" do
62
- expect(subject).to include "Pact between Consumer (v3) and Provider"
63
- expect(subject).to include "Pact between Consumer (v4) and Provider"
62
+ expect(subject).to include "Pact between Consumer (3) and Provider"
63
+ expect(subject).to include "Pact between Consumer (4) and Provider"
64
64
  end
65
65
 
66
66
  it "includes a link to the comparison pact", pending: true do
@@ -52,21 +52,21 @@ module PactBroker
52
52
  let(:pseudo_branch_verification_status) { :stale }
53
53
  its(:pseudo_branch_verification_status) { is_expected.to eq "warning" }
54
54
  its(:warning?) { is_expected.to be true }
55
- its(:verification_tooltip) { is_expected.to eq "Pact has changed since last successful verification by Foo (v4.5.6)" }
55
+ its(:verification_tooltip) { is_expected.to eq "Pact has changed since last successful verification by Foo (4.5.6)" }
56
56
  end
57
57
 
58
58
  context "when the pact has not changed since the last successful verification" do
59
59
  let(:pseudo_branch_verification_status) { :success }
60
60
  its(:pseudo_branch_verification_status) { is_expected.to eq "success" }
61
61
  its(:warning?) { is_expected.to be false }
62
- its(:verification_tooltip) { is_expected.to eq "Successfully verified by Foo (v4.5.6)" }
62
+ its(:verification_tooltip) { is_expected.to eq "Successfully verified by Foo (4.5.6)" }
63
63
  end
64
64
 
65
65
  context "when the pact verification failed" do
66
66
  let(:pseudo_branch_verification_status) { :failed }
67
67
  its(:pseudo_branch_verification_status) { is_expected.to eq "danger" }
68
68
  its(:warning?) { is_expected.to be false }
69
- its(:verification_tooltip) { is_expected.to eq "Verification by Foo (v4.5.6) failed" }
69
+ its(:verification_tooltip) { is_expected.to eq "Verification by Foo (4.5.6) failed" }
70
70
  end
71
71
  end
72
72
 
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: pact_broker
3
3
  version: !ruby/object:Gem::Version
4
- version: 2.39.0
4
+ version: 2.40.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Bethany Skurrie
@@ -10,7 +10,7 @@ authors:
10
10
  autorequire:
11
11
  bindir: bin
12
12
  cert_chain: []
13
- date: 2019-10-21 00:00:00.000000000 Z
13
+ date: 2019-10-25 00:00:00.000000000 Z
14
14
  dependencies:
15
15
  - !ruby/object:Gem::Dependency
16
16
  name: httparty
@@ -610,6 +610,7 @@ files:
610
610
  - db/ddl_statements.rb
611
611
  - db/ddl_statements/head_matrix_v001.rb
612
612
  - db/ddl_statements/head_matrix_v002.rb
613
+ - db/ddl_statements/latest_verification_ids_for_consumer_version_tags.rb
613
614
  - db/ddl_statements/latest_verification_ids_for_pact_versions_v001.rb
614
615
  - db/migrations/000001_create_pacticipant_table.rb
615
616
  - db/migrations/000002_create_versions_table.rb
@@ -717,6 +718,7 @@ files:
717
718
  - db/migrations/20190909_add_test_results_to_all_verifications.rb
718
719
  - db/migrations/20190910_add_test_results_to_latest_verifications.rb
719
720
  - db/migrations/20190911_add_test_results_to_latest_verifications_for_pact_versions.rb
721
+ - db/migrations/20191025_optimise_latest_verification_ids_for_cv_tags.rb
720
722
  - db/migrations/migration_helper.rb
721
723
  - db/test/backwards_compatibility/.rspec
722
724
  - db/test/backwards_compatibility/Appraisals