Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
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
75 changes: 75 additions & 0 deletions .github/workflows/pr-elasticsearch-tests.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,75 @@
name: Elasticsearch Tests

on:
pull_request:

jobs:
leia-tests:
runs-on: ${{ matrix.os }}
env:
TERM: xterm
strategy:
matrix:
leia-tests:
- examples/elasticsearch-6.5
- examples/elasticsearch-6.8
- examples/elasticsearch-7.2
# - examples/elasticsearch-7.5
# - examples/elasticsearch-7.7
# - examples/elasticsearch-7.9
# - examples/elasticsearch-7.10
lando-versions:
- edge
os:
- ubuntu-20.04
node-version:
- '14'

steps:
# Install deps and cache
- name: Checkout code
uses: actions/checkout@v2
- name: Install node ${{ matrix.node-version }}
uses: actions/setup-node@v2
with:
node-version: ${{ matrix.node-version }}
cache: yarn
- name: Install Yarn dependencies
run: yarn install --prefer-offline --frozen-lockfile

# This block should eventually become use lando/actions-hyperdrive@v2
- name: Verify Docker dependencies
run: |
docker --version | grep "20.10."
docker-compose --version | grep "1.29."
- name: Grab latest edge Lando CLI
run: |
sudo curl -fsSL -o /usr/local/bin/lando "https://files.lando.dev/cli/lando-linux-x64-${{ matrix.lando-versions }}"
sudo chmod +x /usr/local/bin/lando
- name: Move in lando config appropriate for testing
run: |
mkdir -p ~/.lando/cache
cp -f actions-lando-config.yml ~/.lando/config.yml
echo false > ~/.lando/cache/report_errors
lando --clear
- name: Verify Lando works and we are dogfooding this plugin for tests
run: |
lando version
lando config --path plugins | grep platformsh | grep /home/runner/work/platformsh/platformsh || echo "::error:: Not dogfooding this plugin correctly! "
cd ${{ matrix.leia-tests }}
lando config --path plugins | grep platformsh | grep dir | grep /home/runner/work/platformsh/platformsh || echo "::error:: Not dogfooding this plugin correctly! "

# This block should eventually become use lando/actions-leia@v2
# @NOTE? Do we want a way for our leia-action to configure apparmor since
# this might break a whole bunch of tests? or is this literally just a thing
# for the platform.sh mysql/mariadb container?
- name: Configure apparmor
run: |
set -x
sudo apt-get remove mysql-server --purge
sudo apt-get install apparmor-profiles
sudo apparmor_parser -R /etc/apparmor.d/usr.sbin.mysqld
- name: Run leia tests
shell: bash
run: yarn leia "./${{ matrix.leia-tests }}/README.md" -c 'Destroy tests' --stdin --shell bash

20 changes: 20 additions & 0 deletions examples/elasticsearch-6.5/.editorconfig
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
# Drupal editor configuration normalization
# @see http://editorconfig.org/

# This is the top-most .editorconfig file; do not search in parent directories.
root = true

# All files.
[*]
end_of_line = LF
indent_style = space
indent_size = 4
charset = utf-8
trim_trailing_whitespace = true
insert_final_newline = true

[composer.{json,lock}]
indent_size = 4

[.platform.app.yaml]
indent_size = 4
11 changes: 11 additions & 0 deletions examples/elasticsearch-6.5/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
vendor
files
data
private
.platform/local

*.sql
*.tar.gz
*.tar

.DS_Store
10 changes: 10 additions & 0 deletions examples/elasticsearch-6.5/.lando.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
name: lando-platformsh-elasticsearch-6.5
recipe: platformsh
config:
id: DISCONNECTED


# This is important because it lets lando know to test against the plugin in this repo
# DO NOT REMOVE THIS!
plugins:
"@lando/platformsh": ./../../
12 changes: 12 additions & 0 deletions examples/elasticsearch-6.5/.platform.app.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
name: app
type: "php:7.3"
build:
flavor: composer
web:
locations:
"/":
root: "."
passthru: "/index.php"
relationships:
elasticsearch: "searchelastic:elasticsearch"
elasticsearch-plugin: "searchelastic-plugin:elasticsearch"
8 changes: 8 additions & 0 deletions examples/elasticsearch-6.5/.platform/routes.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
# The routes of the project.
#
# Each route describes how an incoming URL is going
# to be processed by Platform.sh.

