2020-04-15 14:09:36 -04:00
|
|
|
# frozen_string_literal: true
|
|
|
|
|
|
|
|
require 'spec_helper'
|
|
|
|
|
2020-06-24 14:09:03 -04:00
|
|
|
RSpec.describe Gitlab::Elasticsearch::Logs::Pods do
|
2020-04-15 14:09:36 -04:00
|
|
|
let(:client) { Elasticsearch::Transport::Client }
|
|
|
|
|
2020-04-30 20:09:59 -04:00
|
|
|
let(:es_query) { Gitlab::Json.parse(fixture_file('lib/elasticsearch/pods_query.json'), symbolize_names: true) }
|
|
|
|
let(:es_response) { Gitlab::Json.parse(fixture_file('lib/elasticsearch/pods_response.json')) }
|
2020-04-15 14:09:36 -04:00
|
|
|
let(:namespace) { "autodevops-deploy-9-production" }
|
|
|
|
|
|
|
|
subject { described_class.new(client) }
|
|
|
|
|
|
|
|
describe '#pods' do
|
|
|
|
it 'returns the pods' do
|
|
|
|
expect(client).to receive(:search).with(body: es_query).and_return(es_response)
|
|
|
|
|
|
|
|
result = subject.pods(namespace)
|
|
|
|
expect(result).to eq([
|
|
|
|
{
|
|
|
|
name: "runner-gitlab-runner-7bbfb5dcb5-p6smb",
|
|
|
|
container_names: %w[runner-gitlab-runner]
|
|
|
|
},
|
|
|
|
{
|
|
|
|
name: "elastic-stack-elasticsearch-master-1",
|
|
|
|
container_names: %w[elasticsearch chown sysctl]
|
|
|
|
},
|
|
|
|
{
|
|
|
|
name: "ingress-nginx-ingress-controller-76449bcc8d-8qgl6",
|
|
|
|
container_names: %w[nginx-ingress-controller]
|
|
|
|
}
|
|
|
|
])
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|