summaryrefslogtreecommitdiff
path: root/qa/vagrant/src/test/resources/packaging/tests/75_bad_data_paths.bats
blob: 0f802a439b702797434fe336352b0faa9edcd23e (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
#!/usr/bin/env bats

# Tests data.path settings which in the past have misbehaving, leaking the
# default.data.path setting into the data.path even when it doesn't belong.

# WARNING: This testing file must be executed as root and can
# dramatically change your system. It removes the 'elasticsearch'
# user/group and also many directories. Do not execute this file
# unless you know exactly what you are doing.

# The test case can be executed with the Bash Automated
# Testing System tool available at https://github.com/sstephenson/bats
# Thanks to Sam Stephenson!

# Licensed to Elasticsearch under one or more contributor
# license agreements. See the NOTICE file distributed with
# this work for additional information regarding copyright
# ownership. Elasticsearch licenses this file to you under
# the Apache License, Version 2.0 (the "License"); you may
# not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
#    http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing,
# software distributed under the License is distributed on an
# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
# KIND, either express or implied.  See the License for the
# specific language governing permissions and limitations
# under the License.

# Load test utilities
load $BATS_UTILS/packages.bash
load $BATS_UTILS/tar.bash
load $BATS_UTILS/utils.bash

@test "[BAD data.path] install package" {
    clean_before_test
    skip_not_dpkg_or_rpm
    install_package
}

@test "[BAD data.path] setup funny path.data in package install" {
    skip_not_dpkg_or_rpm
    local temp=`mktemp -d`
    chown elasticsearch:elasticsearch "$temp"
    echo "path.data: [$temp]" > "/etc/elasticsearch/elasticsearch.yml"
}

@test "[BAD data.path] start installed from package" {
    skip_not_dpkg_or_rpm
    start_elasticsearch_service green
}

@test "[BAD data.path] check for bad dir after starting from package" {
    skip_not_dpkg_or_rpm
    assert_file_not_exist /var/lib/elasticsearch/nodes
}

@test "[BAD data.path] install tar" {
    clean_before_test
    install_archive
}

@test "[BAD data.path] setup funny path.data in tar install" {
    local temp=`mktemp -d`
    chown elasticsearch:elasticsearch "$temp"
    echo "path.data: [$temp]" > "/tmp/elasticsearch/config/elasticsearch.yml"
}

@test "[BAD data.path] start installed from tar" {
    start_elasticsearch_service green "" "-Edefault.path.data=/tmp/elasticsearch/data"
}

@test "[BAD data.path] check for bad dir after starting from tar" {
    assert_file_not_exist "/tmp/elasticsearch/data/nodes"
}