"https://{default}/":
type: upstream
upstream: "app:http"
7 changes: 7 additions & 0 deletions examples/elasticsearch-6.5/.platform/services.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
searchelastic:
type: elasticsearch:6.5
searchelastic-plugin:
type: elasticsearch:6.5
configuration:
plugins:
- mapper-size
74 changes: 74 additions & 0 deletions examples/elasticsearch-6.5/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,74 @@
Platform.sh elasticsearch 6.5 Example
=================================

This example exists to test this plugin's implementation of Platform.sh's `elasticsearch:6.5` service.

* [`elasticsearch:6.5`](https://docs.platform.sh/configuration/services/elasticsearch.html)

Start up tests
--------------

Run the following commands to get up and running with this example.

```bash
# Should poweroff
lando poweroff

# Should start up successfully
lando start
```

Verification commands
---------------------

Run the following commands to validate things are rolling as they should.

```bash
# Should have the expected platformsh containers and images
docker ps --filter label=com.docker.compose.project=landoplatformshelasticsearch65 | grep docker.registry.platform.sh/php-7.3 | grep landoplatformshelasticsearch65_app_1
docker ps --filter label=com.docker.compose.project=landoplatformshelasticsearch65 | grep docker.registry.platform.sh/elasticsearch-6.5 | grep landoplatformshelasticsearch65_searchelastic_1

# Should be running all application containers as web
lando ssh -s app -c "id" | grep web

# Should have the platform cli in all application containers
lando ssh -s app -c "platform -V"

# Should be running the correct php version
lando ssh -s app -c "php --version" | grep 7.3.

# Should be running all elasticsearch containers as elasticsearch
lando ssh -s searchelastic -c "id" | grep elasticsearch

# Should be running the correct elasticsearch versions
lando ssh -s searchelastic -c "curl -XGET 'http://localhost:9200'" | grep 6.5

# Should be able to connect to elasticsearch from the application containers
lando ssh -s app -c "curl localhost/esearch.php" | grep "Barbara Liskov"

# Should be running the correct elasticsearch versions (plugin service)
lando ssh -s searchelastic-plugin -c "curl -XGET 'http://localhost:9200'" | grep 6.5

# Should be able to enable the _size field for mapper-size plugin
lando ssh -s searchelastic-plugin -c "curl -X PUT 'localhost:9200/my_index?pretty' -H 'Content-Type:application/json' -d'{\"mappings\": {\"_doc\": {\"_size\": {\"enabled\": true}}}}'"

# Should be able to add a doc to the ES index
lando ssh -s searchelastic-plugin -c "curl -X PUT 'localhost:9200/my-index/_doc/1?pretty' -H 'Content-Type: application/json' -d'{\"text\": \"This is a document\"}'"

# Should see _size field when querying ES index.
lando ssh -s searchelastic-plugin -c "curl -X GET 'localhost:9200/my_index/_search?pretty' -H 'Content-Type: application/json' -d '{ \"query\": { \"range\": { \"_size\": { \"gt\": 10 } } }, \"aggs\": { \"sizes\": { \"terms\": { \"field\": \"_size\", \"size\": 10 } } }, \"sort\": [ { \"_size\": { \"order\": \"desc\" } } ], \"script_fields\": { \"size\": { \"script\": \"doc[\\u0027_size\\u0027]\" } }}'" | grep sizes

```

Destroy tests
-------------

Run the following commands to trash this app like nothing ever happened.

```bash
# Should be able to destroy our app
lando destroy -y

# Should poweroff
lando poweroff
```
16 changes: 16 additions & 0 deletions examples/elasticsearch-6.5/composer.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
{
"name": "lando/platformsh-elasticsearch-6.5",
"description": "A basic application to test Lando's implementation of platformsh's elasticsearch 6.5 service.",
"license": "MIT",
"type" : "project",
"require": {
"php": ">7.2",
"platformsh/config-reader": "~2.0",
"elasticsearch/elasticsearch": "~6.5.0"
},
"autoload": {
"psr-4": {
"App\\": "src/"
}
}
}
Loading