Skip to content

Commit b67cc8b

Browse files
samcrangchrisfarms
authored and
chrisfarms
committed
Enable Redis and add acceptance tests
1 parent da42a43 commit b67cc8b

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

48 files changed

+8082
-2
lines changed

config/service-brokers/compose/catalog.json

Lines changed: 32 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,38 @@
3030
"databaseType": "mongodb"
3131
}
3232
}]
33-
},{
33+
}, {
34+
"id": "1356eeeb-7c5d-4d9d-9a04-c035a2c709b3",
35+
"name": "redis",
36+
"bindable": true,
37+
"description": "Redis instance",
38+
"requires": [],
39+
"tags": [
40+
"redis",
41+
"compose"
42+
],
43+
"metadata": {
44+
"displayName": "Redis",
45+
"imageUrl": "https://redis.io/images/redis-logo.svg",
46+
"longDescription": "Redis instance",
47+
"providerDisplayName": "GOV.UK PaaS",
48+
"documentationUrl": "https://compose.com/databases/redis",
49+
"supportUrl": "https://www.cloud.service.gov.uk/support.html"
50+
},
51+
"plans": [{
52+
"id": "a8574a4b-9c6c-40ea-a0df-e9b7507948c8",
53+
"name": "tiny",
54+
"description": "256MB Storage / 256MB RAM",
55+
"compose": {
56+
"units": 1,
57+
"databaseType": "redis"
58+
},
59+
"metadata": {
60+
"displayName": "Redis Tiny",
61+
"bullets": []
62+
}
63+
}]
64+
}, {
3465
"id": "6e9202f2-c2e1-4de8-8d4a-a8c898fc2d8c",
3566
"name": "elasticsearch",
3667
"bindable": true,

platform-tests/example-apps/healthcheck/Gopkg.lock

Lines changed: 13 additions & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

platform-tests/example-apps/healthcheck/main.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@ func main() {
1818
http.HandleFunc("/db", dbHandler)
1919
http.HandleFunc("/mongo-test", mongoHandler)
2020
http.HandleFunc("/elasticsearch-test", elasticsearchHandler)
21+
http.HandleFunc("/redis-test", redisHandler)
2122
err := http.ListenAndServe(addr, nil)
2223
if err != nil {
2324
log.Fatal(err)
Lines changed: 53 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,53 @@
1+
package main
2+
3+
import (
4+
"fmt"
5+
"net/http"
6+
7+
"github.com/garyburd/redigo/redis"
8+
"github.com/pkg/errors"
9+
)
10+
11+
func redisHandler(w http.ResponseWriter, r *http.Request) {
12+
err := testRedisConnection()
13+
if err != nil {
14+
http.Error(w, err.Error(), http.StatusInternalServerError)
15+
return
16+
}
17+
18+
writeJson(w, map[string]interface{}{
19+
"success": true,
20+
})
21+
}
22+
23+
func testRedisConnection() error {
24+
var credentials struct {
25+
URI string `json:"uri"`
26+
}
27+
28+
err := getVCAPServiceCredentials("redis", &credentials)
29+
if err != nil {
30+
return errors.Wrap(err, "failed to parse VCAP_SERVICES")
31+
}
32+
33+
conn, err := redis.DialURL(credentials.URI)
34+
if err != nil {
35+
return errors.Wrap(err, "failed to connect to Redis")
36+
}
37+
defer conn.Close()
38+
39+
_, err = conn.Do("SET", "hello", "world")
40+
if err != nil {
41+
return errors.Wrap(err, "failed to SET")
42+
}
43+
44+
redisValue, err := redis.String(conn.Do("GET", "hello"))
45+
if err != nil {
46+
return errors.Wrap(err, "failed to GET")
47+
}
48+
if redisValue != "world" {
49+
return fmt.Errorf("expected \"world\" got %s", redisValue)
50+
}
51+
52+
return nil
53+
}

platform-tests/example-apps/healthcheck/vendor/github.com/garyburd/redigo/.github/CONTRIBUTING.md

Lines changed: 5 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

platform-tests/example-apps/healthcheck/vendor/github.com/garyburd/redigo/.github/ISSUE_TEMPLATE.md

Lines changed: 1 addition & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

platform-tests/example-apps/healthcheck/vendor/github.com/garyburd/redigo/.travis.yml

Lines changed: 18 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

platform-tests/example-apps/healthcheck/vendor/github.com/garyburd/redigo/LICENSE

Lines changed: 175 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

platform-tests/example-apps/healthcheck/vendor/github.com/garyburd/redigo/README.markdown

Lines changed: 50 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)