Flaky test in ee/spec/requests/api/graphql/project/cluster_agents_spec.rb
From https://gitlab.com/gitlab-org/gitlab/-/jobs/1200874370:
Failures:
1) Project.cluster_agents selecting tokens can select tokens in last_used_at order
Failure/Error:
expect(tokens).to match([
a_hash_including('id' => global_id_of(token_1)),
a_hash_including('id' => global_id_of(token_3)),
a_hash_including('id' => global_id_of(token_2))
])
expected [{"createdAt"=>"2021-04-21T21:22:32Z", "description"=>nil, "id"=>"gid://gitlab/Clusters::AgentToken/8...ion"=>nil, "id"=>"gid://gitlab/Clusters::AgentToken/6", "lastUsedAt"=>nil, "name"=>"agent-token-6"}] to match [(a hash including {"id" => "gid://gitlab/Clusters::AgentToken/6"}), (a hash including {"id" => "gid://gitlab/Clusters::AgentToken/8"}), (a hash including {"id" => "gid://gitlab/Clusters::AgentToken/7"})]
Diff:
@@ -1,4 +1,16 @@
-[(a hash including {"id" => "gid://gitlab/Clusters::AgentToken/6"}),
- (a hash including {"id" => "gid://gitlab/Clusters::AgentToken/8"}),
- (a hash including {"id" => "gid://gitlab/Clusters::AgentToken/7"})]
+[{"createdAt"=>"2021-04-21T21:22:32Z",
+ "description"=>nil,
+ "id"=>"gid://gitlab/Clusters::AgentToken/8",
+ "lastUsedAt"=>"2021-04-19T21:22:32Z",
+ "name"=>"agent-token-8"},
+ {"createdAt"=>"2021-04-21T21:22:32Z",
+ "description"=>nil,
+ "id"=>"gid://gitlab/Clusters::AgentToken/7",
+ "lastUsedAt"=>nil,
+ "name"=>"agent-token-7"},
+ {"createdAt"=>"2021-04-21T21:22:32Z",
+ "description"=>nil,
+ "id"=>"gid://gitlab/Clusters::AgentToken/6",
+ "lastUsedAt"=>nil,
+ "name"=>"agent-token-6"}]
# ./ee/spec/requests/api/graphql/project/cluster_agents_spec.rb:64:in `block (3 levels) in <top (required)>'
# ./spec/spec_helper.rb:355:in `block (3 levels) in <top (required)>'
# ./spec/support/sidekiq_middleware.rb:9:in `with_sidekiq_server_middleware'
# ./spec/spec_helper.rb:346:in `block (2 levels) in <top (required)>'
# ./spec/spec_helper.rb:342:in `block (3 levels) in <top (required)>'
# ./lib/gitlab/application_context.rb:31:in `with_raw_context'
# ./spec/spec_helper.rb:342:in `block (2 levels) in <top (required)>'
Finished in 13 minutes 22 seconds (files took 55.64 seconds to load)
1830 examples, 1 failure, 2 pending
Failed examples:
rspec ./ee/spec/requests/api/graphql/project/cluster_agents_spec.rb:59 # Project.cluster_agents selecting tokens can select tokens in last_used_at order
It looks like lastUsedAt
is nil
for 7 and 6. The actual array is showing IDs [8, 7, 6], but the test is expecting [8, 6, 7], so I think we can fix this by assigning a date to one of the nil
values.