Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Enable x-pack security for testing against snapshots #28131

Merged
merged 58 commits into from
Jan 25, 2022
Merged
Show file tree
Hide file tree
Changes from 49 commits
Commits
Show all changes
58 commits
Select commit Hold shift + click to select a range
0490c5d
Enable xpack security for snapshot testing
cachedout Sep 27, 2021
2b0fefe
Restore accidentially deleted comment
cachedout Sep 27, 2021
cf15cb8
Include logstash config for xpack security
cachedout Sep 27, 2021
01d1d10
Clean up spacing
cachedout Sep 27, 2021
16dbf06
Fix up Filebeat tests to work with xpack security enabled
cachedout Sep 28, 2021
2093f15
More test fixing for enabling xpack security
cachedout Sep 29, 2021
06a216e
Fix lint error
cachedout Sep 29, 2021
99c7303
Setting xpack username and pass
cachedout Sep 30, 2021
7b4468c
Moving xpack auth into env
cachedout Sep 30, 2021
24214b2
Centralize ES config in test_base
cachedout Sep 30, 2021
9b460be
Use get_elasticsearch_instance in base.py
cachedout Sep 30, 2021
cc0949d
Splitting out auth by module
cachedout Oct 1, 2021
aed46fa
Fixups in filebeat testing
cachedout Oct 21, 2021
396c864
Fix go integration tests for filebeat
cachedout Oct 21, 2021
e36195e
Additional libbeat test fixes
cachedout Oct 25, 2021
fe1f840
Fixing heartbeat tests
cachedout Oct 25, 2021
300bd48
Fix libbeat tests for xpack auth
cachedout Oct 25, 2021
06403f6
Additional test fixups
cachedout Oct 26, 2021
82e6cb2
Add auth to cmd test
cachedout Oct 27, 2021
1274015
Add auth to dashboard tests
cachedout Oct 27, 2021
bbe9c81
Add auth to ILM tests
cachedout Oct 27, 2021
f66e5b9
Add auth to template tests
cachedout Oct 27, 2021
729e718
Additional test fixes
cachedout Nov 10, 2021
34d21e9
Series of fixes for filebeat
cachedout Nov 29, 2021
f4d5441
Fixup of auditbeat integration tests
cachedout Nov 29, 2021
91349cf
Additional fixes
cachedout Nov 29, 2021
cf771ef
Linting
cachedout Nov 29, 2021
4652aea
Linting
cachedout Nov 29, 2021
a346733
Lint and test fix
cachedout Nov 29, 2021
43a7b69
Remove debugging
cachedout Nov 29, 2021
ff7f8bd
Re-enabled kafka container
cachedout Nov 29, 2021
15492eb
Move auditbeat to template generator
cachedout Nov 30, 2021
9307cad
Add kibana template config test helper
cachedout Nov 30, 2021
a929fb2
Lint auditbeat
cachedout Nov 30, 2021
ff8a05d
Cleaning up filebeat tests
cachedout Nov 30, 2021
0dbd3a8
Clean up heartbeat tests
cachedout Nov 30, 2021
f73950a
Refining tests for libbeat
cachedout Nov 30, 2021
71130ee
Lint
cachedout Nov 30, 2021
1cf01ca
Fixups for libbeat tests
cachedout Dec 1, 2021
62f7ede
Minor cleanup
cachedout Dec 2, 2021
32ca5ed
Merge branch 'master' into xpack_security_test
cachedout Dec 7, 2021
81b0331
Lint
cachedout Dec 7, 2021
0150043
Update libbeat/tests/system/test_keystore.py
cachedout Dec 9, 2021
9681b4b
Update libbeat/tests/system/test_keystore.py
cachedout Dec 9, 2021
ca21c3e
Resolve merge conflict
cachedout Dec 13, 2021
bea7688
Merge branch 'xpack_security_test' of github.com:cachedout/beats into…
cachedout Dec 13, 2021
a70437f
Merge branch 'master' into xpack_security_test
cachedout Dec 13, 2021
1c7f804
Sync snapshot with master branch
cachedout Dec 13, 2021
6153e65
Fix assert for keystore test
cachedout Dec 14, 2021
a78f72b
Merge branch 'master' into xpack_security_test
mergify[bot] Jan 6, 2022
2f3eac0
Merge branch 'master' into xpack_security_test
belimawr Jan 13, 2022
4504244
Merge remote-tracking branch 'upstream/master' into xpack_security_test
belimawr Jan 20, 2022
692a9f9
fix kibana config and users roles
belimawr Jan 20, 2022
1c759e6
fix docker-compose healthcheck
belimawr Jan 20, 2022
361908e
fix merge issues
belimawr Jan 20, 2022
af6442f
fix yml identation
belimawr Jan 24, 2022
862abd2
fix: libbeat and x-pack/libbeat integTests
belimawr Jan 25, 2022
66c384a
fix kibana healthcheck for all beats
belimawr Jan 25, 2022
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion auditbeat/docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ services:
environment:
- ES_HOST=elasticsearch
- ES_PORT=9200
- ES_USER=beats
- ES_USER=auditbeat_user
- ES_PASS=testing
- KIBANA_HOST=kibana
- KIBANA_PORT=5601
Expand Down
10 changes: 5 additions & 5 deletions auditbeat/tests/system/test_base.py
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ def test_index_management(self):
"""
dirs = [self.temp_dir("auditbeat_test")]
with PathCleanup(dirs):
es = Elasticsearch([self.get_elasticsearch_url()])
es = self.get_elasticsearch_instance()

self.render_config_template(
modules=[{
Expand All @@ -50,7 +50,8 @@ def test_index_management(self):
"paths": dirs,
}
}],
elasticsearch={"host": self.get_elasticsearch_url()})
elasticsearch=self.get_elasticsearch_template_config()
)
self.run_beat(extra_args=["setup", "--index-management"], exit_code=0)

assert self.log_contains('Loaded index template')
Expand All @@ -67,16 +68,15 @@ def test_dashboards(self):
kibana_dir = os.path.join(self.beat_path, "build", "kibana")
shutil.copytree(kibana_dir, os.path.join(self.working_dir, "kibana"))

es = Elasticsearch([self.get_elasticsearch_url()])
self.render_config_template(
modules=[{
"name": "file_integrity",
"extras": {
"paths": dirs,
}
}],
elasticsearch={"host": self.get_elasticsearch_url()},
kibana={"host": self.get_kibana_url()},
elasticsearch=self.get_elasticsearch_template_config(),
kibana=self.get_kibana_template_config(),
)
self.run_beat(extra_args=["setup", "--dashboards"], exit_code=0)

Expand Down
3 changes: 2 additions & 1 deletion dev-tools/cmd/dashboards/export_dashboards.go
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,8 @@ func main() {
user = u.User.Username()
pass, _ = u.User.Password()
}

user = "beats"
pass = "testing"
transport := httpcommon.DefaultHTTPTransportSettings()
transport.Timeout = kibanaTimeout

Expand Down
4 changes: 4 additions & 0 deletions dev-tools/mage/integtest_docker.go
Original file line number Diff line number Diff line change
Expand Up @@ -112,6 +112,10 @@ func (d *DockerIntegrationTester) Test(_ string, mageTarget string, env map[stri
// Use the host machine's pkg cache to minimize external downloads.
"-v", goPkgCache + ":" + dockerGoPkgCache + ":ro",
"-e", "GOPROXY=file://" + dockerGoPkgCache + ",direct",
// Do not set ES_USER or ES_PATH in this file unless you intend to override
// values set in all individual docker-compose files
// "-e", "ES_USER=admin",
// "-e", "ES_PASS=testing",
}
args, err = addUidGidEnvArgs(args)
if err != nil {
Expand Down
8 changes: 8 additions & 0 deletions dev-tools/mage/pytest.go
Original file line number Diff line number Diff line change
Expand Up @@ -133,6 +133,14 @@ func PythonTest(params PythonTestArgs) error {
pytestOptions := []string{
"--timeout=90",
"--durations=20",
// Enable -x to stop at the first failing test
// "-x",
// Enable --tb=long to produce long tracebacks
//"--tb=long",
// Enable -v to produce verbose output
//"-v",
// Don't capture test output
//"-s",
}
if mg.Verbose() {
pytestOptions = append(pytestOptions, "-v")
Expand Down
4 changes: 3 additions & 1 deletion filebeat/fileset/modules_integration_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -258,7 +258,9 @@ func TestLoadMultiplePipelinesWithRollback(t *testing.T) {

func getTestingElasticsearch(t eslegtest.TestLogger) *eslegclient.Connection {
conn, err := eslegclient.NewConnection(eslegclient.ConnectionSettings{
URL: eslegtest.GetURL(),
URL: eslegtest.GetURL(),
Username: eslegtest.GetUser(),
Password: eslegtest.GetPass(),
})
if err != nil {
t.Fatal(err)
Expand Down
4 changes: 3 additions & 1 deletion filebeat/tests/system/config/filebeat_modules.yml.j2
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,10 @@ filebeat.overwrite_pipelines: true
filebeat.config.modules:
path: {{ beat.working_dir + '/modules.d/*.yml' }}

output.elasticsearch.hosts: ["{{ elasticsearch_url }}"]
output.elasticsearch.hosts: ["{{ elasticsearch.host }}"]
output.elasticsearch.index: {{ index_name }}
output.elasticsearch.username: {{ elasticsearch.user }}
output.elasticsearch.password: {{ elasticsearch.pass }}

setup.template.name: {{ index_name }}
setup.template.pattern: {{ index_name }}*
Expand Down
13 changes: 9 additions & 4 deletions filebeat/tests/system/test_base.py
Original file line number Diff line number Diff line change
@@ -1,13 +1,19 @@
import os
import unittest
from filebeat import BaseTest
from elasticsearch import Elasticsearch
from beat.beat import INTEGRATION_TESTS
from beat import common_tests


class Test(BaseTest, common_tests.TestExportsMixin, common_tests.TestDashboardMixin):

def setUp(self):
super(Test, self).setUp()
self.render_config_template(
elasticsearch=self.get_elasticsearch_template_config(),
)
self.es = self.get_elasticsearch_instance()

def test_base(self):
"""
Test if the basic fields exist.
Expand All @@ -32,12 +38,11 @@ def test_index_management(self):
"""
Test that the template can be loaded with `setup --index-management`
"""
es = Elasticsearch([self.get_elasticsearch_url()])
self.render_config_template(
elasticsearch={"host": self.get_elasticsearch_url()},
elasticsearch=self.get_elasticsearch_template_config(),
)
exit_code = self.run_beat(extra_args=["setup", "--index-management"])

