This repository has been archived by the owner on Aug 30, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 44
UserData Testcase #232
Open
hspencer77
wants to merge
3
commits into
eucalyptus:testing
Choose a base branch
from
hspencer77:add_userdata_test
base: testing
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
UserData Testcase #232
Changes from 1 commit
Commits
Show all changes
3 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -15,6 +15,8 @@ | |
import os | ||
import re | ||
import random | ||
import StringIO | ||
import difflib | ||
|
||
|
||
class InstanceBasics(EutesterTestCase): | ||
|
@@ -55,16 +57,20 @@ def __init__( self, name="InstanceBasics", credpath=None, region=None, config_fi | |
self.address = None | ||
self.volume = None | ||
self.private_addressing = False | ||
if not user_data: | ||
self.user_data_file = 'testcases/cloud_user/instances/user-data-tests/userdata-max-size.txt' | ||
else: | ||
self.user_data_file = None | ||
if not zone: | ||
zones = self.tester.ec2.get_all_zones() | ||
self.zone = random.choice(zones).name | ||
else: | ||
self.zone = zone | ||
self.reservation = None | ||
self.reservation_lock = threading.Lock() | ||
self.run_instance_params = {'image': self.image, 'user_data': user_data, 'username': instance_user, | ||
'keypair': self.keypair.name, 'group': self.group.name, 'zone': self.zone, | ||
'timeout': self.instance_timeout} | ||
self.run_instance_params = {'image': self.image, 'user_data': user_data, 'user_data_file': self.user_data_file, | ||
'username': instance_user, 'keypair': self.keypair.name, 'group': self.group.name, | ||
'zone': self.zone, 'timeout': self.instance_timeout} | ||
self.managed_network = True | ||
|
||
### If I have access to the underlying infrastructure I can look | ||
|
@@ -238,6 +244,29 @@ def MetaData(self): | |
self.set_reservation(reservation) | ||
return reservation | ||
|
||
def UserData(self): | ||
""" | ||
This case was developed to test the user-data service of an instance for consistency. | ||
This case does a comparison of the user data passed in by the user-data argument to | ||
the data supplied by the user-data service within the instance. Supported | ||
user data formats can be found here: https://cloudinit.readthedocs.org/en/latest/topics/format.html | ||
If this test fails, the test case will error out; logging the results. | ||
The userdata tested is 16K string (maximum size of userdata string defined by AWS) | ||
""" | ||
if not self.reservation: | ||
reservation = self.tester.run_instance(**self.run_instance_params) | ||
else: | ||
reservation = self.reservation | ||
for instance in reservation.instances: | ||
""" | ||
For aesthetics, the user data value is a 16K file thats converted to string then compare, | ||
""" | ||
if self.user_data_file: | ||
with open(self.user_data_file) as user_data_file: | ||
user_data = user_data_file.read() | ||
instance_user_data = StringIO.StringIO(instance.get_userdata()) | ||
self.assertTrue(difflib.SequenceMatcher(None, instance_user_data.getvalue(), user_data), 'Incorrect User Data File') | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Can we just use self.assertEquals(input_string, instance.get_userdata()) |
||
|
||
def DNSResolveCheck(self): | ||
""" | ||
This case was developed to test DNS resolution information for public/private DNS | ||
|
@@ -419,7 +448,7 @@ def ReuseAddresses(self): | |
|
||
### Either use the list of tests passed from config/command line to determine what subset of tests to run | ||
test_list = testcase.args.tests or ["BasicInstanceChecks", "DNSResolveCheck", "Reboot", "MetaData", "ElasticIps", | ||
"MultipleInstances", "LargestInstance", "PrivateIPAddressing", "Churn"] | ||
"UserData", "MultipleInstances", "LargestInstance", "PrivateIPAddressing", "Churn"] | ||
### Convert test suite methods to EutesterUnitTest objects | ||
unit_list = [] | ||
for test in test_list: | ||
|
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can we generate the 16K on the fly rather than adding a static file? You should be able to use self.tester.id_generator(16000)