Skip to content

Commit

Permalink
Merge pull request TykTechnologies#328 from mvdan/travis-fixes
Browse files Browse the repository at this point in the history
Travis and code cleanups
  • Loading branch information
lonelycode authored Jan 6, 2017
2 parents e4de737 + 6a5b1e6 commit 68ed670
Show file tree
Hide file tree
Showing 15 changed files with 23 additions and 66 deletions.
9 changes: 3 additions & 6 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,7 @@ language: go
sudo: false

go:
- 1.7

- 1.7.x

services:
- redis-server
Expand All @@ -13,11 +12,9 @@ install:
- go get -d -v ./...
- go get -d -v -tags coprocess ./...
- go build -v ./...
- go get golang.org/x/tools/cover


secure: "F3GrvKUQkuIJyzamGM3fw5tTZfYtSCmR+02t5KpqsqkBt1iBM2w4wlZjm+kMzisz8NDVZYfXYDYIqLhfBa4kwSPGgUqxqXAsMhI7hEco3P2FZ6nre0HC0QYhvKks07644KsVq1J2Xn7JMT+61rXKeEk4Ncu1spZCfWbhiJk+MKA="

script:
- go test -v -covermode=count -coverprofile=coverage.out
- go test -tags 'coprocess' -v -covermode=count -coverprofile=coverage.out
- go test -v
- go test -tags coprocess -v
8 changes: 7 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,10 @@
# Develop
# v2.3.1

- Added patch for redis cluster driver - in some docker distributions caused deadlocks by setting REDIGOCLUSTER_SHARDCOUNT to a higher value (default 32)
- Removed config notification info messages (to debug) so Tyk is less chatty
- Added instrumentation for statsd for more in-depth debugging (If TYK_INSTRUMENTATION is set to any value and TYK_GW_STATSDCONNECTIONSTRING is set), optionally set TYK_GW_STATSDPREFIX to a value to enable a prefix.

# v2.3

- It is now possible to separate out the cache data store from the main redis store
- Context Data now includes JWT Claims, claims are added as individual keys as $tyk_context.jwt_claims_CLAIMNAME.
Expand Down
6 changes: 0 additions & 6 deletions api.go
Original file line number Diff line number Diff line change
Expand Up @@ -1290,12 +1290,6 @@ func expandKey(orgID, key string) string {
return fmt.Sprintf("%s%s", orgID, key)
}

func extractKey(orgID, key string) string {
replacementStr := fmt.Sprintf("%s", orgID)
replaced := strings.Replace(key, replacementStr, "", 1)
return replaced
}

func createKeyHandler(w http.ResponseWriter, r *http.Request) {
var responseMessage []byte
code := 200
Expand Down
15 changes: 3 additions & 12 deletions api_definition_manager.go
Original file line number Diff line number Diff line change
Expand Up @@ -1235,9 +1235,6 @@ func (a *APISpec) getVersionFromRequest(r *http.Request) string {
thisVersion := thisURL[:firstParamEndsAt]

return thisVersion

} else {
return ""
}

return ""
Expand All @@ -1262,15 +1259,9 @@ func (a *APISpec) IsThisAPIVersionExpired(versionDef *tykcommon.VersionInfo) boo
return true
}

remaining := time.Since(t)
if remaining < 0 {
// It's in the future, keep going
return false
}

// It's in the past, expire
return true

// It's in the future, keep going
return time.Since(t) >= 0
}

// IsRequestValid will check if an incoming request has valid version data and return a RequestStatus that
Expand All @@ -1284,7 +1275,7 @@ func (a *APISpec) IsRequestValid(r *http.Request) (bool, RequestStatus, interfac
}

// Is the API version expired?
if a.IsThisAPIVersionExpired(versionMetaData) == true {
if a.IsThisAPIVersionExpired(versionMetaData) {
// Expired - fail
return false, VersionExpired, nil
}
Expand Down
2 changes: 1 addition & 1 deletion api_definition_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -162,7 +162,7 @@ func TestExpiredRequest(t *testing.T) {
thisSpec := createDefinitionFromString(sampleDefiniton)

ok, status, _ := thisSpec.IsRequestValid(req)
if ok == true {
if ok {
t.Error("Request should fail as expiry date is in the past!")
}

Expand Down
5 changes: 1 addition & 4 deletions auth_manager.go
Original file line number Diff line number Diff line change
Expand Up @@ -79,10 +79,7 @@ func (b DefaultAuthorisationManager) IsKeyAuthorised(keyName string) (SessionSta
func (b DefaultAuthorisationManager) IsKeyExpired(newSession *SessionState) bool {
if newSession.Expires >= 1 {
//diff := newSession.Expires - time.Now().Unix()
if time.Now().After(time.Unix(newSession.Expires, 0)) {
return true
}
return false
return time.Now().After(time.Unix(newSession.Expires, 0))
}
return false
}
Expand Down
5 changes: 1 addition & 4 deletions handler_websocket.go
Original file line number Diff line number Diff line change
Expand Up @@ -113,8 +113,5 @@ func IsWebsocket(req *http.Request) bool {
}

upgrade := strings.ToLower(strings.TrimSpace(req.Header.Get("Upgrade")))
if upgrade != "websocket" {
return false
}
return true
return upgrade == "websocket"
}
2 changes: 1 addition & 1 deletion host_checker.go
Original file line number Diff line number Diff line change
Expand Up @@ -129,7 +129,7 @@ func (h *HostUptimeChecker) HostReporter() {

case <-h.stopPollingChan:
log.Debug("[HOST CHECKER] Received kill signal")
break
return
}
}
}
Expand Down
8 changes: 2 additions & 6 deletions host_checker_manager.go
Original file line number Diff line number Diff line change
Expand Up @@ -283,12 +283,8 @@ func (hc *HostCheckerManager) IsHostDown(thisUrl string) bool {
}).Debug("Key is: ", PoolerHostSentinelKeyPrefix+u.Host)
_, fErr := hc.store.GetKey(PoolerHostSentinelKeyPrefix + u.Host)