assert exit_code == 0
assert self.log_contains('Loaded index template')
assert len(es.cat.templates(name='filebeat-*', h='name')) > 0
assert len(self.es.cat.templates(name='filebeat-*', h='name')) > 0
25 changes: 12 additions & 13 deletions filebeat/tests/system/test_crawler.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ def test_fetched_lines(self):
"""

self.render_config_template(
path=os.path.abspath(self.working_dir) + "/log/*"
path=os.path.abspath(self.working_dir) + "/log/*",
)
os.mkdir(self.working_dir + "/log/")

Expand Down Expand Up @@ -55,7 +55,7 @@ def test_unfinished_line_and_continue(self):
"""

self.render_config_template(
path=os.path.abspath(self.working_dir) + "/log/*"
path=os.path.abspath(self.working_dir) + "/log/*",
)
os.mkdir(self.working_dir + "/log/")

Expand Down Expand Up @@ -162,7 +162,7 @@ def test_file_renaming(self):
"""

self.render_config_template(
path=os.path.abspath(self.working_dir) + "/log/*"
path=os.path.abspath(self.working_dir) + "/log/*",
)
os.mkdir(self.working_dir + "/log/")

Expand Down Expand Up @@ -339,7 +339,7 @@ def test_new_line_on_existing_file(self):
"""

