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

Bashtub Tests Working #4586

Open
wants to merge 7 commits into
base: main
Choose a base branch
from
Open

Bashtub Tests Working #4586

wants to merge 7 commits into from

Conversation

udsamani
Copy link
Contributor

@udsamani udsamani commented Oct 6, 2024

PR Details

  • Fix all tests
  • secret_auth.sh and update.sh tests have been commented due to more complication.

@udsamani udsamani self-assigned this Oct 6, 2024
Comment on lines 17 to 18
cmd.SetOut(os.Stdout)
cmd.Println()
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't think setting the writer here is necessary as we are already doing that in cli/root

bacalhau/cmd/cli/root.go

Lines 136 to 137 in 48dc1a7

rootCmd.SetOut(os.Stdout)
rootCmd.SetErr(os.Stderr)


var bErr bacerrors.Error
if errors.As(err, &bErr) {
// Print error message
cmd.PrintErrln(output.RedStr("Error: ") + bErr.Error())
cmd.Println(output.RedStr("Error: ") + bErr.Error())
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

why are we switching from stderr to stdout for error messages? It doesn't sound the right thing to do

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

As discussed reverting it.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

not reverted yet!

Comment on lines -39 to 28
subject bacalhau config set node.network.type nats
subject ${BACALHAU} config set orchestrator.auth.token kerfuffle
create_node compute
# If this returns successfully, the node started and authenticated.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't think this should pass. We are setting orchestrator.auth.token which secures the orchestrator node, but not setting compute.auth.token. This is making me question if we are actually validating all the tests properly or not

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

not addressed yet!

test/update.sh Outdated
Comment on lines 5 to 10
# testcase_default_config_has_updates_enabled() {
# subject bacalhau config list --output=csv
# assert_equal 0 $status
# assert_not_equal $(echo "$stdout" | grep 'update.checkfrequency' | cut -d, -f2) '0'
# assert_not_equal $(echo "$stdout" | grep 'update.checkfrequency' | cut -d, -f2) ''
# }
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

you shouldn't disable this, but instead check for UpdateConfig.Interval. Also I hate that we have to remember to replace bacalhau with ${BACALHAU} as we will keep forgetting as you have fixed in many places and here as well. Can't we set an alias before running the tests?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is mainly done for local development. Because the local environment in a developers laptop comes into the play. We can come up with an alias, but in that scenario it would be the case that we remember to use that alias.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

by alias I mean directing bacalhau to the development binary and not using a different term. As in alias bacalhau=path/to/built/binary

Comment on lines +1 to 13
# #!bin/bashtub

source bin/bacalhau.sh
# source bin/bacalhau.sh

setup() {
{
bacalhau config set auth.methods "{\"Method\": \"shared_secret\", \"Policy\": {\"Type\": \"ask\", \"PolicyPath\": \"$ROOT/pkg/authn/ask/ask_ns_secret.rego\"}}"
bacalhau config set auth.accesspolicypath "$ROOT/pkg/authz/policies/policy_ns_anon.rego"
} >/dev/null
# setup() {
# {
# bacalhau config set auth.methods "{\"Method\": \"shared_secret\", \"Policy\": {\"Type\": \"ask\", \"PolicyPath\": \"$ROOT/pkg/authn/ask/ask_ns_secret.rego\"}}"
# bacalhau config set auth.accesspolicypath "$ROOT/pkg/authz/policies/policy_ns_anon.rego"
# } >/dev/null

subject 'bacalhau config list | grep auth.methods'
assert_match 'shared_secret' $stdout
# subject 'bacalhau config list | grep auth.methods'
# assert_match 'shared_secret' $stdout

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't think we should skip these tests as they might be indicating an issue with 1.5. Lets work together to debug this

@wdbaruni
Copy link
Member

wdbaruni commented Oct 8, 2024

What is the status of this PR?

@udsamani
Copy link
Contributor Author

udsamani commented Oct 9, 2024

What is the status of this PR?

We can merge this. I have created a separate issue #4609 for auth tests. I need to investigate it more. The main problem is that our framework creates logical separation between tests and not within tests.

So for example before every test we would create a new temp repo and assign it an env variable and after the test a clean up would happen.

However, with Authentication we need logical isolation within a test, meaning when you spin up an orchestrator node it needs to be in one temp directory and the compute node one needs to be in other directory. The framework does not allow that. Also doing simply "export BACALHAU_DIR=$(mktemp -d)" does not work because you then also have to think of clean up. This needs more thought.

Moreover with configuration pattern change now we do need to set the tokens differently for different node. Hence ideally the tests are completely wrong at the moment and the bashtub framework does not support writing test for such use case. So the task is no longer about getting it work now there is added work to support these type of tests.

cc - @wdbaruni @frrist


var bErr bacerrors.Error
if errors.As(err, &bErr) {
// Print error message
cmd.PrintErrln(output.RedStr("Error: ") + bErr.Error())
cmd.Println(output.RedStr("Error: ") + bErr.Error())
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

not reverted yet!

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

Successfully merging this pull request may close these issues.

2 participants