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

Add support for ES/Shield 2.3.3 #1

Open
wants to merge 3 commits into
base: master
Choose a base branch
from
Open
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
31 changes: 28 additions & 3 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -1,5 +1,30 @@
language: clojure
lein: lein2
script: lein2 all test
jdk:
- oraclejdk8
language: clojure
lein: lein2

env:
- ES_VERSION=2.3.3

services:
- docker

before_install:
- docker pull elasticsearch:2.3.3
- docker build --rm=true -t elastisch/shield:2.3.3 ./resources/

install:
- docker run -d -p 127.0.0.1:9200:9200 -p 127.0.0.1:9300:9300 --name="shield-test" elastisch/shield:2.3.3
- lein deps

before_script:
- sleep 10

script:
- docker logs shield-test
- curl -vvvv -u es_admin:toor123 http://127.0.0.1:9200/_stats
- lein all test :ci

after_script:
- docker stop shield-test
- docker rm shield-test
60 changes: 60 additions & 0 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,60 @@
## Pre-requisites

The project uses [Leiningen 2](https://leiningen.org) and requires Elasticsearch `1.4.x` or more recent to be running locally.

Make sure you have those two installed and then run tests against all supported Clojure versions using

lein all test


#### Testing with docker

* pull [Elasticsearch](https://hub.docker.com/_/elasticsearch/) image

```
$> docker pull elasticsearch:2.3.3
```
nb! Tag must match with Elasticsearch version in the `project.clj`

* build image to test Elasticsearch Shield

```
cd resources
docker build -f Dockerfile --rm=true -t elastisch/shield:2.3.3 .
```


* run Docker instance

The custom file in the `resources/config/elasticsearch.yml` has all the required settings for full-scale test activated, so you dont have manually tweak them.

```
docker run -d -p 9200:9200 -p 9300:9300 \
--name="shield-test" elasticsearch/shield:2.3.3

curl -u es_admin:toor123 127.0.0.1:9200/_shield
```

* set environment variables

```
$> export ES_URL="http://127.0.0.1:9200" ;;to override URL for the rest-client
$> export ES_CLUSTER_NAME="shield-test" ;; to override default cluster name
$> export ES_CLUSTER_HOST="127.0.0.1" ;; to override default cluster IP address
```

* run tests

```
lein with-profile dev,1.8 test :only clojurewerkz.elastisch.shield-test
lein with-profile dev,1.8 test :native ;;only native client
lein with-profile dev,1.8 test ;;all the tests with clj1.8
```

## Pull Requests

Then create a branch and make your changes on it. Once you are done with your changes and all
tests pass, write a [good, detailed commit message](http://tbaggery.com/2008/04/19/a-note-about-git-commit-messages.html) and submit a pull request on GitHub.

Don't forget to add your changes to `ChangeLog.md` and credit yourself!

21 changes: 21 additions & 0 deletions ChangeLog.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
# Change Log
All notable changes to this project will be documented in this file.

The format is based on [Keep a Changelog](http://keepachangelog.com/)
and this project adheres to [Semantic Versioning](http://semver.org/).

## [Unreleased]
### Added
- TODO


### Changed
- TODO

## [1.0.0-alpha1] - 2016-12-21
### Added
- add drop-in Shield client for `clojurewerkz.elastisch.rest.*` endpoints
- add drop-in Shield client for `clojurewerkz.elastisch.native.*` endpoints
- endpoints to manage Shield roles and users
- endpoints to manage license for Shield
- re-use testsuites from `Elastisch` to improve test-coverate
45 changes: 43 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -38,12 +38,53 @@ With Maven:

## Documentation & Examples

Our documentation site is not yet live, sorry.
```clojure

(require '[clojurewerkz.elastisch.shield :as shield] :reload)

(def shield-user (shield/init-user "es_admin" "toor123"))
(def test-user (shield/init-user "es_test" "qwerty123" ["test"]))

;using rest-client to make authorized calls
(def srconn (shield/connect-rest
"http://127.0.0.1:9200"
(:username shield-user)
(:password shield-user)))

(require '[clojurewerkz.elastisch.rest.admin :as radmin])
(radmin/cluster-health srconn)
(shield/info srconn)


;; manage Shield license
(shield/get-license srconn)
(def lic-file (slurp "resources/elastisch-shield-license-v2.json"))
(shield/update-license srconn lic-file)

;; manage Shield users
(shield/authenticate srconn)
(shield/clear-cache srconn)
(shield/add-user srconn test-user)
(shield/get-users srconn)
(shield/get-users srconn ["es_test"])
(shield/delete-user srconn (:username test-user))


;;using native client to make authorized calls
(def sconn (shield/connect-native [["127.0.0.1" 9300]]
(:username shield-user)
(:password shield-user)
{"cluster.name" "shield-test"}))

(require '[clojurewerkz.elastisch.native.index :as index])
(index/create sconn "testindex")
(index/stats sconn)

```

## Community & Support

[Elasitsch has a mailing
[Elastisch has a mailing
list](https://groups.google.com/forum/#!forum/clojure-elasticsearch). Feel
free to join it and ask any questions you may have.

Expand Down
Loading