self.render_config_template(
path=os.path.abspath(self.working_dir) + "/log/*"
path=os.path.abspath(self.working_dir) + "/log/*",
)
os.mkdir(self.working_dir + "/log/")

Expand Down Expand Up @@ -373,7 +373,7 @@ def test_multiple_appends(self):
"""

self.render_config_template(
path=os.path.abspath(self.working_dir) + "/log/*"
path=os.path.abspath(self.working_dir) + "/log/*",
)
os.mkdir(self.working_dir + "/log/")

Expand Down Expand Up @@ -419,7 +419,7 @@ def test_new_line_on_open_file(self):
"""

self.render_config_template(
path=os.path.abspath(self.working_dir) + "/log/*"
path=os.path.abspath(self.working_dir) + "/log/*",
)
os.mkdir(self.working_dir + "/log/")

Expand Down Expand Up @@ -457,7 +457,7 @@ def test_tail_files(self):

self.render_config_template(
path=os.path.abspath(self.working_dir) + "/log/*",
tail_files="true"
tail_files="true",
)
os.mkdir(self.working_dir + "/log/")

Expand Down Expand Up @@ -501,7 +501,7 @@ def test_utf8(self):

self.render_config_template(
path=os.path.abspath(self.working_dir) + "/log/*",
encoding="utf-8"
encoding="utf-8",
)
os.mkdir(self.working_dir + "/log/")

