Skip to content

Commit fcdf872

Browse files
Merge pull request #290 from feichashao/update-testjob-render-docs
Update docs regarding the testjob change
2 parents ffdcce9 + 8ab9751 commit fcdf872

2 files changed

Lines changed: 47 additions & 33 deletions

File tree

‎CLAUDE.md‎

Lines changed: 17 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -16,18 +16,26 @@ This is the OpenShift Dedicated managed-scripts repository, containing scripts e
1616
- `make pyflakes` - Run pyflakes on all .py files
1717

1818
### Testing with Backplane
19-
Scripts are tested using the Backplane CLI:
19+
The `testjob create`, `get`, and `logs` subcommands are deprecated. Use `ocm backplane testjob render` to generate Kubernetes YAML (ServiceAccount, RBAC, and Pod) locally, then apply it with `oc` on a non-production cluster where you have `cluster-admin` access:
2020
```bash
21-
# Connect to stage environment
22-
ocm backplane config set url https://api.stage.backplane.openshift.com
23-
ocm backplane login <stage-cluster-id>
21+
# Log in to a non-production cluster with cluster-admin (normal IDP login; no backplane login needed)
22+
# Replace the API URL with your cluster's.
23+
oc login https://api.example.openshift.com:6443
2424

25-
# Test a script
26-
ocm backplane testjob create [-p var1=val1]
25+
# Render the test job YAML from the script directory (contains metadata.yaml + the script)
26+
# If the script requires parameters, add them with -p (repeatable), e.g. -p var1=value
27+
cd scripts/CEE/new-script
28+
ocm backplane testjob render > test-job.yaml
2729

28-
# Check status and logs
29-
ocm backplane testjob get <job-id>
30-
ocm backplane testjob logs <job-id>
30+
# Review, then apply
31+
oc apply -f test-job.yaml
32+
33+
# Watch / inspect with standard oc (replace the pod name with the one from the previous step)
34+
oc -n openshift-backplane-managed-scripts get pods
35+
oc -n openshift-backplane-managed-scripts logs example-test-job-pod
36+
37+
# Clean up
38+
oc delete -f test-job.yaml
3139
```
3240

3341
## Architecture and Structure

‎CONTRIBUTING.md‎

Lines changed: 30 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ Before creating, testing, or deploying new scripts, ensure you have the followin
2020
1. VPN connectivity
2121
2. [OCM CLI Binary](https://github.com/openshift-online/ocm-cli)
2222
3. [Backplane CLI Binary](https://source.redhat.com/groups/public/sre/wiki/setup_backplane_cli)
23-
4. Access to the [Stage API](https://api.stage.backplane.openshift.com)
23+
4. A non-production cluster where you have `cluster-admin` access to test on
2424

2525
All pre-existing scripts can be found [here](https://github.com/openshift/managed-scripts/tree/main/scripts) for reference.
2626

@@ -60,44 +60,50 @@ All pre-existing scripts can be found [here](https://github.com/openshift/manage
6060

6161
## Testing the Script
6262

63-
1. **Ensure You Are Using the Stage API**
64-
```sh
65-
ocm backplane config set url https://api.stage.backplane.openshift.com
66-
ocm backplane config get url
67-
```
68-
Output:
69-
```
70-
url: https://api.stage.backplane.openshift.com
71-
```
63+
The `ocm backplane testjob create`, `get`, and `logs` commands are deprecated. Use `ocm backplane testjob render` instead, which generates the Kubernetes YAML (ServiceAccount, RBAC, and Pod) for your draft script locally — no backplane API call is made. You then apply it directly with `oc` on a non-production cluster where you have `cluster-admin` access, and use plain `oc` to watch, inspect, and clean up.
7264

73-
2. **Connect to a Stage Cluster**
65+
1. **Log In to a Non-Production Cluster**
66+
- Use a normal IDP login to a non-production cluster where you have `cluster-admin` access (no `ocm backplane login` needed).
67+
- Replace `https://api.example.openshift.com:6443` with your cluster's API URL.
7468
```sh
75-
ocm backplane login <stage-cluster-id>
69+
oc login https://api.example.openshift.com:6443
7670
```
7771

78-
3. **Run a Test Job**
72+
2. **Render the Test Job YAML**
73+
- Run this from the script directory (which contains `metadata.yaml` and the script).
7974
```sh
80-
ocm backplane testjob create [-p var1=val1]
75+
cd scripts/CEE/new-script
76+
ocm backplane testjob render > test-job.yaml
8177
```
82-
Example Output:
78+
- If your script requires parameters, pass them with `-p` (repeatable):
79+
```sh
80+
ocm backplane testjob render -p var1=value > test-job.yaml
8381
```
84-
Test job openshift-job-dev-7m755 created successfully
85-
Run "ocm backplane testjob get openshift-job-dev-7m755" for details
86-
Run "ocm backplane testjob logs openshift-job-dev-7m755" for job logs
82+
Useful flags:
83+
- `-p`/`--params` - script parameter, repeatable.
84+
- `-s`/`--source-dir` - script source directory (defaults to the current directory).
85+
- `-i`/`--base-image-override` - override the base image (defaults to the latest managed-scripts image resolved from GitHub).
86+
- `-o`/`--output` - write to a file instead of stdout.
87+
88+
3. **Review and Apply the YAML**
89+
```sh
90+
oc apply -f test-job.yaml
8791
```
8892

8993
4. **Check Job Status**
9094
```sh
91-
ocm backplane testjob get openshift-job-dev-7m755
92-
```
93-
Example Output:
94-
```
95-
TestId: openshift-job-dev-7m755, Status: Succeeded
95+
oc -n openshift-backplane-managed-scripts get pods
9696
```
9797

9898
5. **View Logs**
99+
- Replace `example-test-job-pod` with the pod name from the previous step.
100+
```sh
101+
oc -n openshift-backplane-managed-scripts logs example-test-job-pod
102+
```
103+
104+
6. **Clean Up**
99105
```sh
100-
ocm backplane testjob logs openshift-job-dev-7m755
106+
oc delete -f test-job.yaml
101107
```
102108

103109
## Deploying the Script to Production

0 commit comments

Comments
 (0)