saltstack / saltstack/salt

[E2E Test] Add E2E test for using external pillars

Open
#64,690 0 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Tests
Dominant language
Python
Stars
15.7k
Forks
5.6k
Avg merge
2d 44m
Merged PRs (30d)
80

Description

Add E2E test for the following scenario:

  1. Setup a master with the following configuration:
ext_pillar:
  - cmd_json: 'echo {\"arg\":\"value\"}'
  - http_json:
      url: http://localhost/%s.html
  1. Setup a webserver (In the test suite you can use the webserver class from tests/support/helpers.py
  2. Add an html page with the name of test minion. For example: minion.html. And the contents of the html file are:
{"minion": "supersecret"}
  1. Create SLS File with the following contents:
{% set minion_id = grains.get("id") %}
{% set password = pillar.get(minion_id) %}
{% set arg = pillar.get("arg") %}

add_secret:
  file.managed:
    - name: /tmp/conf_file
    - contents: |
        target: {{ minion_id }}
        password: {{ password }}
        args: {{ arg }}
  1. Run the state and ensure the contents of the file are added correctly.
(py-3.10)  ch3ll@megan-precision5550  ~/git/salt   add_pillar_docs ±  salt 'poc-minion' state.apply ext_pillar
poc-minion:
----------
          ID: add_secret
    Function: file.managed
        Name: /tmp/conf_file
      Result: True
     Comment: File /tmp/conf_file is in the correct state
     Started: 12:24:46.662342
    Duration: 20.081 ms
     Changes:   

Summary for poc-minion
------------
Succeeded: 1
Failed:    0
------------
Total states run:     1
Total run time:  20.081 ms
(py-3.10)  ch3ll@megan-precision5550  ~/git/salt   add_pillar_docs ±  cat /tmp/conf_file 
target: poc-minion
password: supersecret
args: value
  1. Update the external pillar data by updating the minions.html site with a new password.
{"poc-minion": "new-supersecret"}
  1. Run the state again and ensure the contents of the file have changed correctly.
(py-3.10)  ch3ll@megan-precision5550  ~/git/salt   add_pillar_docs ±  salt 'poc-minion' state.apply ext_pillar      
poc-minion:
----------
          ID: add_secret
    Function: file.managed
        Name: /tmp/conf_file
      Result: True
     Comment: File /tmp/conf_file updated
     Started: 12:25:50.439871
    Duration: 22.172 ms
     Changes:   
              ----------
              diff:
                  --- 
                  +++ 
                  @@ -1,3 +1,3 @@
                   target: poc-minion
                  -password: supersecret
                  +password: new-supersecret
                   args: value

Summary for poc-minion
------------
Succeeded: 1 (changed=1)
Failed:    0
------------
Total states run:     1
Total run time:  22.172 ms
(py-3.10)  ch3ll@megan-precision5550  ~/git/salt   add_pillar_docs ±  cat /tmp/conf_file                            
target: poc-minion
password: new-supersecret
args: value

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start with the E2E test structure and the webserver helper in tests/support/helpers.py. Set up the master with cmd_json and http_json external pillars, serve the minion data, and apply the SLS scenario. Done means the managed file contains the initial external values and reflects the updated password after the web content changes.

Written by the indexing model from the issue text.

Assessment

Tech stack
python
Domain
devops, testing-qa
Issue type
Feature
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
48/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.