import (
        "msb2pilot/log"
+       "msb2pilot/models"
        "msb2pilot/util"
+       "os"
        "path/filepath"
 
        "github.com/hashicorp/consul/api"
 }
 
 func getConsulAddress(path string) string {
+       res := os.Getenv(models.EnvConsulAddress)
+       if res != "" {
+               return res
+       }
+
        cfg, err := loadCfgInfo(path)
        if err != nil {
                log.Log.Error("load consul config info error", err)
 
 package consul
 
 import (
+       "msb2pilot/models"
+       "os"
        "testing"
 )
 
 func TestSetConsulAddress(t *testing.T) {
        cases := []struct {
-               path, want string
+               env, path, want string
        }{
                {
+                       env:  "testEnv",
+                       path: "",
+                       want: `testEnv`,
+               },
+               {
+                       env:  "",
                        path: cfgFilePath,
                        want: `http://127.0.0.1:8500`,
                },
                {
+                       env:  "testEnvWithPath",
+                       path: cfgFilePath,
+                       want: `testEnvWithPath`,
+               },
+               {
+                       env:  "",
                        path: ``,
                        want: `http://localhost:8500`,
                },
                {
+                       env:  "",
                        path: `controller.go`,
                        want: `http://localhost:8500`,
                },
        }
 
+       oldEnv := os.Getenv(models.EnvConsulAddress)
+
        for _, cas := range cases {
+               os.Setenv(models.EnvConsulAddress, cas.env)
+
                res := getConsulAddress(cas.path)
                if res != cas.want {
                        t.Errorf("getConsulAddress() => want %s, got %s", cas.want, res)
                }
        }
+
+       os.Setenv(models.EnvConsulAddress, oldEnv)
 }
 
 func TestLoadCfgInfo(t *testing.T) {
 
--- /dev/null
+/**
+ * Copyright (c) 2018 ZTE Corporation.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * and the Apache License 2.0 which both accompany this distribution,
+ * and are available at http://www.eclipse.org/legal/epl-v10.html
+ * and http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Contributors:
+ *     ZTE - initial Project
+ */
+package models
+
+const (
+       EnvConsulAddress = "ConsulAddress" //http://localhost:8500
+)