Expand Down Expand Up @@ -613,7 +613,7 @@ def test_include_lines(self):

self.render_config_template(
path=os.path.abspath(self.working_dir) + "/log/*",
include_lines=["^ERR", "^WARN"]
include_lines=["^ERR", "^WARN"],
)
os.mkdir(self.working_dir + "/log/")

Expand Down Expand Up @@ -648,9 +648,8 @@ def test_default_include_exclude_lines(self):
"""
Checks if all the log lines are exported by default
"""

self.render_config_template(
path=os.path.abspath(self.working_dir) + "/log/*"
path=os.path.abspath(self.working_dir) + "/log/*",
)
os.mkdir(self.working_dir + "/log/")

Expand Down Expand Up @@ -688,7 +687,7 @@ def test_exclude_lines(self):

self.render_config_template(
path=os.path.abspath(self.working_dir) + "/log/*",
exclude_lines=["^DBG"]
exclude_lines=["^DBG"],
)
os.mkdir(self.working_dir + "/log/")

Expand Down Expand Up @@ -727,7 +726,7 @@ def test_include_exclude_lines(self):
self.render_config_template(
path=os.path.abspath(self.working_dir) + "/log/*",
exclude_lines=["^DBG"],
include_lines=["apache"]
include_lines=["apache"],
)
os.mkdir(self.working_dir + "/log/")

Expand Down
7 changes: 2 additions & 5 deletions filebeat/tests/system/test_modules.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@
import glob
import subprocess

from elasticsearch import Elasticsearch
import json
import logging
from parameterized import parameterized
Expand Down Expand Up @@ -61,9 +60,7 @@ def load_fileset_test_cases():
class Test(BaseTest):

def init(self):
self.elasticsearch_url = self.get_elasticsearch_url()
print("Using elasticsearch: {}".format(self.elasticsearch_url))
self.es = Elasticsearch([self.elasticsearch_url])
self.es = self.get_elasticsearch_instance(user='admin')
logging.getLogger("urllib3").setLevel(logging.WARNING)
logging.getLogger("elasticsearch").setLevel(logging.ERROR)

Expand All @@ -89,7 +86,7 @@ def test_fileset_file(self, module, fileset, test_file):
template_name="filebeat_modules",
output=cfgfile,
index_name=self.index_name,
elasticsearch_url=self.elasticsearch_url,
elasticsearch=self.get_elasticsearch_template_config(user='admin')
)

