@@ -22,15 +22,13 @@ package org.apache.comet.objectstore
2222import java .net .URI
2323
2424import scala .collection .mutable
25- import scala .util .Try
2625
2726import org .scalatest .BeforeAndAfterEach
2827import org .scalatest .funsuite .AnyFunSuite
2928import org .scalatest .matchers .should .Matchers
3029
3130import org .apache .hadoop .conf .Configuration
3231
33- import org .apache .comet .CometNativeException
3432import org .apache .comet .rules .CometScanRule
3533
3634class NativeConfigSuite extends AnyFunSuite with Matchers with BeforeAndAfterEach {
@@ -98,23 +96,20 @@ class NativeConfigSuite extends AnyFunSuite with Matchers with BeforeAndAfterEac
9896 test(" validate object store config - invalid provider" ) {
9997 val hadoopConf = new Configuration ()
10098 hadoopConf.set(" fs.s3a.aws.credentials.provider" , " invalid" )
101- val e = intercept[CometNativeException ] {
102- validate(hadoopConf)
103- }
104- assert(e.getMessage.contains(" Unsupported credential provider: invalid" ))
99+ val fallbackReasons = validate(hadoopConf)
100+ val expectedError = " Unsupported credential provider: invalid"
101+ assert(fallbackReasons.exists(_.contains(expectedError)))
105102 }
106103
107104 test(" validate object store config - mixed anonymous providers" ) {
108105 val hadoopConf = new Configuration ()
109106 val provider1 = " com.amazonaws.auth.AnonymousAWSCredentials"
110107 val provider2 = " software.amazon.awssdk.auth.credentials.AnonymousCredentialsProvider"
111108 hadoopConf.set(" fs.s3a.aws.credentials.provider" , Seq (provider1, provider2).mkString(" ," ))
112- val e = intercept[CometNativeException ] {
113- validate(hadoopConf)
114- }
109+ val fallbackReasons = validate(hadoopConf)
115110 val expectedError =
116111 " Anonymous credential provider cannot be mixed with other credential providers"
117- assert(e.getMessage .contains(expectedError))
112+ assert(fallbackReasons.exists(_ .contains(expectedError) ))
118113 }
119114
120115 test(" validity cache" ) {
@@ -125,19 +120,20 @@ class NativeConfigSuite extends AnyFunSuite with Matchers with BeforeAndAfterEac
125120
126121 assert(CometScanRule .configValidityMap.isEmpty)
127122 for (_ <- 0 until 5 ) {
128- assert(Try ( validate(hadoopConf)).isFailure )
123+ assert(validate(hadoopConf).nonEmpty )
129124 assert(CometScanRule .configValidityMap.size == 1 )
130125 }
131126
132127 // set the same providers but in a different order
133128 hadoopConf.set(" fs.s3a.aws.credentials.provider" , Seq (provider2, provider1).mkString(" ," ))
134- assert(Try ( validate(hadoopConf)).isFailure )
129+ assert(validate(hadoopConf).nonEmpty )
135130 assert(CometScanRule .configValidityMap.size == 2 )
136131 }
137132
138- private def validate (hadoopConf : Configuration ): Unit = {
133+ private def validate (hadoopConf : Configuration ): Set [ String ] = {
139134 val path = " s3a://path/to/file.parquet"
140135 val fallbackReasons = mutable.ListBuffer [String ]()
141136 CometScanRule .validateObjectStoreConfig(path, hadoopConf, fallbackReasons)
137+ fallbackReasons.toSet
142138 }
143139}
0 commit comments