flapdoodle-oss/de.flapdoodle.embed.mongo

DistributionBaseUrl with Windows file path

kentbong9288 opened this issue ยท 11 comments

Hi,

I have set below value to environment variable EMBEDDED_MONGO_ARTIFACTS

C:\tools\embedded-mongo

DistributionBaseUrl as below.

fun distributionUrl(): Transition<DistributionBaseUrl> {
    return Derive.given(SystemEnv::class.java)
        .state(DistributionBaseUrl::class.java)
        .deriveBy { sysEnv: SystemEnv ->
            val url = "file:///" + sysEnv.value()["EMBEDDED_MONGO_ARTIFACTS"]

            DistributionBaseUrl.of(URI.create(url).toString())
        }
}

And, I am getting

Caused by: java.lang.IllegalArgumentException: parts missing: 'file:/c:/tools/embedded-mongo/windows/mongodb-windows-x86_64-5.0.14.zip' != 'file://'+'/c:/tools/embedded-mongo/windows/mongodb-windows-x86_64-5.0.14.zip'

Please advise if any missing part. Thanks.

@kentbong9288 why are you calling DistributionBaseUrl.of(URI.create(url).toString()) instead of DistributionBaseUrl.of(url)?

@michaelmosmann it was just one of my testing part.

Tried DistributionBaseUrl.of(url) , the same error still persists.

@kentbong9288 .. can you provide some more of this error message? Maybe the full stack trace?

btw: you could set the env variable to file:///c:/tools/embedded-mongo without this string concat stuff..

@michaelmosmann below are the log with env variable set to file:///c:/tools/embedded-mongo

Caused by: java.nio.file.InvalidPathException: Illegal char <:> at index 4: file:///c:/tools/embedded-mongo
at java.base/sun.nio.fs.WindowsPathParser.normalize(WindowsPathParser.java:182)
at java.base/sun.nio.fs.WindowsPathParser.parse(WindowsPathParser.java:153)
at java.base/sun.nio.fs.WindowsPathParser.parse(WindowsPathParser.java:77)
at java.base/sun.nio.fs.WindowsPath.parse(WindowsPath.java:92)
at java.base/sun.nio.fs.WindowsFileSystem.getPath(WindowsFileSystem.java:232)
at java.base/java.nio.file.Path.of(Path.java:147)
at java.base/java.nio.file.Paths.get(Paths.java:69)
at de.flapdoodle.embed.mongo.transitions.ExtractFileSet.lambda$null$1(ExtractFileSet.java:64)
at java.base/java.util.Optional.map(Optional.java:260)
at de.flapdoodle.embed.mongo.transitions.ExtractFileSet.lambda$persistentBaseDir$2(ExtractFileSet.java:64)
at java.base/java.util.function.Function.lambda$andThen$1(Function.java:88)
at de.flapdoodle.reverse.transitions.Derive.result(Derive.java:53)
at de.flapdoodle.reverse.TransitionWalker.resolve(TransitionWalker.java:58)
at de.flapdoodle.reverse.TransitionWalker.resolve(TransitionWalker.java:46)
at de.flapdoodle.reverse.TransitionWalker.initState(TransitionWalker.java:180)
... 141 more

Below are the log with env variable set to c:/tools/embedded-mongo

