Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

AutoTxConfigTest is looking for configuration files in the wrong place #1

Closed
mathse opened this issue Jun 21, 2018 · 5 comments
Closed
Assignees
Labels

Comments

@mathse
Copy link

mathse commented Jun 21, 2018

my config files are in C:\Tools\AutoTx\conf\

but it searches for C:\Tools\AutoTx\HOSTNAME.xml

PS C:\Tools\AutoTx\conf> ..\AutoTxConfigTest.exe

Trying to parse configuration files from [C:\Tools\AutoTx\]...

System.IO.FileNotFoundException: Could not find file 'C:\Tools\AutoTx\HOSTNAME.xml'.
File name: 'C:\Tools\AutoTx\EDVMD2.xml'
   at System.IO.__Error.WinIOError(Int32 errorCode, String maybeFullPath)
   at System.IO.FileStream.Init(String path, FileMode mode, FileAccess access, Int32 rights, Boolean useRights, FileShare share, Int32 bufferSize, FileOptions options, SECURITY_ATTRIBUTES secAttrs, String msgPath, Boolean bFromProxy, Boolean useLongPath, Boolean checkHost)
   at System.IO.FileStream..ctor(String path, FileMode mode, FileAccess access, FileShare share, Int32 bufferSize)
   at System.Xml.XmlDownloadManager.GetStream(Uri uri, ICredentials credentials, IWebProxy proxy, RequestCachePolicy cachePolicy)
   at System.Xml.XmlUrlResolver.GetEntity(Uri absoluteUri, String role, Type ofObjectToReturn)
   at System.Xml.XmlTextReaderImpl.FinishInitUriString()
   at System.Xml.XmlTextReaderImpl..ctor(String uriStr, XmlReaderSettings settings, XmlParserContext context, XmlResolver uriResolver)
   at System.Xml.XmlReaderSettings.CreateReader(String inputUri, XmlParserContext inputContext)
   at System.Xml.XmlReader.Create(String inputUri, XmlReaderSettings settings, XmlParserContext inputContext)
   at System.Xml.Linq.XElement.Load(String uri, LoadOptions options)
   at ATxCommon.Serializables.ServiceConfig.Deserialize(String path)
   at ATxConfigTest.AutoTxConfigTest.Main(String[] args)
@mathse
Copy link
Author

mathse commented Jun 21, 2018

also config.common.xml needs to be in C:\Tools\AutoTx
but autotxconfigtest.exe does NOT complain about this file is missing

PS C:\Tools\AutoTx\conf> ..\AutoTxConfigTest.exe

Trying to parse configuration files from [C:\Tools\AutoTx\]...

[Error] mandatory parameter missing: <IncomingDirectory>
System.Configuration.ConfigurationErrorsException: mandatory parameter missing: <IncomingDirectory>
   at ATxCommon.Serializables.ServiceConfig.<ValidateConfiguration>g__CheckEmpty|152_0(String value, String name)
   at ATxCommon.Serializables.ServiceConfig.ValidateConfiguration(ServiceConfig c)
   at ATxCommon.Serializables.ServiceConfig.Deserialize(String path)
   at ATxConfigTest.AutoTxConfigTest.Main(String[] args)

@mathse
Copy link
Author

mathse commented Jun 25, 2018

AutoTxConfigTest.exe is look for the config in the same folder as the exe file - not mentioned in the documentation

@mathse mathse closed this as completed Jun 25, 2018
@ehrenfeu
Copy link
Member

Hi @mathse,

thanks for the feedback. Actually, AutoTxConfigText.exe is looking in its own location for the configuration files to check only if nothing is specified on the command line. This is done using a very simple approach in the Main() method as seen here (no smart command line parameter parsing at all!):

var baseDir = AppDomain.CurrentDomain.BaseDirectory;
if (args.Length > 0)
baseDir = args[0];

The tool was created to be used by the Update-Service.ps1 script, where it is used in the Config-IsValid function (see line 384 for the call):

function Config-IsValid {
# Check if the new configuration provided at $UpdPathConfig validates with
# the appropriate "AutoTxConfigTest" binary (either the existing one in the
# service installation directory (if the service binaries won't be updated)
# or the new one at the $UpdPathBinaries location in case the service itself
# will be updated as well).
#
# Returns an array with two elements, the first one being $True in case the
# configuration was successfully validated ($False otherwise) and the second
# one containing the output of the configuration test tool as a string.
Param (
[Parameter(Mandatory=$True)]
[ValidateScript({(Test-Path $_ -PathType Leaf)})]
[String]$ConfigTest,
[Parameter(Mandatory=$True)]
[ValidateScript({(Test-Path $_ -PathType Container)})]
[String]$ConfigPath
)
Write-Verbose "Running [$($ConfigTest) $($ConfigPath)]..."
$Summary = & $ConfigTest $ConfigPath
$Ret = $?
# pipe through Out-String to preserve line breaks:
$Summary = "$("=" * 80)`n$($Summary | Out-String)`n$("=" * 80)"
if ($Ret) {
Log-Debug "Validated config files at [$($ConfigPath)]:`n$($Summary)"
Return $Ret, $Summary
}
Log-Error "Config at [$($ConfigPath)] FAILED VALIDATION:`n$($Summary)"
Return $Ret, $Summary
}

However, the tool is also intended for direct use on the command line. So this should indeed be documented better, and it would definitely be smarter to look in the (new) default location for the config files. Forgot to reflect this when changing the config location and never ran into problems myself since the updater is calling configtest with an explicit path...

Cheers,
Niko

@ehrenfeu ehrenfeu reopened this Jun 25, 2018
@ehrenfeu ehrenfeu self-assigned this Jun 25, 2018
@ehrenfeu ehrenfeu changed the title autotx is looking for host specific configuration files in the wrong place AutoTxConfigTest is looking for configuration files in the wrong place Jun 25, 2018
@ehrenfeu
Copy link
Member

Just for completeness:

AutoTxConfigTest.exe is look for the config in the same folder as the exe file - not mentioned in the documentation

this behavior is explained in the corresponding README here:

By default, configuration files are expected to be in the same directory as the
`AutoTxConfigTest` executable. In that case simply run the tool like this:

If you have any suggestions where else this should be mentioned, please let me know - happy to update the documentation about this!

@ehrenfeu
Copy link
Member

With commit 3752c5e the configuration tester is now looking in the var/ subfolder for the config files by default.

ehrenfeu referenced this issue Jul 25, 2018
Since the executable will be located in the service base directory it
makes most sense to check in the `var` subdir for the config by default.

Fixes #58
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants