@@ -6,7 +6,7 @@ class ConfigServerService
6
6
7
7
LOCAL_CONFIG_SERVER_FILE_NAME = "bosh-config-server-executable"
8
8
9
- INSTALL_DIR = File . join ( 'tmp' , 'integration- config-server' )
9
+ SOURCE_DIR = File . join ( IntegrationSupport :: Constants :: BOSH_REPO_PARENT_DIR , 'config-server' )
10
10
11
11
# Keys and Certs
12
12
CERTS_DIR = File . join ( IntegrationSupport ::Constants ::SANDBOX_ASSETS_DIR , 'config_server' , 'certs' )
@@ -23,7 +23,7 @@ def initialize(port_provider, base_log_path, logger, test_env_number)
23
23
@port = port_provider . get_port ( :config_server_port )
24
24
@logger = logger
25
25
@log_location = "#{ base_log_path } .config-server.out"
26
- @config_server_config_file = File . join ( INSTALL_DIR , "config-server-config#{ test_env_number } .json" )
26
+ @config_server_config_file = File . join ( IntegrationSupport :: Constants :: INTEGRATION_BIN_DIR , "config-server-config#{ test_env_number } .json" )
27
27
@config_server_socket_connector = SocketConnector . new ( 'config-server' , 'localhost' , @port , @log_location , logger )
28
28
29
29
@config_server_process = IntegrationSupport ::Service . new (
@@ -36,12 +36,25 @@ def initialize(port_provider, base_log_path, logger, test_env_number)
36
36
end
37
37
38
38
def self . install
39
- binary_file_path = ENV . fetch ( 'CONFIG_SERVER_BINARY' )
39
+ return if File . exist? ( executable_path )
40
40
41
- FileUtils . mkdir_p ( INSTALL_DIR )
42
- executable_file_path = File . join ( INSTALL_DIR , LOCAL_CONFIG_SERVER_FILE_NAME )
43
- FileUtils . copy ( binary_file_path , executable_file_path )
44
- File . chmod ( 0777 , executable_file_path )
41
+ binary_file_path = self . build_binary
42
+ FileUtils . copy ( binary_file_path , executable_path )
43
+ end
44
+
45
+ def self . executable_path
46
+ File . join ( IntegrationSupport ::Constants ::INTEGRATION_BIN_DIR , LOCAL_CONFIG_SERVER_FILE_NAME )
47
+ end
48
+
49
+ def self . build_binary
50
+ raise "The config-server source must be a sibling to the BOSH Director repo" unless File . exist? ( SOURCE_DIR )
51
+
52
+ Dir . chdir ( SOURCE_DIR ) do
53
+ system ( 'go build .' ) || raise ( 'Unable to build config-server' )
54
+ end
55
+ binary_file_path = File . join ( SOURCE_DIR , 'config-server' )
56
+ raise 'Expected config-server binary to exist, but it does not' unless File . exist? ( binary_file_path )
57
+ binary_file_path
45
58
end
46
59
47
60
def start ( with_trusted_certs )
@@ -68,7 +81,7 @@ def restart(with_trusted_certs)
68
81
private
69
82
70
83
def executable_path
71
- File . join ( INSTALL_DIR , LOCAL_CONFIG_SERVER_FILE_NAME )
84
+ File . join ( IntegrationSupport :: Constants :: INTEGRATION_BIN_DIR , LOCAL_CONFIG_SERVER_FILE_NAME )
72
85
end
73
86
74
87
def setup_config_file ( with_trusted_certs = true )
0 commit comments