aglinxinyuan commented on code in PR #6084:
URL: https://github.com/apache/texera/pull/6084#discussion_r3522608786


##########
common/config/src/test/scala/org/apache/texera/common/config/KubernetesConfigSpec.scala:
##########
@@ -0,0 +1,91 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you 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 org.apache.texera.common.config
+
+import org.scalatest.flatspec.AnyFlatSpec
+import org.scalatest.matchers.should.Matchers
+
+/**
+  * Spec for [[KubernetesConfig]]. Reading each value forces resolution from 
kubernetes.conf, so a
+  * renamed or mistyped key surfaces here as a ConfigException. Every value 
except the port number
+  * carries a `${?ENV}` override, so exact-value assertions are guarded on the 
env var being unset.
+  */
+class KubernetesConfigSpec extends AnyFlatSpec with Matchers {
+
+  private def ifUnset(env: String)(assertion: => Any): Unit =
+    if (sys.env.get(env).isEmpty) assertion

Review Comment:
   Good point — `ifUnset` now treats a `${?VAR}` as overridden if it's present 
in either `sys.env` or `sys.props`.



##########
common/config/src/test/scala/org/apache/texera/common/config/KubernetesConfigSpec.scala:
##########
@@ -0,0 +1,91 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you 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 org.apache.texera.common.config
+
+import org.scalatest.flatspec.AnyFlatSpec
+import org.scalatest.matchers.should.Matchers
+
+/**
+  * Spec for [[KubernetesConfig]]. Reading each value forces resolution from 
kubernetes.conf, so a
+  * renamed or mistyped key surfaces here as a ConfigException. Every value 
except the port number
+  * carries a `${?ENV}` override, so exact-value assertions are guarded on the 
env var being unset.
+  */
+class KubernetesConfigSpec extends AnyFlatSpec with Matchers {
+
+  private def ifUnset(env: String)(assertion: => Any): Unit =
+    if (sys.env.get(env).isEmpty) assertion
+
+  "KubernetesConfig.computeUnitPortNumber" should "load the fixed port (no env 
override)" in {
+    KubernetesConfig.computeUnitPortNumber shouldBe 8085
+  }
+
+  "KubernetesConfig string settings" should "resolve to their kubernetes.conf 
defaults" in {
+    ifUnset("KUBERNETES_COMPUTE_UNIT_SERVICE_NAME")(
+      KubernetesConfig.computeUnitServiceName shouldBe 
"workflow-computing-unit-svc"
+    )
+    ifUnset("KUBERNETES_COMPUTE_UNIT_POOL_NAME")(
+      KubernetesConfig.computeUnitPoolName shouldBe 
"texera-workflow-computing-unit"
+    )
+    ifUnset("KUBERNETES_COMPUTE_UNIT_POOL_NAMESPACE")(
+      KubernetesConfig.computeUnitPoolNamespace shouldBe 
"texera-workflow-computing-unit-pool"
+    )
+    ifUnset("KUBERNETES_IMAGE_NAME")(
+      KubernetesConfig.computeUnitImageName shouldBe 
"bobbai/texera-workflow-computing-unit:dev"
+    )
+    ifUnset("KUBERNETES_IMAGE_PULL_POLICY")(
+      KubernetesConfig.computingUnitImagePullPolicy shouldBe "Always"
+    )
+    ifUnset("KUBERNETES_COMPUTING_UNIT_GPU_RESOURCE_KEY")(
+      KubernetesConfig.gpuResourceKey shouldBe "nvidia.com/gpu"
+    )
+  }
+
+  "KubernetesConfig numeric and boolean settings" should "resolve to their 
kubernetes.conf defaults" in {
+    ifUnset("KUBERNETES_COMPUTING_UNIT_ENABLED")(
+      KubernetesConfig.kubernetesComputingUnitEnabled shouldBe false
+    )
+    ifUnset("MAX_NUM_OF_RUNNING_COMPUTING_UNITS_PER_USER")(
+      KubernetesConfig.maxNumOfRunningComputingUnitsPerUser shouldBe 10
+    )
+    KubernetesConfig.maxNumOfRunningComputingUnitsPerUser should be > 0
+  }

Review Comment:
   Fixed — relaxed to `should be >= 0` so an override of 0 (disabling CUs) no 
longer fails; the exact default is still pinned when unset.



