[XAPID-1074] rename diagnostic mode, refactor tests
diff --git a/apigeeSync_suite_test.go b/apigeeSync_suite_test.go
index a9370c2..8594d17 100644
--- a/apigeeSync_suite_test.go
+++ b/apigeeSync_suite_test.go
@@ -61,7 +61,7 @@
config.Set(configChangeServerBaseURI, dummyConfigValue)
config.Set(configSnapshotProtocol, "sqlite")
config.Set(configPollInterval, 10*time.Millisecond)
-
+ config.Set(configDiagnosticMode, false)
config.Set(configName, "testhost")
config.Set(configApidClusterId, expectedClusterId)
config.Set(configConsumerKey, "XXXXXXX")
diff --git a/apigee_sync.go b/apigee_sync.go
index 895447c..188e0dd 100644
--- a/apigee_sync.go
+++ b/apigee_sync.go
@@ -37,7 +37,7 @@
*/
func bootstrap() {
if isOfflineMode && apidInfo.LastSnapshot == "" {
- log.Panic("Offline mode requires existent snapshot info in default DB.")
+ log.Panic("Diagnostic mode requires existent snapshot info in default DB.")
}
if apidInfo.LastSnapshot != "" {
diff --git a/apigee_sync_test.go b/apigee_sync_test.go
index a3d4036..3d897d6 100644
--- a/apigee_sync_test.go
+++ b/apigee_sync_test.go
@@ -34,7 +34,7 @@
)
var _ = BeforeEach(func() {
- config.Set(configOnlineMode, offlineMode)
+ config.Set(configDiagnosticMode, true)
config.Set(configApidClusterId, testClusterID)
_initPlugin(apid.AllServices())
apidSnapshotManager = &dummySnapshotManager{}
@@ -54,7 +54,7 @@
})
var _ = AfterEach(func() {
- config.Set(configOnlineMode, "")
+ config.Set(configDiagnosticMode, false)
if wipeDBAferTest {
db, err := dataService.DB()
Expect(err).NotTo(HaveOccurred())
diff --git a/change_test.go b/change_test.go
index 617129d..d7ee964 100644
--- a/change_test.go
+++ b/change_test.go
@@ -20,7 +20,6 @@
. "github.com/onsi/ginkgo"
. "github.com/onsi/gomega"
"net/http/httptest"
- "net/url"
"os"
"time"
)
@@ -155,77 +154,3 @@
})
})
-
-type dummyTokenManager struct {
- invalidateChan chan bool
-}
-
-func (t *dummyTokenManager) getTokenReadyChannel() <-chan bool {
- return nil
-}
-
-func (t *dummyTokenManager) getBearerToken() string {
- return ""
-}
-
-func (t *dummyTokenManager) invalidateToken() error {
- log.Debug("invalidateToken called")
- testMock.passAuthCheck()
- t.invalidateChan <- true
- return nil
-}
-
-func (t *dummyTokenManager) getToken() *OauthToken {
- return nil
-}
-
-func (t *dummyTokenManager) close() {
- return
-}
-
-func (t *dummyTokenManager) getRetrieveNewTokenClosure(*url.URL) func(chan bool) error {
- return func(chan bool) error {
- return nil
- }
-}
-
-func (t *dummyTokenManager) start() {
-
-}
-
-type dummySnapshotManager struct {
- downloadCalledChan chan bool
-}
-
-func (s *dummySnapshotManager) close() <-chan bool {
- closeChan := make(chan bool)
- close(closeChan)
- return closeChan
-}
-
-func (s *dummySnapshotManager) downloadBootSnapshot() {
-
-}
-
-func (s *dummySnapshotManager) storeBootSnapshot(snapshot *common.Snapshot) {
-
-}
-
-func (s *dummySnapshotManager) downloadDataSnapshot() {
- log.Debug("dummySnapshotManager.downloadDataSnapshot() called")
- s.downloadCalledChan <- true
-}
-
-func (s *dummySnapshotManager) storeDataSnapshot(snapshot *common.Snapshot) {
-
-}
-
-func (s *dummySnapshotManager) downloadSnapshot(isBoot bool, scopes []string, snapshot *common.Snapshot) error {
- return nil
-}
-
-func (s *dummySnapshotManager) startOnLocalSnapshot(snapshot string) *common.Snapshot {
- return &common.Snapshot{
- SnapshotInfo: snapshot,
- }
-}
diff --git a/init.go b/init.go
index eb25a95..0cedd9a 100644
--- a/init.go
+++ b/init.go
@@ -22,7 +22,6 @@
"time"
"github.com/30x/apid-core"
- "strings"
)
const (
@@ -35,7 +34,7 @@
configApidClusterId = "apigeesync_cluster_id"
configSnapshotProtocol = "apigeesync_snapshot_proto"
configName = "apigeesync_instance_name"
- configOnlineMode = "apigeesync_online"
+ configDiagnosticMode = "apigeesync_diagnostic_mode"
// special value - set by ApigeeSync, not taken from configuration
configApidInstanceID = "apigeesync_apid_instance_id"
// This will not be needed once we have plugin handling tokens.
@@ -46,10 +45,6 @@
ApigeeSyncEventSelector = "ApigeeSync"
)
-const (
- offlineMode = "offline"
-)
-
var (
/* All set during plugin initialization */
log apid.LogService
@@ -86,7 +81,7 @@
func initConfigDefaults() {
config.SetDefault(configPollInterval, 120*time.Second)
config.SetDefault(configSnapshotProtocol, "sqlite")
- config.SetDefault(configOnlineMode, "online")
+ config.SetDefault(configDiagnosticMode, false)
name, errh := os.Hostname()
if (errh != nil) && (len(config.GetString(configName)) == 0) {
log.Errorf("Not able to get hostname for kernel. Please set '%s' property in config", configName)
@@ -176,8 +171,8 @@
config = services.Config()
initConfigDefaults()
- if strings.EqualFold(config.GetString(configOnlineMode), offlineMode) {
- log.Warn("offline mode!")
+ if config.GetBool(configDiagnosticMode) {
+ log.Warn("Diagnostic mode: will not download changelist and snapshots!")
isOfflineMode = true
}
diff --git a/test_mock_test.go b/test_mock_test.go
index e62d0a5..de2f673 100644
--- a/test_mock_test.go
+++ b/test_mock_test.go
@@ -13,6 +13,11 @@
// limitations under the License.
package apidApigeeSync
+import (
+ "github.com/apigee-labs/transicator/common"
+ "net/url"
+)
+
type dummyChangeManager struct {
pollChangeWithBackoffChan chan bool
}
@@ -26,3 +31,77 @@
func (d *dummyChangeManager) pollChangeWithBackoff() {
d.pollChangeWithBackoffChan <- true
}
+
+type dummyTokenManager struct {
+ invalidateChan chan bool
+}
+
+func (t *dummyTokenManager) getTokenReadyChannel() <-chan bool {
+ return nil
+}
+
+func (t *dummyTokenManager) getBearerToken() string {
+ return ""
+}
+
+func (t *dummyTokenManager) invalidateToken() error {
+ log.Debug("invalidateToken called")
+ testMock.passAuthCheck()
+ t.invalidateChan <- true
+ return nil
+}
+
+func (t *dummyTokenManager) getToken() *OauthToken {
+ return nil
+}
+
+func (t *dummyTokenManager) close() {
+ return
+}
+
+func (t *dummyTokenManager) getRetrieveNewTokenClosure(*url.URL) func(chan bool) error {
+ return func(chan bool) error {
+ return nil
+ }
+}
+
+func (t *dummyTokenManager) start() {
+
+}
+
+type dummySnapshotManager struct {
+ downloadCalledChan chan bool
+}
+
+func (s *dummySnapshotManager) close() <-chan bool {
+ closeChan := make(chan bool)
+ close(closeChan)
+ return closeChan
+}
+
+func (s *dummySnapshotManager) downloadBootSnapshot() {
+
+}
+
+func (s *dummySnapshotManager) storeBootSnapshot(snapshot *common.Snapshot) {
+
+}
+
+func (s *dummySnapshotManager) downloadDataSnapshot() {
+ log.Debug("dummySnapshotManager.downloadDataSnapshot() called")
+ s.downloadCalledChan <- true
+}
+
+func (s *dummySnapshotManager) storeDataSnapshot(snapshot *common.Snapshot) {
+
+}
+
+func (s *dummySnapshotManager) downloadSnapshot(isBoot bool, scopes []string, snapshot *common.Snapshot) error {
+ return nil
+}
+
+func (s *dummySnapshotManager) startOnLocalSnapshot(snapshot string) *common.Snapshot {
+ return &common.Snapshot{
+ SnapshotInfo: snapshot,
+ }
+}