Skip to content

Commit

Permalink
Fix app_management_test at HEAD (#448)
Browse files Browse the repository at this point in the history
See #447. Tested with:

```
bazel test //src/app_charts/base:app_management_test
USE_BAZEL_VERSION=b084956e23a6e50e35fe8886d0f3f7e05f718155 bazel test //src/app_charts/base:app_management_test
```
  • Loading branch information
drigz authored Sep 25, 2024
1 parent c66169c commit 25b3d7b
Show file tree
Hide file tree
Showing 4 changed files with 28 additions and 8 deletions.
8 changes: 8 additions & 0 deletions deploy.sh
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,14 @@ if is_source_install; then
# Not using bazel run to not clobber the bazel-bin dir
TERRAFORM="${DIR}/bazel-out/../../../external/_main~non_module_deps~hashicorp_terraform/terraform"
HELM_COMMAND="${DIR}/bazel-out/../../../external/_main~non_module_deps~kubernetes_helm/helm"
if [[ ! -x "${TERRAFORM}" ]] ; then
TERRAFORM="${DIR}/bazel-out/../../../external/+non_module_deps+hashicorp_terraform/terraform"
HELM_COMMAND="${DIR}/bazel-out/../../../external/+non_module_deps+kubernetes_helm/helm"
fi
if [[ ! -x "${TERRAFORM}" ]] ; then
echo >&2 "Failed to locate terraform in ${DIR}."
exit 1
fi
# To avoid a dependency on the host's glibc, we build synk with pure="on".
# Because this is a non-default build configuration, it results in a separate
# subdirectory of bazel-out/, which is not as easy to hardcode as
Expand Down
24 changes: 17 additions & 7 deletions src/app_charts/base/app_management_test.sh
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,17 @@
# See the License for the specific language governing permissions and
# limitations under the License.

HELM="${TEST_SRCDIR}/_main/external/_main~non_module_deps~kubernetes_helm/helm template"
HELM="${TEST_SRCDIR}/_main/external/_main~non_module_deps~kubernetes_helm/helm"
if [[ ! -x "${HELM}" ]] ; then
HELM="${TEST_SRCDIR}/+non_module_deps+kubernetes_helm/helm"
fi
if [[ ! -x "${HELM}" ]] ; then
# If we hit this again, consider using the runfiles library:
# https://github.com/bazelbuild/bazel/blob/master/tools/bash/runfiles/runfiles.bash#L55-L86
echo >&2 "Failed to locate helm in ${TEST_SRCDIR}."
exit 1
fi

CLOUD_BASE="${TEST_SRCDIR}/_main/src/app_charts/base/base-cloud-0.0.1.tgz"
ROBOT_BASE="${TEST_SRCDIR}/_main/src/app_charts/base/base-robot-0.0.1.tgz"

Expand Down Expand Up @@ -55,10 +65,10 @@ function expect_app_not_installed() {
test_passed "application \"${application}\" is not included in template created by \"${command}\""
}

expect_app_installed "${HELM} ${CLOUD_BASE} --set-string app_management=true" "app-rollout-controller"
expect_app_installed "${HELM} ${CLOUD_BASE} --set-string app_management=true" "chart-assignment-controller"
expect_app_not_installed "${HELM} ${CLOUD_BASE} --set-string app_management=false" "app-rollout-controller"
expect_app_not_installed "${HELM} ${CLOUD_BASE} --set-string app_management=false" "chart-assignment-controller"
expect_app_installed "${HELM} template ${CLOUD_BASE} --set-string app_management=true" "app-rollout-controller"
expect_app_installed "${HELM} template ${CLOUD_BASE} --set-string app_management=true" "chart-assignment-controller"
expect_app_not_installed "${HELM} template ${CLOUD_BASE} --set-string app_management=false" "app-rollout-controller"
expect_app_not_installed "${HELM} template ${CLOUD_BASE} --set-string app_management=false" "chart-assignment-controller"

expect_app_installed "${HELM} ${ROBOT_BASE} --set-string app_management=true" "chart-assignment-controller"
expect_app_not_installed "${HELM} ${ROBOT_BASE} --set-string app_management=false" "chart-assignment-controller"
expect_app_installed "${HELM} template ${ROBOT_BASE} --set-string app_management=true" "chart-assignment-controller"
expect_app_not_installed "${HELM} template ${ROBOT_BASE} --set-string app_management=false" "chart-assignment-controller"
2 changes: 1 addition & 1 deletion src/bootstrap/cloud/terraform/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ To run terraform command locally, do:

```shell
bazel build @hashicorp_terraform//:terraform
alias terraform=$(realpath bazel-out/../../../external/_main~non_module_deps~hashicorp_terraform/terraform)
alias terraform=$(realpath bazel-out/../../../external/*hashicorp_terraform/terraform)
cd src/bootstrap/cloud/terraform/
terraform init
```
2 changes: 2 additions & 0 deletions src/go/pkg/kubetest/kubetest.go
Original file line number Diff line number Diff line change
Expand Up @@ -89,6 +89,8 @@ type cluster struct {
// New creates a new test environment.
func New(t *testing.T, cfg Config) *Environment {
e := &Environment{
// When updating Bazel, you'll need to change this to
// "../+non_module_deps+kubernetes_helm/helm".
helmPath: "../_main~non_module_deps~kubernetes_helm/helm",
synkPath: "src/go/cmd/synk/synk_/synk",
t: t,
Expand Down

0 comments on commit 25b3d7b

Please sign in to comment.