self.run_on_file(
Expand Down
15 changes: 8 additions & 7 deletions filebeat/tests/system/test_pipeline.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@
from beat.beat import INTEGRATION_TESTS
import os
import unittest
from elasticsearch import Elasticsearch
import json
import logging

Expand All @@ -12,8 +11,7 @@ class Test(BaseTest):
def init(self):
self.elasticsearch_url = self.get_elasticsearch_url()
self.kibana_url = self.get_kibana_url()
print("Using elasticsearch: {}".format(self.elasticsearch_url))
self.es = Elasticsearch([self.elasticsearch_url])
self.es = self.get_elasticsearch_instance()
logging.getLogger("urllib3").setLevel(logging.WARNING)
logging.getLogger("elasticsearch").setLevel(logging.ERROR)

Expand Down Expand Up @@ -47,10 +45,13 @@ def test_input_pipeline_config(self):

self.render_config_template(
path=os.path.abspath(self.working_dir) + "/log/*",
elasticsearch=dict(
host=self.elasticsearch_url,
pipeline="estest",
index=index_name),
elasticsearch={
'host': self.elasticsearch_url,
'pipeline': "estest",
'index': index_name,
'user': os.getenv("ES_USER"),
'pass': os.getenv("ES_PASS")
},
pipeline="test",
setup_template_name=index_name,
setup_template_pattern=index_name + "*",
Expand Down
5 changes: 2 additions & 3 deletions filebeat/tests/system/test_reload_modules.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@

from filebeat import BaseTest
from beat.beat import INTEGRATION_TESTS
from elasticsearch import Elasticsearch


moduleConfigTemplate = """
Expand All @@ -27,7 +26,7 @@ class Test(BaseTest):
def setUp(self):
super(BaseTest, self).setUp()
if INTEGRATION_TESTS:
self.es = Elasticsearch([self.get_elasticsearch_url()])
self.es = self.get_elasticsearch_instance()

# Copy system module
shutil.copytree(os.path.join(self.beat_path, "tests", "system", "module", "test"),
Expand Down Expand Up @@ -72,7 +71,7 @@ def test_reload_writes_pipeline(self):
reload_path=self.working_dir + "/configs/*.yml",
reload_type="modules",
inputs=False,
elasticsearch={"host": self.get_elasticsearch_url()}
elasticsearch=self.get_elasticsearch_template_config(),
)

proc = self.start_beat()
Expand Down
8 changes: 2 additions & 6 deletions filebeat/tests/system/test_setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,6 @@
import yaml
from shutil import copytree, copyfile

from elasticsearch import Elasticsearch

from filebeat import BaseTest

INTEGRATION_TESTS = os.environ.get('INTEGRATION_TESTS', False)
Expand All @@ -15,7 +13,7 @@ class Test(BaseTest):
def init(self):
self.elasticsearch_url = self.get_elasticsearch_url()
print("Using elasticsearch: {}".format(self.elasticsearch_url))
self.es = Elasticsearch([self.elasticsearch_url])
self.es = self.get_elasticsearch_instance()

@unittest.skipIf(not INTEGRATION_TESTS,
"integration tests are disabled, run with INTEGRATION_TESTS=1 to enable them.")
Expand All @@ -28,9 +26,7 @@ def test_setup_modules_d_config(self):
self.init()
self.render_config_template(
modules=True,
elasticsearch={
"host": self.get_elasticsearch_url(),
},
elasticsearch=self.get_elasticsearch_template_config(),
)

self._setup_dummy_module()
Expand Down
2 changes: 2 additions & 0 deletions heartbeat/docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,8 @@ services:
- REDIS_HOST=redis
- REDIS_PORT=6379
- ES_HOST=elasticsearch
- ES_USER=heartbeat_user
- ES_PASS=testing
- ES_PORT=9200
working_dir: /go/src/github.com/elastic/beats/heartbeat
volumes:
Expand Down
2 changes: 2 additions & 0 deletions heartbeat/tests/system/config/heartbeat.yml.j2
Original file line number Diff line number Diff line change
Expand Up @@ -105,6 +105,8 @@ queue.mem:
{%- if elasticsearch %}
output.elasticsearch:
hosts: ["{{ elasticsearch.host }}"]
username: {{ elasticsearch.user }}
password: {{ elasticsearch.pass }}
{%- else %}
output.file:
path: '{{ output_file_path|default(beat.working_dir + "/output") }}'
Expand Down
Loading