|
| 1 | +# Licensed to Elasticsearch B.V. under one or more contributor |
| 2 | +# license agreements. See the NOTICE file distributed with |
| 3 | +# this work for additional information regarding copyright |
| 4 | +# ownership. Elasticsearch B.V. licenses this file to you under |
| 5 | +# the Apache License, Version 2.0 (the "License"); you may |
| 6 | +# not use this file except in compliance with the License. |
| 7 | +# You may obtain a copy of the License at |
| 8 | +# |
| 9 | +# http://www.apache.org/licenses/LICENSE-2.0 |
| 10 | +# |
| 11 | +# Unless required by applicable law or agreed to in writing, |
| 12 | +# software distributed under the License is distributed on an |
| 13 | +# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY |
| 14 | +# KIND, either express or implied. See the License for the |
| 15 | +# specific language governing permissions and limitations |
| 16 | +# under the License. |
| 17 | + |
| 18 | +require_relative '../../framework/fixture' |
| 19 | +require_relative '../../framework/settings' |
| 20 | +require_relative '../../services/logstash_service' |
| 21 | +require_relative '../../framework/helpers' |
| 22 | +require "logstash/devutils/rspec/spec_helper" |
| 23 | + |
| 24 | +describe "CLI > logstash-plugin remove" do |
| 25 | + before(:all) do |
| 26 | + @fixture = Fixture.new(__FILE__) |
| 27 | + @logstash_plugin = @fixture.get_service("logstash").plugin_cli |
| 28 | + end |
| 29 | + |
| 30 | + context "listing plugins" do |
| 31 | + |
| 32 | + let(:sub_heading_pattern) do |
| 33 | + Regexp.union(" ├──"," └──") |
| 34 | + end |
| 35 | + |
| 36 | + let(:version_pattern) do |
| 37 | + /[0-9]+[.][0-9][0-9a-z.]+/ |
| 38 | + end |
| 39 | + |
| 40 | + def parse_output(output) |
| 41 | + output.split(/\n(?! )/) |
| 42 | + end |
| 43 | + |
| 44 | + context "--verbose" do |
| 45 | + it "successfully lists a single plugin" do |
| 46 | + list_command = @logstash_plugin.run("list --verbose logstash-integration-jdbc") |
| 47 | + expect(list_command.exit_code).to eq(0) |
| 48 | + expect(list_command.stderr_and_stdout).to match(/^logstash-integration-jdbc [(]#{version_pattern}[)]/) |
| 49 | + end |
| 50 | + it "successfully lists all plugins" do |
| 51 | + list_command = @logstash_plugin.run("list --verbose") |
| 52 | + expect(list_command.exit_code).to eq(0) |
| 53 | + expect(list_command.stderr_and_stdout).to match(/^logstash-integration-jdbc [(]#{version_pattern}[)]/) |
| 54 | + expect(list_command.stderr_and_stdout).to match(/^logstash-input-beats [(]#{version_pattern}[)]/) |
| 55 | + expect(list_command.stderr_and_stdout).to match(/^logstash-output-elasticsearch [(]#{version_pattern}[)]/) |
| 56 | + end |
| 57 | + end |
| 58 | + |
| 59 | + it "expands integration plugins" do |
| 60 | + list_command = @logstash_plugin.run("list logstash-integration-jdbc") |
| 61 | + expect(list_command.exit_code).to eq(0) |
| 62 | + plugins = list_command.stderr_and_stdout.split(/\n(?! )/) |
| 63 | + |
| 64 | + integration_plugin = plugins.find { |plugin_output| plugin_output.match(/^logstash-integration-jdbc\b/) } |
| 65 | + expect(integration_plugin).to match(/^#{sub_heading_pattern} #{Regexp.escape("logstash-input-jdbc")}$/) |
| 66 | + expect(integration_plugin).to match(/^#{sub_heading_pattern} #{Regexp.escape("logstash-filter-jdbc_static")}$/) |
| 67 | + end |
| 68 | + |
| 69 | + it "expands plugin aliases" do |
| 70 | + list_command = @logstash_plugin.run("list logstash-input-beats") |
| 71 | + expect(list_command.exit_code).to eq(0) |
| 72 | + plugins = list_command.stderr_and_stdout.split(/\n(?! )/) |
| 73 | + |
| 74 | + alias_plugin = plugins.find { |plugin_output| plugin_output.match(/^logstash-input-beats\b/) } |
| 75 | + expect(alias_plugin).to match(/^#{sub_heading_pattern} #{Regexp.escape("logstash-input-elastic_agent (alias)")}$/) |
| 76 | + end |
| 77 | + |
| 78 | + context "--no-expand" do |
| 79 | + it "does not expand integration plugins" do |
| 80 | + list_command = @logstash_plugin.run("list --no-expand") |
| 81 | + expect(list_command.exit_code).to eq(0) |
| 82 | + expect(list_command.stderr_and_stdout).to match(/^logstash-integration-jdbc\b/) |
| 83 | + expect(list_command.stderr_and_stdout).to_not include("logstash-input-jdbc") # known integrated plugin |
| 84 | + expect(list_command.stderr_and_stdout).to_not include("logstash-filter-jdbc") # known integrated plugin |
| 85 | + end |
| 86 | + it "does not expand plugin aliases" do |
| 87 | + list_command = @logstash_plugin.run("list --no-expand") |
| 88 | + expect(list_command.exit_code).to eq(0) |
| 89 | + expect(list_command.stderr_and_stdout).to match(/^logstash-input-beats\b/) |
| 90 | + expect(list_command.stderr_and_stdout).to_not include("logstash-input-elastic_agent") # known alias |
| 91 | + end |
| 92 | + end |
| 93 | + end |
| 94 | +end |
0 commit comments