##########
common/config/src/test/scala/org/apache/texera/common/config/UserSystemConfigSpec.scala:
##########
@@ -0,0 +1,66 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you 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 org.apache.texera.common.config
+
+import org.scalatest.flatspec.AnyFlatSpec
+import org.scalatest.matchers.should.Matchers
+
+/**
+  * Spec for [[UserSystemConfig]]. Reading each value forces resolution from 
user-system.conf, so a
+  * renamed or mistyped key surfaces here as a ConfigException. Every value 
carries a `${?ENV}`
+  * override, so exact-value assertions are guarded on the env var being unset.
+  */
+class UserSystemConfigSpec extends AnyFlatSpec with Matchers {
+
+  private def ifUnset(env: String)(assertion: => Any): Unit =
+    if (sys.env.get(env).isEmpty) assertion

Review Comment:
   Done — `ifUnset` now checks both `sys.env` and `sys.props`.



##########
common/config/src/test/scala/org/apache/texera/common/config/UserSystemConfigSpec.scala:
##########
@@ -0,0 +1,66 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you 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 org.apache.texera.common.config
+
+import org.scalatest.flatspec.AnyFlatSpec
+import org.scalatest.matchers.should.Matchers
+
+/**
+  * Spec for [[UserSystemConfig]]. Reading each value forces resolution from 
user-system.conf, so a
+  * renamed or mistyped key surfaces here as a ConfigException. Every value 
carries a `${?ENV}`
+  * override, so exact-value assertions are guarded on the env var being unset.
+  */
+class UserSystemConfigSpec extends AnyFlatSpec with Matchers {
+
+  private def ifUnset(env: String)(assertion: => Any): Unit =
+    if (sys.env.get(env).isEmpty) assertion
+
+  "UserSystemConfig" should "resolve every value from user-system.conf" in {
+    // reference each val to force resolution regardless of environment
+    UserSystemConfig.adminUsername should not be null
+    UserSystemConfig.adminPassword should not be null
+    UserSystemConfig.googleClientId should not be null
+    UserSystemConfig.gmail should not be null
+    UserSystemConfig.smtpPassword should not be null
+    UserSystemConfig.projectName should not be null
+    UserSystemConfig.workflowVersionCollapseIntervalInMinutes should be >= 0
+  }
+
+  it should "match the user-system.conf defaults when no env override is set" 
in {
+    ifUnset("USER_SYS_ADMIN_USERNAME")(UserSystemConfig.adminUsername shouldBe 
"texera")
+    ifUnset("USER_SYS_ADMIN_PASSWORD")(UserSystemConfig.adminPassword shouldBe 
"texera")
+    ifUnset("USER_SYS_GOOGLE_CLIENT_ID")(UserSystemConfig.googleClientId 
shouldBe "")
+    ifUnset("USER_SYS_GOOGLE_SMTP_GMAIL")(UserSystemConfig.gmail shouldBe "")
+    ifUnset("USER_SYS_GOOGLE_SMTP_PASSWORD")(UserSystemConfig.smtpPassword 
shouldBe "")
+    ifUnset("USER_SYS_PROJECT_NAME")(UserSystemConfig.projectName shouldBe 
"Texera")
+    ifUnset("USER_SYS_INVITE_ONLY")(UserSystemConfig.inviteOnly shouldBe false)
+    ifUnset("USER_SYS_VERSION_TIME_LIMIT_IN_MINUTES")(
+      UserSystemConfig.workflowVersionCollapseIntervalInMinutes shouldBe 60
+    )
+  }
+
+  it should "return None for appDomain when the domain is blank/unset" in {
+    if (sys.env.get("USER_SYS_DOMAIN").forall(_.trim.isEmpty)) {

Review Comment:
   Done — the appDomain guard now consults both the environment and system 
properties for USER_SYS_DOMAIN.



##########
common/config/src/test/scala/org/apache/texera/common/config/AuthConfigSpec.scala:
##########
@@ -0,0 +1,60 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you 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 org.apache.texera.common.config
+
+import org.scalatest.flatspec.AnyFlatSpec
+import org.scalatest.matchers.should.Matchers
+
+/**
+  * Spec for [[AuthConfig]]. Reading each value forces resolution from 
auth.conf, so a renamed or
+  * mistyped key surfaces here as a ConfigException. Exact-value assertions 
are guarded on the env
+  * override being unset; the random-secret path is exercised directly via 
getRandomHexString.
+  */
+class AuthConfigSpec extends AnyFlatSpec with Matchers {
+
+  "AuthConfig.jwtExpirationMinutes" should "resolve from auth.conf" in {
+    if (sys.env.get("AUTH_JWT_EXPIRATION_IN_MINUTES").isEmpty) {
+      AuthConfig.jwtExpirationMinutes shouldBe 10080
+    } else {
+      AuthConfig.jwtExpirationMinutes should be > 0
+    }
+  }
+
+  "AuthConfig.jwtSecretKey" should "return the configured secret (lowercased) 
and memoize it" in {
+    val first = AuthConfig.jwtSecretKey
+    if (sys.env.get("AUTH_JWT_SECRET").isEmpty) {

Review Comment:
   Done — the secret guard now treats AUTH_JWT_SECRET as overridden if set via 
env or system property.



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to