if fErr != nil {
// Found a key, the host is down
return true
}

return false
// Found a key, the host is down
return fErr != nil
}

func (hc *HostCheckerManager) PrepareTrackingHost(checkObject tykcommon.HostCheckObject, APIID string) (HostData, error) {
Expand Down
4 changes: 0 additions & 4 deletions main.go
Original file line number Diff line number Diff line change
Expand Up @@ -637,10 +637,6 @@ func IsRPCMode() bool {
return false
}

func doCopy(from *APISpec, to *APISpec) {
*to = *from
}

type SortableAPISpecListByListen []*APISpec

func (s SortableAPISpecListByListen) Len() int {
Expand Down
6 changes: 1 addition & 5 deletions monitor.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,11 +5,7 @@ import "time"
type Monitor struct{}

func (m Monitor) IsMonitorEnabled() bool {
if config.Monitor.EnableTriggerMonitors {
return true
}

return false
return config.Monitor.EnableTriggerMonitors
}

func (m Monitor) Fire(sessionData *SessionState, key string, triggerLimit float64) {
Expand Down
4 changes: 0 additions & 4 deletions redis_cluster_handler.go
Original file line number Diff line number Diff line change
Expand Up @@ -539,8 +539,6 @@ func (r *RedisClusterStorageManager) StartPubSubHandler(channel string, callback
return v
}
}
return errors.New("Connection closed.")
return nil
}

func (r *RedisClusterStorageManager) Publish(channel string, message string) error {
Expand Down Expand Up @@ -751,7 +749,6 @@ func (r *RedisClusterStorageManager) SetRollingWindow(keyName string, per int64,

return intVal, redVal[1].([]interface{})
}
return 0, []interface{}{}
}

func (r *RedisClusterStorageManager) SetRollingWindowPipeline(keyName string, per int64, value_override string) (int, []interface{}) {
Expand Down Expand Up @@ -817,5 +814,4 @@ func (r *RedisClusterStorageManager) SetRollingWindowPipeline(keyName string, pe

return intVal, redVal[1].([]interface{})
}
return 0, []interface{}{}
}
10 changes: 2 additions & 8 deletions rpc_storage_handler.go
Original file line number Diff line number Diff line change
Expand Up @@ -536,11 +536,8 @@ func (r *RPCStorageHandler) DeleteKeys(keys []string) bool {
}

return ok.(bool)
} else {
log.Debug("RPCStorageHandler called DEL - Nothing to delete")
return true
}

log.Debug("RPCStorageHandler called DEL - Nothing to delete")
return true
}

Expand Down Expand Up @@ -652,10 +649,7 @@ func (r RPCStorageHandler) RemoveFromSet(keyName string, value string) {

func (r RPCStorageHandler) IsAccessError(err error) bool {
if err != nil {
if err.Error() == "Access Denied" {
return true
}
return false
return err.Error() == "Access Denied"
}
return false
}
Expand Down
3 changes: 0 additions & 3 deletions storage_handlers.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@ package main

import (
"encoding/hex"
"errors"
"github.com/garyburd/redigo/redis"
"github.com/spaolacci/murmur3"
"hash"
Expand Down Expand Up @@ -657,11 +656,9 @@ func (r *RedisStorageManager) StartPubSubHandler(channel string, callback func(r

case error:
log.Error("Redis disconnected or error received, attempting to reconnect: ", v)

return v
}
}
return errors.New("Connection closed.")
}

func (r *RedisStorageManager) Publish(channel string, message string) error {
Expand Down
2 changes: 1 addition & 1 deletion version.go
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
package main
var VERSION string = "v2.3.0.45"
var VERSION string = "v2.3.1.2"

0 comments on commit 68ed670

Please sign in to comment.