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

Display clouds integration test #11072

Merged

Conversation

SimonRichardson
Copy link
Member

@SimonRichardson SimonRichardson commented Jan 6, 2020

Checklist

  • Checked if it requires a pylibjuju change?
  • Added integration tests for the PR?
  • Added or updated doc.go related to packages changed?
  • Do comments answer the question of why design decisions were made?

Description of change

The following changes introduce the idea of a display clouds integration
tests. Unfortunately it required to change how we handle machine
interactions. For formatting directives such as json or yaml, we never
want to be prompted for anything, we just either want an empty output in
the right format (json being {}) or the data.

Bringing in the changes is the first drive into doing so, the PR doesn't
enforce the changes through out, although it is a first step in doing
so.

Adding redirection of the stderr to /dev/null for machine directives is
pointless, so in the future checking for ctx.IsSerial() should be used.
If the value is true then omitting the information and the noise is
probably the wisest.

See: https://discourse.jujucharms.com/t/cli-serialisable-output-formats/2490

QA steps

Please replace with how we can verify that the change works?

cd tests && ./main.sh cli test_display_clouds

@SimonRichardson
Copy link
Member Author

Copy link
Member

@hmlanigan hmlanigan left a comment

Choose a reason for hiding this comment

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

High level looks good. Some comments related to maintainability. :-)

Provided QA was successful. How do I test the runner formatting changes?

cmd/juju/cloud/list.go Outdated Show resolved Hide resolved
cmd/juju/cloud/list.go Outdated Show resolved Hide resolved
tests/suites/cli/clouds/public-clouds.yaml Show resolved Hide resolved
fi

cp ./tests/suites/cli/clouds/public-clouds.yaml "${TEST_DIR}"/juju/public-clouds.yaml
OUT=$(XDG_DATA_HOME="${TEST_DIR}" juju clouds --local --format=json 2>/dev/null | jq ".[] | select(.defined != \"built-in\")")
Copy link
Member

Choose a reason for hiding this comment

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

Please add an echo of command run, or what's being attempted, for easier debugging and review of test results.

Copy link
Member Author

Choose a reason for hiding this comment

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

Running: ./main.sh -V cli test_desplay_clouds (notice capital V) will tell you exactly what's running... It's easier to see what's going on.

Copy link
Member

Choose a reason for hiding this comment

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

Okay that worked, but not exactly human reading friendly.

Copy link
Member Author

Choose a reason for hiding this comment

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

I wonder if we can do something about that and only trace out certain things, let me think about this.

EOF
)

OUT=$(XDG_DATA_HOME="${TEST_DIR}" juju clouds --all --format=json 2>/dev/null | jq ".[] | select(.defined != \"built-in\")")
Copy link
Member

Choose a reason for hiding this comment

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

Please add an echo of command run, or what's being attempted, for easier debugging and review of test results.

Copy link
Member Author

Choose a reason for hiding this comment

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

Running: ./main.sh -V cli test_desplay_clouds (notice capital V) will tell you exactly what's running... It's easier to see what's going on.

tests/suites/cli/display_clouds.sh Outdated Show resolved Hide resolved
@SimonRichardson
Copy link
Member Author

!!build!!

Copy link
Member

@hmlanigan hmlanigan left a comment

Choose a reason for hiding this comment

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

Looks great! Thank you

@SimonRichardson
Copy link
Member Author

$$merge$$

The following changes introduce the idea of a display clouds integration
tests. Unfortunately it required to change how we handle machine
interactions. For formatting directives such as json or yaml, we never
want to be prompted for anything, we just either want an empty output in
the right format (json being {}) or the data.

Bringing in the changes is the first drive into doing so, the PR doesn't
enforce the changes through out, although it is a first step in doing
so.

Adding redirection of the stderr to /dev/null for machine directives is
pointless, so in the future checking for ctx.IsSerial() should be used.
If the value is true then omitting the information and the noise is
probably the wisest.
The following updates the test to use a real (read as "test") public
cloud. That way it becomes more obvious what the test meant to do.

The changes introduce a fake openstack test cloud with fake urls for the
regions.
The following changes uses a real public cloud rather than some fake
canonical one.
The following adds a reason for the introduction of IsSerial. The basic
idea is that we want to provide a more holistic approach to handling the
formatting directives in the CLI without having to resorting to magic
string checking.
The following updates show-storage so that it's backwards compatible
with the feature tests around it. Essentially the fact that the user
asked for formatted directive of yaml and instead was returned a string
doesn't match what they asked for.

The fix here is to say, return an empty object `{}` (remembering that
yaml is a subset of json) and then correctly outputting the issue to
stderr.

The consumer of the CLI can then either check stderr for issues or
redirect stderr to a file or /dev/null. Either way the consumer gets
valid yaml and you also get the correct information about why it failed.

See: https://discourse.jujucharms.com/t/cli-serialisable-output-formats/2490
The following cleans up the double logging from storage show command. It
seemed ridiculous for every command to return an error and log the same
error. To clean this up, the command package is now again opinionated
correctly and we've followed suit with the commands.
@SimonRichardson
Copy link
Member Author

$$merge$$

@SimonRichardson
Copy link
Member Author

$$merge$$

FAIL: caasoperator_test.go:437: WorkerSuite.TestContainerStart

@jujubot jujubot merged commit ebec0b0 into juju:develop Jan 8, 2020
@SimonRichardson SimonRichardson deleted the display-clouds-integration-test branch July 12, 2021 14:11
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
3 participants