Caused by: java.lang.RuntimeException: rollback after error on transition to State(Archive), successful reached:
State(DownloadCache)=de.flapdoodle.embed.process.store.LocalDownloadCache@6f056fdf,
State(Package)=Package{archiveType=ZIP, fileSet=FileSet{entries=[Entry{type=Executable, destination=mongod.exe, uncompiledMatchingPattern=UncompiledPattern{regex=.*mongod.exe, flags=2}}]}, url=file:///c:/tools/embedded-mongo/windows/mongodb-windows-x86_64-5.0.14.zip},
State(ExtractedFileSetStore)=de.flapdoodle.embed.process.store.ContentHashExtractedFileSetStore@2cbd2385,
State(ProcessArguments)=ProcessArguments([--dbpath, C:\Users{userHome}\AppData\Local\Temp\temp--00b2ee75-f52d-4a69-8eac-2294e8f71a37\mongod-database7492356337227340063, --noauth, --nojournal, --port, 63118, --bind_ip, 127.0.0.1, --syncdelay=0]),
State(ProcessWorkingDir)=ProcessWorkingDir(C:\Users{userHome}\AppData\Local\Temp\temp--00b2ee75-f52d-4a69-8eac-2294e8f71a37\workingDir8257249574499054160),
State(DistributionBaseUrl)=DistributionBaseUrl(file:///c:/tools/embedded-mongo),
State(Distribution)=GenericFeatureAwareVersion{5.0.14}:Platform{operatingSystem=Windows, architecture=X86_64},
State(SupportConfig)=SupportConfig{name=mongod, supportUrl=https://github.com/flapdoodle-oss/de.flapdoodle.embed.mongo/issues, messageOnException=de.flapdoodle.embed.mongo.transitions.ProcessDefaults$$Lambda$1014/0x000001c681a008a0@25727f74},
State(Name)=Name(mongod),
State(PersistentDir)=ImmutablePersistentDir(c:\tools\embedded-mongo),
State(DatabaseDir)=DatabaseDir(C:\Users{userHome}\AppData\Local\Temp\temp--00b2ee75-f52d-4a69-8eac-2294e8f71a37\mongod-database7492356337227340063),
State(TempDir)=ImmutableTempDir(C:\Users{userHome}\AppData\Local\Temp\temp--00b2ee75-f52d-4a69-8eac-2294e8f71a37),
State(Platform)=Platform{operatingSystem=Windows, architecture=X86_64},
State(ProcessConfig)=ProcessConfig{daemonProcess=false, stopTimeoutInMillis=5000},
State(ProcessEnv)=ProcessEnv({}),
State(ProcessOutput)=ProcessOutput{output=de.flapdoodle.embed.process.io.Slf4jStreamProcessor@388c0178, error=de.flapdoodle.embed.process.io.Slf4jStreamProcessor@14db06d0, commands=de.flapdoodle.embed.process.io.NamedOutputStreamProcessor@50e4e803},
State(ProgressListener)=de.flapdoodle.embed.process.io.progress.Slf4jProgressListener@2b14a654,
State(Command)=MongoD,
State(Version)=GenericFeatureAwareVersion{5.0.14},
State(Net)=Net{bindIp=127.0.0.1, port=63118, isIpv6=false},
State(MongodArguments)=MongodArguments{syncDelay=0, useDefaultSyncDelay=false, isVerbose=false, verbosityLevel=1, isQuiet=false, useNoPrealloc=true, useSmallFiles=true, useNoJournal=true, enableTextSearch=false, auth=false, master=false, isConfigServer=false, isShardServer=false, params={}, args={}}
at de.flapdoodle.reverse.TransitionWalker.initState(TransitionWalker.java:190)
at de.flapdoodle.reverse.TransitionWalker.initState(TransitionWalker.java:69)
at de.flapdoodle.reverse.TransitionWalker.initState(TransitionWalker.java:65)
at de.flapdoodle.embed.mongo.spring.autoconfigure.MongodWrapper.start(MongodWrapper.java:45)
at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:77)
at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.base/java.lang.reflect.Method.invoke(Method.java:568)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.invokeCustomInitMethod(AbstractAutowireCapableBeanFactory.java:1850)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.invokeInitMethods(AbstractAutowireCapableBeanFactory.java:1807)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.initializeBean(AbstractAutowireCapableBeanFactory.java:1747)
... 131 more
Caused by: java.lang.IllegalArgumentException: parts missing: 'file:/c:/tools/embedded-mongo/windows/mongodb-windows-x86_64-5.0.14.zip' != 'file://'+'/c:/tools/embedded-mongo/windows/mongodb-windows-x86_64-5.0.14.zip'
at de.flapdoodle.checks.Preconditions.checkArgument(Preconditions.java:32)
at de.flapdoodle.embed.process.store.LocalDownloadCache.resolve(LocalDownloadCache.java:88)
at de.flapdoodle.embed.process.store.LocalDownloadCache.archivePath(LocalDownloadCache.java:56)
at de.flapdoodle.embed.process.store.LocalDownloadCache.archiveFor(LocalDownloadCache.java:61)
at de.flapdoodle.embed.process.transitions.DownloadPackage.result(DownloadPackage.java:126)
at de.flapdoodle.reverse.TransitionWalker.resolve(TransitionWalker.java:58)
at de.flapdoodle.reverse.TransitionWalker.resolve(TransitionWalker.java:46)
at de.flapdoodle.reverse.TransitionWalker.initState(TransitionWalker.java:180)
... 141 more

To further explain, I would like the library to point to the pre-downloaded embedded-mongo binary ZIP, instead of having it downloaded via the net. I have run through flapdoodle-oss/de.flapdoodle.embed.mongo.spring#38, whereby there is mention of the file URL are supported too. That's what I would like to achieve here. Thanks.

@kentbong9288 thanks.. i will have a look

@kentbong9288 .. found the bug .. if the hostname part of the url is empty, it will be shortened to "protocol:/path/foo" instead of "protocol:///path/foo" (file:/c:/path/foo , http:/path/foo) .. made a bugfix, i think i will make an release in the evening (local time).

If release is done, i will notify you.

Thanks:)

@kentbong9288 did release 4.12.1 .. should be in maven central in some hours..

@michaelmosmann tested the fix, it is working perfectly ;)

And would like to check if you are going to update the mongo(4.12.1) dependency in the spring3x package?

Thanks.

@kentbong9288 will do..

@kentbong9288 release done.. will be in maven central in some hours.. i close this issue, reopen if needed:)