From d1e939f87b9e3b7d7eb77f18e2189d38ecd26166 Mon Sep 17 00:00:00 2001 From: Jason Yellick Date: Tue, 31 Jan 2017 10:59:00 -0500 Subject: [PATCH] [FAB-1956] Automatically generate orderer template https://jira.hyperledger.org/browse/FAB-1956 It's easy to accidentally let the orderer template get out of sync, so this CR causes the orderer unit tests to update the orderer.template file in common/configtx/test. Other automatic template generation coming in the near future. Change-Id: I5709bff35b724e4751c01d6e04392698afcf9c7a Signed-off-by: Jason Yellick --- orderer/tools/configtemplate/main.go | 13 +++++++----- orderer/tools/configtemplate/main_test.go | 25 +++++++++++++++++++++++ 2 files changed, 33 insertions(+), 5 deletions(-) create mode 100644 orderer/tools/configtemplate/main_test.go diff --git a/orderer/tools/configtemplate/main.go b/orderer/tools/configtemplate/main.go index fb61238fc3d..c134eac5dce 100644 --- a/orderer/tools/configtemplate/main.go +++ b/orderer/tools/configtemplate/main.go @@ -33,11 +33,7 @@ var logger = logging.MustGetLogger("orderer/tools/baseconfig") const defaultOutputFile = "orderer.template" -func main() { - var outputFile string - flag.StringVar(&outputFile, "outputFile", defaultOutputFile, "The file to write the configuration templatee to") - flag.Parse() - +func writeTemplate(outputFile string) { conf := config.Load() flogging.InitFromSpec(conf.General.LogLevel) @@ -54,5 +50,12 @@ func main() { logger.Debugf("Writing configuration to disk") ioutil.WriteFile(outputFile, outputData, 0644) +} + +func main() { + var outputFile string + flag.StringVar(&outputFile, "outputFile", defaultOutputFile, "The file to write the configuration templatee to") + flag.Parse() + writeTemplate(outputFile) } diff --git a/orderer/tools/configtemplate/main_test.go b/orderer/tools/configtemplate/main_test.go new file mode 100644 index 00000000000..227ddedc88a --- /dev/null +++ b/orderer/tools/configtemplate/main_test.go @@ -0,0 +1,25 @@ +/* +Copyright IBM Corp. 2017 All Rights Reserved. + +Licensed under the Apache License, Version 2.0 (the "License"); +you may not use this file except in compliance with the License. +You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + +Unless required by applicable law or agreed to in writing, software +distributed under the License is distributed on an "AS IS" BASIS, +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +See the License for the specific language governing permissions and +limitations under the License. +*/ + +package main + +import ( + "testing" +) + +func TestUpdateTemplate(t *testing.T) { + writeTemplate("../../../common/configtx/test/orderer.template") +}