#405 Add helper developer scripts
Merged 4 years ago by jkaluza. Opened 4 years ago by jkaluza.
jkaluza/freshmaker helper-scripts  into  master

@@ -0,0 +1,13 @@ 

+ ## Development scripts

+ 

+ This directory contains useful scripts for Freshmaker development.

+ 

+ It is hard to test Freshmaker end to end locally, because it depends

+ on lot of other services. To be able to test some parts locally,

+ we use few scripts stored in this directory.

+ 

+ The scripts are just templates creating instances of particular Freshmaker

+ classes so they can later be used for testing.

+ 

+ The intended use-case is that when developing some feature, you can test

+ the feature using these scripts. You should *not* commit the changed script.

@@ -0,0 +1,28 @@ 

+ #!/usr/bin/python

+ from __future__ import print_function

+ import os

+ import sys

+ from pprint import pprint

+ 

+ # Allow imports from parent directory.

+ sys.path.insert(1, os.path.join(sys.path[0], '..'))

+ 

+ # Set the FRESHMAKER_DEVELOPER_ENV variable.

+ os.environ["FRESHMAKER_DEVELOPER_ENV"] = "1"

+ 

+ from freshmaker.errata import Errata

+ from freshmaker import conf

+ 

+ 

+ if len(sys.argv) != 2:

+     print("Template for testing freshmaker.Errata class")

+     print("Usage: ./errata.py ERRATA_TOOL_SERVER_URL")

+     sys.exit(1)

+ 

+ 

+ conf.errata_tool_server_url = sys.argv[1]

+ errata = Errata()

+ 

+ # Example usage:

+ data = errata.get_builds(42515)

+ pprint(data)

@@ -0,0 +1,77 @@ 

+ #!/usr/bin/python

+ from __future__ import print_function

+ import os

+ import sys

+ from pprint import pprint

+ 

+ # Allow imports from parent directory.

+ sys.path.insert(1, os.path.join(sys.path[0], '..'))

+ 

+ # Set the FRESHMAKER_DEVELOPER_ENV variable.

+ os.environ["FRESHMAKER_DEVELOPER_ENV"] = "1"

+ 

+ from freshmaker.lightblue import LightBlue

+ 

+ 

+ if len(sys.argv) != 4:

+     print("Template for testing freshmaker.Lightblue class")

+     print("Usage: ./lightblue.py LB_SERVER_URL PATH_TO_LB_CLIENT_CERT "

+           "PATH_TO_LB_CLIENT_KEY")

+     sys.exit(1)

+ 

+ 

+ lb = LightBlue(sys.argv[1], sys.argv[2], sys.argv[3], False)

+ 

+ 

+ def example_image_request(lb):

+     query = {

+         "objectType": "containerImage",

+         "query": {

+             "$and": [

+                 {

+                     "field": "repositories.*.tags.*.name",

+                     "op": "=",

+                     "rvalue": "latest"

+                 },

+                 {

+                     "field": "brew.build",

+                     "op": "=",

+                     "rvalue": "s2i-core-container-1-66"

+                 },

+                 {

+                     "field": "parsed_data.files.*.key",

+                     "op": "=",

+                     "rvalue": "buildfile"

+                 }

+             ]

+         },

+         "projection": lb._get_default_projection(include_rpms=False)

+     }

+     images = lb.find_container_images(query)

+     pprint(images)

+ 

+ 

+ def example_repository_request(lb):

+     # Get all the latest container images containing "httpd"

+     query = {

+         "objectType": "containerRepository",

+         "query": {

+             "$and": [

+                 {

+                     "field": "images.*.brew.build",

+                     "op": "=",

+                     "rvalue": "s2i-core-container-1-66"

+                 },

+ 

+             ]

+         },

+         "projection": [

+             {"field": "repository", "include": True},

+         ]

+     }

+     repositories = lb.find_container_repositories(query)

+     pprint(repositories)

+ 

+ 

+ example_image_request(lb)

+ example_repository_request(lb)

file added
+28
@@ -0,0 +1,28 @@ 

+ #!/usr/bin/python

+ from __future__ import print_function

+ import os

+ import sys

+ from pprint import pprint

+ 

+ # Allow imports from parent directory.

+ sys.path.insert(1, os.path.join(sys.path[0], '..'))

+ 

+ # Set the FRESHMAKER_DEVELOPER_ENV variable.

+ os.environ["FRESHMAKER_DEVELOPER_ENV"] = "1"

+ 

+ from freshmaker.pulp import Pulp

+ 

+ 

+ if len(sys.argv) != 4:

+     print("Template for testing freshmaker.Pulp class")

+     print("Usage: ./pulp.py PULP_SERVER_URL PULP_USERNAME PULP_PASSWORD")

+     sys.exit(1)

+ 

+ 

+ pulp = Pulp(sys.argv[1], sys.argv[2], sys.argv[3])

+ 

+ 

+ repo_ids = [

+     "rhel-7-server-release-e2e-test-1-rpms__x86_64"

+ ]

+ pprint(pulp.get_content_set_by_repo_ids(repo_ids))

file modified
+1 -1
@@ -37,7 +37,7 @@ 

  

  [flake8]

  ignore = E501,E731,W504

- exclude = freshmaker/migrations/*,.tox/*,build/*,__pycache__,scripts/print_handlers_md.py,.copr/*,.env

+ exclude = dev_scripts/*,freshmaker/migrations/*,.tox/*,build/*,__pycache__,scripts/print_handlers_md.py,.copr/*,.env

  

  [pytest]

  addopts = --cov=freshmaker

This commit adds the helper scripts I use to test particular parts of Freshmaker locally when developing new features. See readme for more info.

amazing! Can you add some explanation on how to run them, when we should run them, etc?

+1 to what @gnaponie said. Maybe a how to run in the readme would be nice, and maybe more clear on the use cases.

Commit d7a29bf fixes this pull-request

Pull-Request has been merged by jkaluza

4 years ago

Pull-Request has been merged by jkaluza

4 years ago