summaryrefslogtreecommitdiff
path: root/spec/requests/api/graphql_spec.rb
diff options
context:
space:
mode:
authorcharlieablett <cablett@gitlab.com>2019-06-21 16:20:00 +0200
committercharlieablett <cablett@gitlab.com>2019-07-03 22:53:13 +1200
commitf4890d90782ad42a802b89c2a17c83bf9fb9d123 (patch)
tree233421eff8ec110cc16b1dcb9b50bedccb044e76 /spec/requests/api/graphql_spec.rb
parentc99c30fdd6f3adf4fb29aad4b10e265be69d2d67 (diff)
downloadgitlab-ce-f4890d90782ad42a802b89c2a17c83bf9fb9d123.tar.gz
Alert if `calls_gitaly` declaration missing
- Move `calls_gitaly_check` to public - Add instrumentation for flagging missing CallsGitaly declarations - Wrap resolver proc in before-and-after Gitaly counts to get the net Gitaly call count for the resolver.
Diffstat (limited to 'spec/requests/api/graphql_spec.rb')
-rw-r--r--spec/requests/api/graphql_spec.rb31
1 files changed, 31 insertions, 0 deletions
diff --git a/spec/requests/api/graphql_spec.rb b/spec/requests/api/graphql_spec.rb
index 656d6f8b50b..d78b17827a6 100644
--- a/spec/requests/api/graphql_spec.rb
+++ b/spec/requests/api/graphql_spec.rb
@@ -131,4 +131,35 @@ describe 'GraphQL' do
end
end
end
+
+ describe 'testing for Gitaly calls' do
+ let(:project) { create(:project, :repository) }
+ let(:user) { create(:user) }
+
+ let(:query) do
+ graphql_query_for('project', { 'fullPath' => project.full_path }, %w(forksCount))
+ end
+
+ before do
+ project.add_developer(user)
+ end
+
+ it_behaves_like 'a working graphql query' do
+ before do
+ post_graphql(query, current_user: user)
+ end
+ end
+
+ context 'when Gitaly is called' do
+ before do
+ allow(Gitlab::GitalyClient).to receive(:get_request_count).and_return(1, 2)
+ end
+
+ it "logs a warning that the 'calls_gitaly' field declaration is missing" do
+ expect(Gitlab::Sentry).to receive(:track_exception).once
+
+ post_graphql(query, current_user: user)
+ end
+ end
+ end
end