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

fix(citest): Dont perform superfluous platform initializations #1529

Merged
merged 1 commit into from
Apr 3, 2017

Conversation

ewiseblatt
Copy link

@rguthriemsft When the dependent PR goes in, you should take things you may be adding into spinnaker_test_scenario.py and instead add them to an azure_support.py so the only change to spinnaker_test_scenario is adding AzureScenarioSupport to the PLATFORM_SUPPORT_CLASSES. This PR should fix the other issues made me aware of so your workarounds should not be needed anymore.

@Roshan2017 I migrated all the OpenStack changes, but I did not test them because I still havent gotten around to reinstalling openstack. Could you test this for me?

@jtk54 or @lwander Please review.


This CL refactors SpinnakerTestScenario so that bindings requiring
platform interrogation are not performed until they are needed.
This allows tests to be decoupled from platforms they are not using.

This also refactors the SpinnakerTestScenario so that the platform
specific code is factored out into an encapsulated support module.
This should make it easier to add and maintain platforms, as
well as simplify what's going on.

Most of this PR is moving existing code from spinnaker_scenario_test.py into individual _support.py modules. The interface has a method for initializing the argparser (used before the class is constructed), initializing the bindings (used on the instance after constructed) and creating the observer for that platform. The appropriate code blocks were moved from spinnaker_testing without any major change except as follows:

  1. The observers are not constructed until the property is referenced. So if the observer is never referenced, it will never be instantiated. Presumably if one is not needed it will not be referenced.

  2. Binding values derived from interrogating the platform if not otherwise available are added using lazy initializers so that they will not incur the work if they are never needed. This also decouples the platform initialization from tests that do not need them.

  3. I added a SPINNAKER__ENABLED binding to easily check if a platform is enabled or not rather than merely seeing if there is an account configured for it. This is added in the base support class.

This PR depends on google/citest#252 which is not yet approved.

This CL refactors SpinnakerTestScenario so that bindings requiring
platform interrogation are not performed until they are needed.
This allows tests to be decoupled from platforms they are not using.

This also refactors the SpinnakerTestScenario so that the platform
specific code is factored out into an encapsulated support module.
This should make it easier to add and maintain new platforms as
well as simplify what's going on.
builder.add_argument(
'--test_aws_vpc_id',
default=defaults.get('TEST_AWS_VPC_ID', None),
help='Default AWS VpcId to use when creating test resources.')
Copy link
Member

Choose a reason for hiding this comment

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

Why not "VPC ID" rather than "VpcId"?

Copy link
Author

Choose a reason for hiding this comment

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

VpcId is the identifier in the AWS schemas. Not that it matters.

@lwander
Copy link
Member

lwander commented Apr 1, 2017

I'm missing something - where is the loading from lazy bindings defined?

@ewiseblatt
Copy link
Author

ewiseblatt commented Apr 1, 2017 via email

@lwander
Copy link
Member

lwander commented Apr 2, 2017

What I meant was I see you call bindings.add_lazy_initializer, and I see you read properties from the bindings that were added with that method, but I didn't see where the logic for that lives.

@ewiseblatt
Copy link
Author

ewiseblatt commented Apr 3, 2017 via email

Copy link
Member

@lwander lwander left a comment

Choose a reason for hiding this comment

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

Ah, I see, LGTM

@Roshan2017
Copy link
Contributor

@ewiseblatt Okay! I will test and will let you know.

@ewiseblatt
Copy link
Author

ewiseblatt commented Apr 3, 2017 via email

Copy link
Contributor

@jtk54 jtk54 left a comment

Choose a reason for hiding this comment

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

LGTM.

@ewiseblatt ewiseblatt merged commit 6075c8f into spinnaker:master Apr 3, 2017
@ewiseblatt ewiseblatt deleted the refactor_scenario branch April 3, 2017 17:31
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.

None yet

4 participants