├── pkg ├── jsonschema │ ├── testdata │ │ ├── empty.json │ │ ├── non_json.json │ │ ├── non_schema_match.json │ │ └── zsh.json │ ├── doc.go │ └── utils.go ├── config │ ├── autodiscover │ │ ├── testdata │ │ │ ├── empty.json │ │ │ ├── testpods_empty.json │ │ │ ├── csv_output_nolabel.json │ │ │ ├── testhelmchart.json │ │ │ ├── testdeployment.json │ │ │ ├── csv.json │ │ │ ├── ipv4pod.json │ │ │ ├── ipv6pod.json │ │ │ ├── testorchestrator.json │ │ │ ├── ipv4ipv6pod.json │ │ │ └── testtarget.json │ │ ├── doc.go │ │ ├── helm_info.go │ │ ├── operator_test.go │ │ ├── container_test.go │ │ └── pod_test.go │ ├── configsections │ │ ├── test-json-config.json883666995 │ │ ├── helm.go │ │ ├── hpa.go │ │ ├── crdfilter.go │ │ ├── podset.go │ │ ├── container_test.go │ │ ├── misc.go │ │ ├── request.go │ │ ├── node.go │ │ ├── node_test.go │ │ └── pod.go │ ├── testdata │ │ └── tnf_test_config.yml │ ├── doc.go │ └── config_instance_test.go ├── tnf │ ├── handlers │ │ ├── generic │ │ │ ├── testdata │ │ │ │ ├── missing_key.yaml │ │ │ │ ├── bad_template.json.tpl │ │ │ │ ├── not_json.json │ │ │ │ ├── bad_yaml.yaml │ │ │ │ ├── hostname.json │ │ │ │ ├── nested-result-context-marshal-expected.json │ │ │ │ ├── test_schema_error.json │ │ │ │ ├── template_has_extraneous_field.yaml.tpl │ │ │ │ ├── assertion_error.json │ │ │ │ └── base.json │ │ │ ├── assertion │ │ │ │ ├── testdata │ │ │ │ │ ├── not_json.json │ │ │ │ │ ├── assertions_incorrect_type.json │ │ │ │ │ ├── missing_logic.json │ │ │ │ │ ├── condition_type_missing.json │ │ │ │ │ ├── groupIdx_missing.json │ │ │ │ │ ├── logic_incorrect_type.json │ │ │ │ │ ├── logic_type_missing.json │ │ │ │ │ ├── condition_type_incorrect_type.json │ │ │ │ │ ├── logic_type_key_incorrect_type.json │ │ │ │ │ ├── groupIdx_incorrect_type.json │ │ │ │ │ ├── condition_type_does_not_exist.json │ │ │ │ │ ├── and_composed_assertions_positive_test.json │ │ │ │ │ └── or_composed_assertions_positive_test.json │ │ │ │ ├── doc.go │ │ │ │ ├── or_test.go │ │ │ │ ├── logic.go │ │ │ │ ├── or.go │ │ │ │ ├── and_test.go │ │ │ │ └── and.go │ │ │ ├── condition │ │ │ │ ├── doc.go │ │ │ │ ├── intcondition │ │ │ │ │ └── doc.go │ │ │ │ ├── stringcondition │ │ │ │ │ ├── doc.go │ │ │ │ │ └── string.go │ │ │ │ └── condition.go │ │ │ ├── doc.go │ │ │ └── match.go │ │ ├── daemonset │ │ │ ├── testdata │ │ │ │ ├── non_valid_daemonset │ │ │ │ ├── valid_daemonset │ │ │ │ └── non_valid_output │ │ │ └── doc.go │ │ ├── ping │ │ │ ├── testdata │ │ │ │ ├── incorrect_ip_address.txt │ │ │ │ ├── ip_address_failing_packet_loss.txt │ │ │ │ ├── ip_address_no_packet_loss.txt │ │ │ │ ├── hostname_no_packet_loss.txt │ │ │ │ ├── ip_address_passing_packet_loss.txt │ │ │ │ └── ip_address_error_packet_loss.txt │ │ │ └── doc.go │ │ ├── ipaddr │ │ │ ├── testdata │ │ │ │ ├── device_does_not_exist.txt │ │ │ │ └── device_exists.txt │ │ │ └── doc.go │ │ ├── node │ │ │ ├── doc.go │ │ │ └── nodes.json │ │ ├── liveness │ │ │ ├── liveness.gotemplate │ │ │ ├── liveness.json │ │ │ └── doc.go │ │ ├── shutdown │ │ │ ├── shutdown.gotemplate │ │ │ ├── shutdown.json │ │ │ └── doc.go │ │ ├── readiness │ │ │ ├── readiness.gotemplate │ │ │ ├── readiness.json │ │ │ └── doc.go │ │ ├── command │ │ │ ├── command.json │ │ │ └── doc.go │ │ ├── nodeuncordon │ │ │ ├── uncordon.json │ │ │ └── doc.go │ │ ├── csidriver │ │ │ ├── csidriver.json │ │ │ └── doc.go │ │ ├── automountservice │ │ │ ├── testData │ │ │ │ ├── saNotSet.yaml │ │ │ │ ├── saFalse.yaml │ │ │ │ └── saTrue.yaml │ │ │ └── doc.go │ │ ├── logging │ │ │ ├── logging.json │ │ │ └── doc.go │ │ ├── owners │ │ │ └── doc.go │ │ ├── checksubscription │ │ │ ├── check-subscription.json │ │ │ └── doc.go │ │ ├── scaling │ │ │ └── doc.go │ │ ├── doc.go │ │ ├── imagepullpolicy │ │ │ ├── doc.go │ │ │ └── imagepullpolicy.json │ │ ├── nodenames │ │ │ └── doc.go │ │ ├── operator │ │ │ └── doc.go │ │ ├── podnodename │ │ │ └── doc.go │ │ ├── nodedebug │ │ │ └── doc.go │ │ ├── nodemcname │ │ │ └── doc.go │ │ ├── crdstatusexistence │ │ │ ├── crdstatusexistence.json │ │ │ └── doc.go │ │ ├── nodeport │ │ │ └── doc.go │ │ ├── rolebinding │ │ │ └── doc.go │ │ ├── clusterversion │ │ │ └── doc.go │ │ ├── container │ │ │ └── doc.go │ │ ├── nodetainted │ │ │ └── doc.go │ │ ├── mckernelarguments │ │ │ └── doc.go │ │ ├── deploymentsdrain │ │ │ └── doc.go │ │ ├── handler_template │ │ │ ├── doc.tmpl │ │ │ └── handler_test.tmpl │ │ ├── nodeselector │ │ │ └── doc.go │ │ ├── clusterrolebinding │ │ │ └── doc.go │ │ ├── cnffsdiff │ │ │ └── doc.go │ │ ├── readbootconfig │ │ │ └── doc.go │ │ ├── bootconfigentries │ │ │ ├── doc.go │ │ │ └── bootconfigentries_test.go │ │ ├── currentkernelcmdlineargs │ │ │ └── doc.go │ │ ├── podsets │ │ │ └── doc.go │ │ ├── base │ │ │ └── redhat │ │ │ │ └── doc.go │ │ ├── sysctlallconfigsargs │ │ │ └── doc.go │ │ ├── deploymentsnodes │ │ │ └── doc.go │ │ └── podantiaffinity │ │ │ ├── doc.go │ │ │ └── podantiaffinity.json │ ├── identifier │ │ ├── testdata │ │ │ ├── not_json.json │ │ │ ├── missing_url.json │ │ │ ├── missing_version.json │ │ │ ├── bad_url.json │ │ │ ├── valid_identifier.json │ │ │ └── bad_version.json │ │ └── doc.go │ ├── interactive │ │ ├── testdata │ │ │ ├── ssh.json.tpl.values.bad.yaml.tpl │ │ │ ├── ssh.json.tpl.values.bad.nonyaml │ │ │ ├── simple.json │ │ │ └── missing_timeout.json │ │ ├── doc.go │ │ ├── ssh.go │ │ └── shell.go │ ├── testcases │ │ ├── files │ │ │ ├── cnf │ │ │ │ ├── readme.txt │ │ │ │ ├── gatherpodfacts.yml │ │ │ │ ├── privilegedroles.yml │ │ │ │ └── privilegedpod.yml │ │ │ └── operator │ │ │ │ └── operatorstatus.yml │ │ ├── data │ │ │ ├── cnf │ │ │ │ ├── readme.txt │ │ │ │ ├── doc.go │ │ │ │ ├── gatherfacts.go │ │ │ │ └── privilegedroles.go │ │ │ └── operator │ │ │ │ ├── doc.go │ │ │ │ └── operator.go │ │ └── doc.go │ ├── doc.go │ ├── dependencies │ │ └── doc.go │ └── reel │ │ └── doc.go ├── gradetool │ ├── doc.go │ └── gradetool_test.go └── junit │ ├── doc.go │ └── convert_test.go ├── version.json ├── examples ├── generic │ └── template │ │ ├── ping.values.yaml │ │ └── ping.json.tpl ├── pty │ ├── sh.json │ ├── ssh.json.tpl.values.yaml │ └── ssh.json.tpl └── ping.json ├── internal └── api │ └── doc.go ├── .github ├── dependabot.yml └── workflows │ └── merge.yaml ├── test-network-function ├── networking │ ├── testdata │ │ ├── test_listening_port.json │ │ └── test_ports.json │ └── doc.go ├── testconfigure.yml ├── tnf_config.yml ├── diagnostic │ └── doc.go ├── identifiers │ └── doc.go ├── results │ └── doc.go ├── doc.go ├── operator │ └── doc.go ├── common │ ├── doc.go │ ├── constant.go │ └── suite.go ├── generic │ ├── doc.go │ └── suite.go ├── accesscontrol │ └── doc.go ├── lifecycle │ └── doc.go ├── platform │ └── doc.go ├── observability │ └── doc.go ├── certification │ └── doc.go └── version │ └── version.go ├── cmd ├── tnf │ ├── generate │ │ └── catalog │ │ │ ├── TEST_CASE_BUILDING_BLOCKS_CATALOG.md │ │ │ ├── TEST_CASE_CATALOG.md │ │ │ └── INTRO.md │ ├── main.go │ └── grade │ │ └── grade.go ├── ssh │ └── doc.go ├── ping │ └── doc.go └── oc │ └── doc.go ├── script ├── exec-container.sh └── run-cfd-container.sh ├── schemas ├── generic-pty.schema.json └── gradetool-policy-schema.json ├── .gitignore ├── go.mod ├── docs └── images │ └── overview.drawio └── COMMITMENT /pkg/jsonschema/testdata/empty.json: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /pkg/config/autodiscover/testdata/empty.json: -------------------------------------------------------------------------------- 1 | [] 2 | -------------------------------------------------------------------------------- /pkg/tnf/handlers/generic/testdata/missing_key.yaml: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /pkg/jsonschema/testdata/non_json.json: -------------------------------------------------------------------------------- 1 | this: 2 | - is_yaml -------------------------------------------------------------------------------- /pkg/tnf/identifier/testdata/not_json.json: -------------------------------------------------------------------------------- 1 | This is not JSON. -------------------------------------------------------------------------------- /version.json: -------------------------------------------------------------------------------- 1 | { 2 | "partner_tag": "v3.3.0" 3 | } 4 | -------------------------------------------------------------------------------- /examples/generic/template/ping.values.yaml: -------------------------------------------------------------------------------- 1 | HOST: 192.168.1.1 2 | -------------------------------------------------------------------------------- /pkg/tnf/handlers/generic/testdata/bad_template.json.tpl: -------------------------------------------------------------------------------- 1 | { 2 | {{ 3 | } -------------------------------------------------------------------------------- /pkg/tnf/handlers/generic/testdata/not_json.json: -------------------------------------------------------------------------------- 1 | this is not valid JSON. -------------------------------------------------------------------------------- /pkg/tnf/handlers/daemonset/testdata/non_valid_daemonset: -------------------------------------------------------------------------------- 1 | test 2 1 1 1 0 2 | % -------------------------------------------------------------------------------- /pkg/tnf/handlers/daemonset/testdata/valid_daemonset: -------------------------------------------------------------------------------- 1 | debug 1 1 1 1 0 2 | % -------------------------------------------------------------------------------- /pkg/tnf/handlers/generic/testdata/bad_yaml.yaml: -------------------------------------------------------------------------------- 1 | Not a Key/Value Pair!!! 2 | -------------------------------------------------------------------------------- /pkg/tnf/identifier/testdata/missing_url.json: -------------------------------------------------------------------------------- 1 | { 2 | "version": "v0.0.1" 3 | } -------------------------------------------------------------------------------- /examples/pty/sh.json: -------------------------------------------------------------------------------- 1 | { 2 | "command": "/bin/sh", 3 | "timeout": 2000000000 4 | } -------------------------------------------------------------------------------- /pkg/jsonschema/testdata/non_schema_match.json: -------------------------------------------------------------------------------- 1 | { 2 | "some_key": "some_value" 3 | } -------------------------------------------------------------------------------- /pkg/tnf/handlers/daemonset/testdata/non_valid_output: -------------------------------------------------------------------------------- 1 | debug 2 2 0 0 2 | -------------------------------------------------------------------------------- /pkg/tnf/interactive/testdata/ssh.json.tpl.values.bad.yaml.tpl: -------------------------------------------------------------------------------- 1 | bad: 2 | - keys 3 | -------------------------------------------------------------------------------- /pkg/tnf/handlers/generic/assertion/testdata/not_json.json: -------------------------------------------------------------------------------- 1 | { 2 | not even json... 3 | } -------------------------------------------------------------------------------- /pkg/tnf/identifier/testdata/missing_version.json: -------------------------------------------------------------------------------- 1 | { 2 | "url": "www.google.com" 3 | } -------------------------------------------------------------------------------- /pkg/tnf/interactive/testdata/ssh.json.tpl.values.bad.nonyaml: -------------------------------------------------------------------------------- 1 | { 2 | "notyaml" 3 | } 4 | -------------------------------------------------------------------------------- /examples/pty/ssh.json.tpl.values.yaml: -------------------------------------------------------------------------------- 1 | SSH_ARGS: 2 | - 192.168.1.5 3 | - -l 4 | - pi 5 | -------------------------------------------------------------------------------- /pkg/tnf/interactive/testdata/simple.json: -------------------------------------------------------------------------------- 1 | { 2 | "command": "ftp", 3 | "timeout": 200 4 | } -------------------------------------------------------------------------------- /pkg/jsonschema/testdata/zsh.json: -------------------------------------------------------------------------------- 1 | { 2 | "command": "/bin/zsh", 3 | "timeout": 2000000000 4 | } -------------------------------------------------------------------------------- /pkg/gradetool/doc.go: -------------------------------------------------------------------------------- 1 | // Package gradetool provides a grading tool for CNF test results 2 | package gradetool 3 | -------------------------------------------------------------------------------- /pkg/tnf/identifier/testdata/bad_url.json: -------------------------------------------------------------------------------- 1 | { 2 | "url": "http://[::1]:namedport", 3 | "version": "v0.0.1" 4 | } -------------------------------------------------------------------------------- /pkg/tnf/handlers/ping/testdata/incorrect_ip_address.txt: -------------------------------------------------------------------------------- 1 | connect: Invalid argument 2 | command terminated with exit code 2 3 | -------------------------------------------------------------------------------- /pkg/tnf/interactive/testdata/missing_timeout.json: -------------------------------------------------------------------------------- 1 | { 2 | "command": "ftp", 3 | "args": [ 4 | "192.168.1.1" 5 | ] 6 | } -------------------------------------------------------------------------------- /pkg/tnf/handlers/ipaddr/testdata/device_does_not_exist.txt: -------------------------------------------------------------------------------- 1 | Device "dne" does not exist. 2 | command terminated with exit code 1 3 | -------------------------------------------------------------------------------- /internal/api/doc.go: -------------------------------------------------------------------------------- 1 | // Package api provides client to make rest api call to RH catalog and container published image database. 2 | package api 3 | -------------------------------------------------------------------------------- /pkg/tnf/identifier/testdata/valid_identifier.json: -------------------------------------------------------------------------------- 1 | { 2 | "url": "http://test-network-function.com/tests/generic/ping", 3 | "version": "v0.0.1" 4 | } -------------------------------------------------------------------------------- /pkg/tnf/testcases/files/cnf/readme.txt: -------------------------------------------------------------------------------- 1 | #This read me is used for unit test , do not delete 2 | This files are used to override templates via files 3 | -------------------------------------------------------------------------------- /pkg/tnf/handlers/generic/assertion/testdata/assertions_incorrect_type.json: -------------------------------------------------------------------------------- 1 | { 2 | "assertions": "string", 3 | "logic": { 4 | "type": "and" 5 | } 6 | } -------------------------------------------------------------------------------- /pkg/tnf/handlers/node/doc.go: -------------------------------------------------------------------------------- 1 | // Package node provides a tnf.Test implementation for getting OpenShift node information for a cluster. 2 | package node 3 | -------------------------------------------------------------------------------- /pkg/tnf/identifier/testdata/bad_version.json: -------------------------------------------------------------------------------- 1 | { 2 | "url": "http://test-network-function.com/tests/generic/ping", 3 | "version": "letters_shouldn_t_be_here0.0.1" 4 | } -------------------------------------------------------------------------------- /.github/dependabot.yml: -------------------------------------------------------------------------------- 1 | # dependabot config 2 | 3 | version: 2 4 | updates: 5 | - package-ecosystem: "gomod" 6 | directory: "/" 7 | schedule: 8 | interval: "daily" 9 | -------------------------------------------------------------------------------- /examples/pty/ssh.json.tpl: -------------------------------------------------------------------------------- 1 | { 2 | "command": "ssh", 3 | "args": [{{range $index, $element := .SSH_ARGS}}{{if $index}},{{end}}"{{$element}}"{{end}}], 4 | "timeout": 2000000000 5 | } -------------------------------------------------------------------------------- /pkg/config/autodiscover/doc.go: -------------------------------------------------------------------------------- 1 | // Package autodiscover provides methods and data structures necessary for finding cluster resources from their labels. 2 | package autodiscover 3 | -------------------------------------------------------------------------------- /pkg/tnf/handlers/liveness/liveness.gotemplate: -------------------------------------------------------------------------------- 1 | {{- range .spec.containers -}} 2 | {{ if .livenessProbe }} {{"liveness-defined\n"}} {{- else -}} {{"liveness-not-defined\n"}}{{- end -}} 3 | {{- end -}} -------------------------------------------------------------------------------- /pkg/tnf/handlers/shutdown/shutdown.gotemplate: -------------------------------------------------------------------------------- 1 | {{- range .spec.containers -}} 2 | {{ if .lifecycle.preStop }} {{"prestop-defined\n"}} {{- else -}} {{"prestop-not-defined\n"}}{{- end -}} 3 | {{- end -}} -------------------------------------------------------------------------------- /pkg/tnf/handlers/readiness/readiness.gotemplate: -------------------------------------------------------------------------------- 1 | {{- range .spec.containers -}} 2 | {{ if .readinessProbe }} {{"readiness-defined\n"}} {{- else -}} {{"readiness-not-defined\n"}}{{- end -}} 3 | {{- end -}} -------------------------------------------------------------------------------- /test-network-function/networking/testdata/test_listening_port.json: -------------------------------------------------------------------------------- 1 | [ 2 | "tcp LISTEN 0 128 0.0.0.0:8080 0.0.0.0:*", 3 | "tcp LISTEN 0 128 0.0.0.0:8443 0.0.0.0:*", 4 | "tcp LISTEN 0 128 [::]:22" 5 | ] -------------------------------------------------------------------------------- /pkg/config/autodiscover/testdata/testpods_empty.json: -------------------------------------------------------------------------------- 1 | { 2 | "apiVersion": "v1", 3 | "items": [], 4 | "kind": "List", 5 | "metadata": { 6 | "resourceVersion": "", 7 | "selfLink": "" 8 | } 9 | } 10 | -------------------------------------------------------------------------------- /cmd/tnf/generate/catalog/TEST_CASE_BUILDING_BLOCKS_CATALOG.md: -------------------------------------------------------------------------------- 1 | ## Test Case Building Blocks Catalog 2 | 3 | A number of Test Case Building Blocks, or `tnf.Test`s, are included out of the box. This is a summary of the available implementations: 4 | -------------------------------------------------------------------------------- /pkg/config/autodiscover/testdata/csv_output_nolabel.json: -------------------------------------------------------------------------------- 1 | { 2 | "apiVersion": "v1", 3 | "items": [], 4 | "kind": "List", 5 | "metadata": { 6 | "resourceVersion": "", 7 | "selfLink": "" 8 | } 9 | } 10 | -------------------------------------------------------------------------------- /pkg/tnf/handlers/generic/assertion/testdata/missing_logic.json: -------------------------------------------------------------------------------- 1 | { 2 | "assertions": [ 3 | { 4 | "groupIdx": 1, 5 | "condition": { 6 | "type": "equals", 7 | "expected": "iperf" 8 | } 9 | } 10 | ] 11 | } -------------------------------------------------------------------------------- /pkg/tnf/handlers/ping/testdata/ip_address_failing_packet_loss.txt: -------------------------------------------------------------------------------- 1 | PING 192.168.1.2 (192.168.1.2) 56(84) bytes of data. 2 | 3 | --- 192.168.1.2 ping statistics --- 4 | 1 packets transmitted, 0 received, 100% packet loss, time 0ms 5 | 6 | command terminated with exit code 1 7 | -------------------------------------------------------------------------------- /pkg/config/autodiscover/testdata/testhelmchart.json: -------------------------------------------------------------------------------- 1 | [ 2 | { 3 | "name":"my-test1", 4 | "namespace":"test", 5 | "revision":"1", 6 | "updated":"test", 7 | "status":"deployed", 8 | "chart":"my-test1-1.13.8", 9 | "app_version":"1.7.1" 10 | } 11 | ] -------------------------------------------------------------------------------- /pkg/tnf/handlers/generic/assertion/testdata/condition_type_missing.json: -------------------------------------------------------------------------------- 1 | { 2 | "assertions": [ 3 | { 4 | "groupIdx": 0, 5 | "condition": { 6 | "expected": "iperf" 7 | } 8 | } 9 | ], 10 | "logic": { 11 | "type": "and" 12 | } 13 | } -------------------------------------------------------------------------------- /pkg/tnf/handlers/generic/assertion/testdata/groupIdx_missing.json: -------------------------------------------------------------------------------- 1 | { 2 | "assertions": [ 3 | { 4 | "condition": { 5 | "type": "equals", 6 | "expected": "iperf" 7 | } 8 | } 9 | ], 10 | "logic": { 11 | "type": "and" 12 | } 13 | } -------------------------------------------------------------------------------- /pkg/tnf/handlers/generic/assertion/testdata/logic_incorrect_type.json: -------------------------------------------------------------------------------- 1 | { 2 | "assertions": [ 3 | { 4 | "groupIdx": 1, 5 | "condition": { 6 | "type": "equals", 7 | "expected": "iperf" 8 | } 9 | } 10 | ], 11 | "logic": "d" 12 | } -------------------------------------------------------------------------------- /pkg/tnf/handlers/generic/assertion/testdata/logic_type_missing.json: -------------------------------------------------------------------------------- 1 | { 2 | "assertions": [ 3 | { 4 | "groupIdx": 1, 5 | "condition": { 6 | "type": "equals", 7 | "expected": "iperf" 8 | } 9 | } 10 | ], 11 | "logic": {} 12 | } -------------------------------------------------------------------------------- /pkg/tnf/handlers/generic/assertion/testdata/condition_type_incorrect_type.json: -------------------------------------------------------------------------------- 1 | { 2 | "assertions": [ 3 | { 4 | "groupIdx": 0, 5 | "condition": { 6 | "type": false, 7 | "expected": "iperf" 8 | } 9 | } 10 | ], 11 | "logic": { 12 | "type": "and" 13 | } 14 | } -------------------------------------------------------------------------------- /pkg/tnf/handlers/generic/assertion/testdata/logic_type_key_incorrect_type.json: -------------------------------------------------------------------------------- 1 | { 2 | "assertions": [ 3 | { 4 | "groupIdx": 1, 5 | "condition": { 6 | "type": "equals", 7 | "expected": "iperf" 8 | } 9 | } 10 | ], 11 | "logic": { 12 | "type": false 13 | } 14 | } -------------------------------------------------------------------------------- /pkg/tnf/handlers/ipaddr/testdata/device_exists.txt: -------------------------------------------------------------------------------- 1 | 24: eth0@if25: mtu 1500 qdisc noqueue state UP group default 2 | link/ether 02:42:ac:11:00:07 brd ff:ff:ff:ff:ff:ff link-netnsid 0 3 | inet 172.17.0.7/16 brd 172.17.255.255 scope global eth0 4 | valid_lft forever preferred_lft forever 5 | -------------------------------------------------------------------------------- /pkg/tnf/handlers/generic/assertion/testdata/groupIdx_incorrect_type.json: -------------------------------------------------------------------------------- 1 | { 2 | "assertions": [ 3 | { 4 | "groupIdx": "non-integer group index", 5 | "condition": { 6 | "type": "equals", 7 | "expected": "iperf" 8 | } 9 | } 10 | ], 11 | "logic": { 12 | "type": "and" 13 | } 14 | } -------------------------------------------------------------------------------- /cmd/tnf/generate/catalog/TEST_CASE_CATALOG.md: -------------------------------------------------------------------------------- 1 | ## Test Case Catalog 2 | 3 | Test Cases are the specifications used to perform a meaningful test. Test cases may run once, or several times against several targets. CNF Certification includes a number of normative and informative tests to ensure CNFs follow best practices. Here is the list of available 4 | -------------------------------------------------------------------------------- /pkg/config/autodiscover/testdata/testdeployment.json: -------------------------------------------------------------------------------- 1 | 2 | { 3 | "apiVersion": "apps/v1", 4 | "kind": "Deployment", 5 | "metadata": { 6 | "labels": { 7 | "app": "test" 8 | }, 9 | "name": "test", 10 | "namespace": "tnf" 11 | }, 12 | "spec": { 13 | "replicas": 2 14 | } 15 | } -------------------------------------------------------------------------------- /pkg/tnf/handlers/generic/assertion/testdata/condition_type_does_not_exist.json: -------------------------------------------------------------------------------- 1 | { 2 | "assertions": [ 3 | { 4 | "groupIdx": 0, 5 | "condition": { 6 | "type": "this condition type does not exist, and is for test purposes only", 7 | "expected": "iperf" 8 | } 9 | } 10 | ], 11 | "logic": { 12 | "type": "and" 13 | } 14 | } -------------------------------------------------------------------------------- /pkg/config/autodiscover/testdata/csv.json: -------------------------------------------------------------------------------- 1 | { 2 | "metadata": { 3 | "annotations": { 4 | "test-network-function.com/operator_tests": "[\"OPERATOR_STATUS\", \"ANOTHER_TEST\"]", 5 | "test-network-function.com/subscription_name": "[\"nginx-operator-v0-0-1-sub\"]" 6 | }, 7 | "labels": { 8 | "test-network-function.com/operator": "target" 9 | }, 10 | "name": "CSVName", 11 | "namespace": "CSVNamespace" 12 | } 13 | } -------------------------------------------------------------------------------- /test-network-function/networking/testdata/test_ports.json: -------------------------------------------------------------------------------- 1 | [ 2 | { 3 | "containerPort": 8443, 4 | "name": "https", 5 | "protocol": "TCP" 6 | }, 7 | { 8 | "containerPort": 50051, 9 | "name": "grpc", 10 | "protocol": "TCP" 11 | }, 12 | { 13 | "containerPort": 8080, 14 | "name": "http-probe", 15 | "protocol": "TCP" 16 | }, 17 | { 18 | "containerPort": 8080, 19 | "name": "http-probe", 20 | "protocol": "TCP" 21 | } 22 | ] -------------------------------------------------------------------------------- /pkg/tnf/handlers/ping/testdata/ip_address_no_packet_loss.txt: -------------------------------------------------------------------------------- 1 | PING 192.168.1.1 (192.168.1.1) 56(84) bytes of data. 2 | 64 bytes from 192.168.1.1: icmp_seq=1 ttl=61 time=2.23 ms 3 | 64 bytes from 192.168.1.1: icmp_seq=2 ttl=61 time=1.71 ms 4 | 64 bytes from 192.168.1.1: icmp_seq=3 ttl=61 time=1.84 ms 5 | 64 bytes from 192.168.1.1: icmp_seq=4 ttl=61 time=7.99 ms 6 | 7 | --- 192.168.1.1 ping statistics --- 8 | 4 packets transmitted, 4 received, 0% packet loss, time 3005ms 9 | rtt min/avg/max/mdev = 1.710/3.446/7.994/2.633 ms 10 | -------------------------------------------------------------------------------- /test-network-function/testconfigure.yml: -------------------------------------------------------------------------------- 1 | cnftest: 2 | - name: "PRIVILEGED_POD" 3 | tests: 4 | - "HOST_NETWORK_CHECK" 5 | - "HOST_PORT_CHECK" 6 | - "HOST_PATH_CHECK" 7 | - "HOST_IPC_CHECK" 8 | - "HOST_PID_CHECK" 9 | - "CAPABILITY_CHECK" 10 | - "ROOT_CHECK" 11 | - "PRIVILEGE_ESCALATION" 12 | - name: "PRIVILEGED_ROLE" 13 | tests: 14 | - "CLUSTER_ROLE_BINDING_BY_SA" 15 | operatortest: 16 | - name: "OPERATOR_STATUS" 17 | tests: 18 | - "CSV_INSTALLED" 19 | - "CSV_SCC" 20 | -------------------------------------------------------------------------------- /cmd/tnf/generate/catalog/INTRO.md: -------------------------------------------------------------------------------- 1 | # test-network-function Catalog 2 | The catalog for test-network-function contains a variety of `Test Cases`, as well as `Test Case Building Blocks`. 3 | * Test Cases: Traditional JUnit testcases, which are specified internally using `Ginkgo.It`. Test cases often utilize several Test Case Building Blocks. 4 | * Test Case Building Blocks: Self-contained building blocks, which perform a small task in the context of `oc`, `ssh`, `shell`, or some other `Expecter`. 5 | 6 | So, a Test Case could be composed by one or many Test Case Building Blocks. 7 | 8 | -------------------------------------------------------------------------------- /pkg/tnf/handlers/node/nodes.json: -------------------------------------------------------------------------------- 1 | { 2 | "identifier": { 3 | "url": "http://test-network-function.com/tests/nodes", 4 | "version": "v1.0.0" 5 | }, 6 | "description": "Runs `oc get nodes -o json` on a target machine.", 7 | "testResult": 0, 8 | "testTimeout": 10000000000, 9 | "reelFirstStep": { 10 | "execute": "oc get nodes -o json\n", 11 | "expect": [ 12 | "(?m)(.|\n)+" 13 | ], 14 | "timeout": 10000000000 15 | }, 16 | "resultContexts": [ 17 | { 18 | "pattern": "(?m)(.|\n)+", 19 | "defaultResult": 1 20 | } 21 | ] 22 | } 23 | -------------------------------------------------------------------------------- /pkg/tnf/handlers/command/command.json: -------------------------------------------------------------------------------- 1 | 2 | { 3 | "identifier" : { 4 | "url" : "http://test-network-function.com/tests/command", 5 | "version": "v1.0.0" 6 | }, 7 | "description": "Handler to execute user custom commands.", 8 | "testResult": 0, 9 | "testTimeout": {{ .TIMEOUT }}, 10 | "reelFirstStep": { 11 | "execute": "{{ .COMMAND }}", 12 | "expect": ["(?m).*"], 13 | "timeout": {{ .TIMEOUT }} 14 | }, 15 | "resultContexts":[ 16 | { 17 | "pattern": "(?m).*", 18 | "defaultResult": 1 19 | } 20 | ] 21 | } -------------------------------------------------------------------------------- /pkg/tnf/handlers/nodeuncordon/uncordon.json: -------------------------------------------------------------------------------- 1 | { 2 | "identifier": { 3 | "url": "http://test-network-function.com/tests/node/uncordon", 4 | "version": "v1.0.0" 5 | }, 6 | "description": "uncordon a node.", 7 | "testResult": 0, 8 | "testTimeout": 10000000000, 9 | "reelFirstStep": { 10 | "execute": "oc adm uncordon {{.NODE}}\n", 11 | "expect": [ 12 | "(?m).*uncordoned" 13 | ], 14 | "timeout": 10000000000 15 | }, 16 | "resultContexts": [ 17 | { 18 | "pattern": "(?m).*uncordoned", 19 | "defaultResult": 1 20 | } 21 | ] 22 | } 23 | -------------------------------------------------------------------------------- /script/exec-container.sh: -------------------------------------------------------------------------------- 1 | # proof of concept bash script to execute any commands in running pods 2 | set -x 3 | NAMESPACE=$1 4 | POD_NAME=$2 5 | COMMAND=$3 6 | NODE_NAME=$(oc get pods -n $NAMESPACE $POD_NAME --no-headers=true -ocustom-columns=node:.spec.nodeName) 7 | CONTAINER_ID=$(oc get pods -ojsonpath={.status.containerStatuses[0].containerID} -n $NAMESPACE $POD_NAME | awk -F "//" '{print $2}') 8 | CONTAINER_PID=$(oc debug node/$NODE_NAME -- chroot /host crictl inspect --output go-template --template '{{.info.pid}}' $CONTAINER_ID 2>/dev/null) 9 | oc debug node/$NODE_NAME -- nsenter nsenter -t $CONTAINER_PID -n $COMMAND 10 | 11 | -------------------------------------------------------------------------------- /pkg/tnf/testcases/data/cnf/readme.txt: -------------------------------------------------------------------------------- 1 | Add test case template file here 2 | 1. Define a variable with json template (TODO create schema) 3 | var TEST_CASE_NAME_HERE = string(`{ 4 | "testcase": [ 5 | { 6 | "name": "name of the test that has to defined, a constant", 7 | "skiptest": true, 8 | "command": "oc get pod %s -n %s -o json | jq -r '.spec.hostNetwork'", 9 | "resultType": "string|array", //return result type from the command 10 | "action": "allow|deny", 11 | "expectedtype" "string|function", 12 | "expectedstatus": [ 13 | "NULL_FALSE" 14 | ] 15 | }, 16 | }')' 17 | 2.update data/config.go with struct -------------------------------------------------------------------------------- /pkg/tnf/handlers/csidriver/csidriver.json: -------------------------------------------------------------------------------- 1 | { 2 | "identifier": { 3 | "url": "http://test-network-function.com/tests/csiDriver", 4 | "version": "v1.0.0" 5 | }, 6 | "description": "This test checks third party CSI driver installed in cluster for cnf.", 7 | "testResult": 0, 8 | "testTimeout": 10000000000, 9 | "reelFirstStep": { 10 | "execute": 11 | "oc get csidriver -o json\n", 12 | "expect": [ 13 | "(?m)(.|\n)+" 14 | ], 15 | "timeout": 10000000000 16 | }, 17 | "resultContexts": [ 18 | { 19 | "pattern": "(?m)(.|\n)+", 20 | "defaultResult": 1 21 | } 22 | ] 23 | } 24 | -------------------------------------------------------------------------------- /examples/generic/template/ping.json.tpl: -------------------------------------------------------------------------------- 1 | { 2 | "identifier": { 3 | "url": "http://test-network-function.com/tests/unit/ping", 4 | "version": "v1.0.0" 5 | }, 6 | "description": "ping test", 7 | "reelFirstStep": { 8 | "execute": "ping -c 5 {{.HOST}}", 9 | "expect": [ 10 | "(?m)(\\d+) packets transmitted, (\\d+)( packets){0,1} received, (?:\\+(\\d+) errors)?.*$" 11 | ], 12 | "timeout": 2000000000 13 | }, 14 | "resultContexts": [ 15 | { 16 | "pattern": "(?m)(\\d+) packets transmitted, (\\d+)( packets){0,1} received, (?:\\+(\\d+) errors)?.*$", 17 | "defaultResult": 0 18 | } 19 | ], 20 | "testResult": 2, 21 | "testTimeout": 2000000000 22 | } 23 | -------------------------------------------------------------------------------- /pkg/tnf/handlers/automountservice/testData/saNotSet.yaml: -------------------------------------------------------------------------------- 1 | --- 2 | { 3 | "apiVersion": "v1", 4 | "imagePullSecrets": [ 5 | { 6 | "name": "default-dockercfg-ckml7" 7 | } 8 | ], 9 | "kind": "ServiceAccount", 10 | "metadata": { 11 | "creationTimestamp": "2021-11-23T23:49:25Z", 12 | "name": "default", 13 | "namespace": "salah3", 14 | "resourceVersion": "193777061", 15 | "uid": "ccbda73b-ad2f-44d8-b188-4dc2cb1945ac" 16 | }, 17 | "secrets": [ 18 | { 19 | "name": "default-token-xrczr" 20 | }, 21 | { 22 | "name": "default-dockercfg-ckml7" 23 | } 24 | ] 25 | } 26 | -------------------------------------------------------------------------------- /pkg/tnf/handlers/generic/testdata/hostname.json: -------------------------------------------------------------------------------- 1 | { 2 | "identifier": { 3 | "url": "http://test-network-function.com/tests/unit/hostname", 4 | "version": "v1.0.0" 5 | }, 6 | "arguments": [ 7 | "cat", 8 | "/etc/redhat-release" 9 | ], 10 | "description": false, 11 | "reelFirstStep": { 12 | "expect": [ 13 | "(?m)Red Hat Enterprise Linux Server release (\\d+\\.\\d+) \\(\\w+\\)" 14 | ], 15 | "timeout": 2000000000 16 | }, 17 | "resultContexts": [ 18 | { 19 | "pattern": "(?m)Red Hat Enterprise Linux Server release (\\d+\\.\\d+) \\(\\w+\\)", 20 | "defaultResult": 0 21 | } 22 | ], 23 | "testResult": 2, 24 | "testTimeout": 2000000000 25 | } 26 | -------------------------------------------------------------------------------- /pkg/tnf/handlers/generic/testdata/nested-result-context-marshal-expected.json: -------------------------------------------------------------------------------- 1 | { 2 | "pattern": "(\\d)+", 3 | "composedAssertions": [ 4 | { 5 | "assertions": [ 6 | { 7 | "groupIdx": 1, 8 | "condition": { 9 | "type": "intComparison", 10 | "input": 1, 11 | "comparison": "==" 12 | } 13 | } 14 | ], 15 | "logic": { 16 | "type": "and" 17 | } 18 | } 19 | ], 20 | "defaultResult": 2, 21 | "nextStep": { 22 | "execute": "echo 2", 23 | "expect": [ 24 | "(\\d+)" 25 | ] 26 | }, 27 | "nextResultContexts": [ 28 | { 29 | "pattern": "(\\d)+", 30 | "defaultResult": 0 31 | } 32 | ] 33 | } -------------------------------------------------------------------------------- /pkg/tnf/handlers/automountservice/testData/saFalse.yaml: -------------------------------------------------------------------------------- 1 | --- 2 | { 3 | "apiVersion": "v1", 4 | "automountServiceAccountToken": false, 5 | "imagePullSecrets": [ 6 | { 7 | "name": "default-dockercfg-ckml7" 8 | } 9 | ], 10 | "kind": "ServiceAccount", 11 | "metadata": { 12 | "creationTimestamp": "2021-11-23T23:49:25Z", 13 | "name": "default", 14 | "namespace": "salah3", 15 | "resourceVersion": "193777061", 16 | "uid": "ccbda73b-ad2f-44d8-b188-4dc2cb1945ac" 17 | }, 18 | "secrets": [ 19 | { 20 | "name": "default-token-xrczr" 21 | }, 22 | { 23 | "name": "default-dockercfg-ckml7" 24 | } 25 | ] 26 | } 27 | -------------------------------------------------------------------------------- /pkg/tnf/handlers/automountservice/testData/saTrue.yaml: -------------------------------------------------------------------------------- 1 | --- 2 | { 3 | "apiVersion": "v1", 4 | "automountServiceAccountToken": true, 5 | "imagePullSecrets": [ 6 | { 7 | "name": "default-dockercfg-ckml7" 8 | } 9 | ], 10 | "kind": "ServiceAccount", 11 | "metadata": { 12 | "creationTimestamp": "2021-11-23T23:49:25Z", 13 | "name": "default", 14 | "namespace": "salah3", 15 | "resourceVersion": "193777061", 16 | "uid": "ccbda73b-ad2f-44d8-b188-4dc2cb1945ac" 17 | }, 18 | "secrets": [ 19 | { 20 | "name": "default-token-xrczr" 21 | }, 22 | { 23 | "name": "default-dockercfg-ckml7" 24 | } 25 | ] 26 | } 27 | -------------------------------------------------------------------------------- /pkg/tnf/handlers/generic/testdata/test_schema_error.json: -------------------------------------------------------------------------------- 1 | { 2 | "description": false, 3 | "reelFirstStep": { 4 | "execute": "if [ -e /etc/redhat-release ]; then cat /etc/redhat-release; else echo \"Unknown Base Image\"; fi\n", 5 | "expect": [ 6 | "(?m)Unknown Base Image", 7 | "(?m)Red Hat Enterprise Linux Server release (\\d+\\.\\d+) \\(\\w+\\)" 8 | ], 9 | "timeout": 2000000000 10 | }, 11 | "resultContexts": [ 12 | { 13 | "pattern": "(?m)Unknown Base Image", 14 | "defaultResult": 1 15 | }, 16 | { 17 | "pattern": "(?m)Red Hat Enterprise Linux Server release (\\d+\\.\\d+) \\(\\w+\\)", 18 | "defaultResult": 0 19 | } 20 | ], 21 | "testResult": 2, 22 | "testTimeout": 2000000000 23 | } 24 | -------------------------------------------------------------------------------- /pkg/tnf/testcases/files/operator/operatorstatus.yml: -------------------------------------------------------------------------------- 1 | testcase: 2 | - name: "CSV_INSTALLED" 3 | skiptest: false 4 | command: "oc get csv %s -n %s -o json | jq -r '.status.phase'" 5 | action: "allow" 6 | resulttype: "string" 7 | expectedType: "string" 8 | expectedstatus: 9 | - "Succeeded" 10 | - name: "CSV_SCC" 11 | skiptest: false 12 | command: "oc get csv %s -n %s -o json | jq -r 'if .spec.install.spec.clusterPermissions == null then null else . end | if . == null then \"EMPTY\" else .spec.install.spec.clusterPermissions[].rules[].resourceNames end | if length == 0 then \"EMPTY\" else . end'" 13 | action: "allow" 14 | resulttype: "string" 15 | expectedtype: "string" 16 | expectedstatus: 17 | - "EMPTY" 18 | -------------------------------------------------------------------------------- /pkg/tnf/handlers/liveness/liveness.json: -------------------------------------------------------------------------------- 1 | { 2 | "identifier" : { 3 | "url" : "http://test-network-function.com/tests/liveness", 4 | "version": "v1.0.0" 5 | }, 6 | "description": "Test check if liveness is defined.", 7 | "testResult": 0, 8 | "testTimeout": 5000000000, 9 | "reelFirstStep": { 10 | "execute": "oc get pod -n {{.POD_NAMESPACE}} {{.POD_NAME}} -o go-template-file={{.GO_TEMPLATE_PATH}}/liveness.gotemplate", 11 | "expect":[ "(?m)liveness-not-defined", 12 | "(?m)liveness-defined"], 13 | "timeout": 5000000000 14 | }, 15 | "resultContexts":[ 16 | { 17 | "pattern": "(?m)liveness-not-defined", 18 | "defaultResult": 2 19 | }, 20 | { 21 | "pattern": "(?m)liveness-defined", 22 | "defaultResult": 1 23 | } 24 | ] 25 | } 26 | -------------------------------------------------------------------------------- /pkg/tnf/handlers/readiness/readiness.json: -------------------------------------------------------------------------------- 1 | { 2 | "identifier" : { 3 | "url" : "http://test-network-function.com/tests/readiness", 4 | "version": "v1.0.0" 5 | }, 6 | "description": "Test check if readiness is defined.", 7 | "testResult": 0, 8 | "testTimeout": 5000000000, 9 | "reelFirstStep": { 10 | "execute": "oc get pod -n {{.POD_NAMESPACE}} {{.POD_NAME}} -o go-template-file={{.GO_TEMPLATE_PATH}}/readiness.gotemplate", 11 | "expect":[ "(?m)readiness-not-defined", 12 | "(?m)readiness-defined"], 13 | "timeout": 5000000000 14 | }, 15 | "resultContexts":[ 16 | { 17 | "pattern": "(?m)readiness-not-defined", 18 | "defaultResult": 2 19 | }, 20 | { 21 | "pattern": "(?m)readiness-defined", 22 | "defaultResult": 1 23 | } 24 | ] 25 | } 26 | -------------------------------------------------------------------------------- /pkg/tnf/handlers/generic/testdata/template_has_extraneous_field.yaml.tpl: -------------------------------------------------------------------------------- 1 | { 2 | "this field is not": "allowed by any means", 3 | "identifier": { 4 | "url": "http://test-network-function.com/tests/unit/ping", 5 | "version": "v1.0.0" 6 | }, 7 | "description": "ping test", 8 | "reelFirstStep": { 9 | "execute": "ping -c 5 {{.HOST}}", 10 | "expect": [ 11 | "(?m)(\\d+) packets transmitted, (\\d+)( packets){0,1} received, (?:\\+(\\d+) errors)?.*$" 12 | ], 13 | "timeout": 2000000000 14 | }, 15 | "resultContexts": [ 16 | { 17 | "pattern": "(?m)(\\d+) packets transmitted, (\\d+)( packets){0,1} received, (?:\\+(\\d+) errors)?.*$", 18 | "defaultResult": 0 19 | } 20 | ], 21 | "testResult": 2, 22 | "testTimeout": 2000000000 23 | } 24 | -------------------------------------------------------------------------------- /schemas/generic-pty.schema.json: -------------------------------------------------------------------------------- 1 | { 2 | "$id": "http://test-network-function.com/schemas/generic-pty.schema.json", 3 | "$schema": "http://json-schema.org/draft-07/schema#", 4 | "version": "0.0.1", 5 | "properties": { 6 | "command": { 7 | "type": "string", 8 | "description": "The command is the PTY executable. For example, ssh." 9 | }, 10 | "args": { 11 | "type": "array", 12 | "items": { 13 | "type": "string" 14 | }, 15 | "description": "The optional command arguments." 16 | }, 17 | "timeout": { 18 | "type": "integer", 19 | "description": "The timeout (in nanoseconds) for the PTY executable." 20 | } 21 | }, 22 | "additionalProperties": false, 23 | "required": [ 24 | "command", 25 | "timeout" 26 | ] 27 | } -------------------------------------------------------------------------------- /pkg/tnf/handlers/shutdown/shutdown.json: -------------------------------------------------------------------------------- 1 | { 2 | "identifier" : { 3 | "url" : "http://test-network-function.com/tests/shutdown", 4 | "version": "v1.0.0" 5 | }, 6 | "description": "Test if containers define pre-stop lifecycle", 7 | "testResult": 0, 8 | "testTimeout": 5000000000, 9 | "reelFirstStep": { 10 | "execute": "oc get pod -n {{.POD_NAMESPACE}} {{.POD_NAME}} -o go-template-file={{.GO_TEMPLATE_PATH}}/shutdown.gotemplate", 11 | "expect":[ "(?m)prestop-not-defined", 12 | "(?m)prestop-defined"], 13 | "timeout": 5000000000 14 | }, 15 | "resultContexts":[ 16 | { 17 | "pattern": "(?m)prestop-not-defined", 18 | "defaultResult": 2 19 | }, 20 | { 21 | "pattern": "(?m)prestop-defined", 22 | "defaultResult": 1 23 | } 24 | ] 25 | } 26 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | bin/ 2 | catalog.json 3 | claim.json 4 | .idea 5 | vendor 6 | *.test 7 | test-network-function_junit.xml 8 | cover.out 9 | test-network-function/cnf-certification-tests_junit.xml 10 | cnf-certification-tests_junit.xml 11 | cnftests-junit.xml 12 | setup_junit.xml 13 | validation_junit.xml 14 | .vscode 15 | jsontest-cli 16 | gradetool 17 | test-out.json 18 | cover.out 19 | 20 | # Explicitly don't track mocks. mocks should be built on request. 21 | pkg/tnf/mocks/mock_tester.go 22 | pkg/tnf/reel/mocks/mock_reel.go 23 | # NOTE: mock_expect.go is tracked, as it is generated from source externally. 24 | pkg/tnf/interactive/mocks/mock_spawner.go 25 | temp/ 26 | /tnf 27 | /all-releases.txt 28 | /latest-release-tag.txt 29 | /release-tag.txt 30 | test-network-function/claimjson.js 31 | test-network-function/results.html 32 | -------------------------------------------------------------------------------- /pkg/config/configsections/test-json-config.json883666995: -------------------------------------------------------------------------------- 1 | {"targetNameSpaces":null,"testTarget":{"deploymentsUnderTest":[{"Name":"deployment-one","Namespace":"default","Replicas":1,"Hpa":{"MinReplicas":0,"MaxReplicas":0,"HpaName":""},"Type":""}],"stateFulSetUnderTest":null,"podsUnderTest":[{"name":"cnf-test-one","namespace":"default","serviceaccount":"","containercount":0,"tests":["PRIVILEGED_POD"],"defaultnetworkipaddresses":null,"defaultNetworkDevice":"","IsManaged":false}],"NonValidPods":null,"containersUnderTest":null,"excludeContainersFromConnectivityTests":null,"operators":[{"name":"etcdoperator.v0.9.4","namespace":"my-etcd","tests":["OPERATOR_STATUS"],"subscriptionName":""}],"Nodes":null},"testPartner":{},"checkDiscoveredContainerCertificationStatus":false,"targetCrdFilters":[{"nameSuffix":"group1.test.com"},{"nameSuffix":"group2.test.com"}]} -------------------------------------------------------------------------------- /pkg/tnf/handlers/logging/logging.json: -------------------------------------------------------------------------------- 1 | { 2 | "identifier" : { 3 | "url" : "http://test-network-function.com/tests/logging", 4 | "version": "v1.0.0" 5 | }, 6 | "description": "Test if PUT emits output to stdout/stderr", 7 | "testResult": 0, 8 | "testTimeout": 5000000000, 9 | "reelFirstStep": { 10 | "execute": "oc logs -n {{.POD_NAMESPACE}} {{.POD_NAME}} {{.CONTAINER_NAME}} --tail 5 | wc -l", 11 | "expect":[ "(?m)[1-9]", 12 | "(?m)[0]", 13 | "(?m)[.*]"], 14 | "timeout": 5000000000 15 | }, 16 | "resultContexts":[ 17 | { 18 | "pattern": "(?m)[1-9]", 19 | "defaultResult": 1 20 | }, 21 | { 22 | "pattern": "(?m)[0]", 23 | "defaultResult": 2 24 | }, 25 | { 26 | "pattern": "(?m)[.*]", 27 | "defaultResult": 0 28 | } 29 | ] 30 | } 31 | -------------------------------------------------------------------------------- /pkg/tnf/testcases/files/cnf/gatherpodfacts.yml: -------------------------------------------------------------------------------- 1 | testcase: 2 | - name: "NAME" 3 | skiptest: false 4 | command: "oc get pod %s -n %s -o json | jq -r '.metadata.name'" 5 | action: "allow" 6 | resulttype: "string" 7 | expectedType: "regex" 8 | expectedstatus: 9 | - "ALLOW_ALL" 10 | - name: "CONTAINER_COUNT" 11 | skiptest: false 12 | command: "oc get pod %s -n %s -o json | jq -r '.spec.containers | length'" 13 | action: "allow" 14 | resulttype: "int" 15 | expectedType: "regex" 16 | expectedstatus: 17 | - "DIGIT" 18 | - name: "SERVICE_ACCOUNT_NAME" 19 | skiptest: false 20 | command: "oc get pod %s -n %s -o json | jq -r '.spec.serviceAccountName'" 21 | action: "allow" 22 | resulttype: "string" 23 | expectedType: "regex" 24 | expectedstatus: 25 | - "ALLOW_ALL" 26 | -------------------------------------------------------------------------------- /test-network-function/tnf_config.yml: -------------------------------------------------------------------------------- 1 | targetNameSpaces: 2 | - name: tnf 3 | targetPodLabels: 4 | - prefix: test-network-function.com 5 | name: generic 6 | value: target 7 | targetCrdFilters: 8 | - nameSuffix: "group1.test.com" 9 | - nameSuffix: "test-network-function.com" 10 | certifiedcontainerinfo: 11 | - name: nginx-116 # working example 12 | repository: rhel8 13 | tag: 1-112 # optional, "latest" assumed if empty 14 | digest: # if set, takes precedence over tag. e.g. "sha256:aa34453a6417f8f76423ffd2cf874e9c4a1a5451ac872b78dc636ab54a0ebbc3" 15 | checkDiscoveredContainerCertificationStatus: false 16 | certifiedoperatorinfo: 17 | - name: etcd 18 | organization: community-operators # working example 19 | acceptedKernelTaints: 20 | - module: vboxsf 21 | - module: vboxguest 22 | skipHelmChartList: 23 | - name: coredns 24 | -------------------------------------------------------------------------------- /pkg/tnf/handlers/command/doc.go: -------------------------------------------------------------------------------- 1 | // Copyright (C) 2020-2022 Red Hat, Inc. 2 | // This program is free software; you can redistribute it and/or modify 3 | // it under the terms of the GNU General Public License as published by 4 | // the Free Software Foundation; either version 2 of the License, or 5 | // (at your option) any later version. 6 | // 7 | // This program is distributed in the hope that it will be useful, 8 | // but WITHOUT ANY WARRANTY; without even the implied warranty of 9 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 10 | // GNU General Public License for more details. 11 | // 12 | // You should have received a copy of the GNU General Public License along 13 | // with this program; if not, write to the Free Software Foundation, Inc., 14 | // 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. 15 | 16 | // Package command provides a test for command. 17 | package command 18 | -------------------------------------------------------------------------------- /cmd/ssh/doc.go: -------------------------------------------------------------------------------- 1 | // Copyright (C) 2020-2022 Red Hat, Inc. 2 | // 3 | // This program is free software; you can redistribute it and/or modify 4 | // it under the terms of the GNU General Public License as published by 5 | // the Free Software Foundation; either version 2 of the License, or 6 | // (at your option) any later version. 7 | // 8 | // This program is distributed in the hope that it will be useful, 9 | // but WITHOUT ANY WARRANTY; without even the implied warranty of 10 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 11 | // GNU General Public License for more details. 12 | // 13 | // You should have received a copy of the GNU General Public License along 14 | // with this program; if not, write to the Free Software Foundation, Inc., 15 | // 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. 16 | 17 | // Package main provides an example of establishing an SSH session 18 | package main 19 | -------------------------------------------------------------------------------- /pkg/tnf/handlers/daemonset/doc.go: -------------------------------------------------------------------------------- 1 | // Copyright (C) 2020-2022 Red Hat, Inc. 2 | // This program is free software; you can redistribute it and/or modify 3 | // it under the terms of the GNU General Public License as published by 4 | // the Free Software Foundation; either version 2 of the License, or 5 | // (at your option) any later version. 6 | // 7 | // This program is distributed in the hope that it will be useful, 8 | // but WITHOUT ANY WARRANTY; without even the implied warranty of 9 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 10 | // GNU General Public License for more details. 11 | // 12 | // You should have received a copy of the GNU General Public License along 13 | // with this program; if not, write to the Free Software Foundation, Inc., 14 | // 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. 15 | 16 | // Package daemonset provides a test for daemonset. 17 | package daemonset 18 | -------------------------------------------------------------------------------- /pkg/tnf/handlers/liveness/doc.go: -------------------------------------------------------------------------------- 1 | // Copyright (C) 2020-2022 Red Hat, Inc. 2 | // This program is free software; you can redistribute it and/or modify 3 | // it under the terms of the GNU General Public License as published by 4 | // the Free Software Foundation; either version 2 of the License, or 5 | // (at your option) any later version. 6 | // 7 | // This program is distributed in the hope that it will be useful, 8 | // but WITHOUT ANY WARRANTY; without even the implied warranty of 9 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 10 | // GNU General Public License for more details. 11 | // 12 | // You should have received a copy of the GNU General Public License along 13 | // with this program; if not, write to the Free Software Foundation, Inc., 14 | // 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. 15 | 16 | // Package liveness provides a test for liveness. 17 | package liveness 18 | -------------------------------------------------------------------------------- /pkg/tnf/handlers/readiness/doc.go: -------------------------------------------------------------------------------- 1 | // Copyright (C) 2020-2022 Red Hat, Inc. 2 | // This program is free software; you can redistribute it and/or modify 3 | // it under the terms of the GNU General Public License as published by 4 | // the Free Software Foundation; either version 2 of the License, or 5 | // (at your option) any later version. 6 | // 7 | // This program is distributed in the hope that it will be useful, 8 | // but WITHOUT ANY WARRANTY; without even the implied warranty of 9 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 10 | // GNU General Public License for more details. 11 | // 12 | // You should have received a copy of the GNU General Public License along 13 | // with this program; if not, write to the Free Software Foundation, Inc., 14 | // 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. 15 | 16 | // Package readiness provides a test for readiness. 17 | package readiness 18 | -------------------------------------------------------------------------------- /cmd/ping/doc.go: -------------------------------------------------------------------------------- 1 | // Copyright (C) 2020-2022 Red Hat, Inc. 2 | // 3 | // This program is free software; you can redistribute it and/or modify 4 | // it under the terms of the GNU General Public License as published by 5 | // the Free Software Foundation; either version 2 of the License, or 6 | // (at your option) any later version. 7 | // 8 | // This program is distributed in the hope that it will be useful, 9 | // but WITHOUT ANY WARRANTY; without even the implied warranty of 10 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 11 | // GNU General Public License for more details. 12 | // 13 | // You should have received a copy of the GNU General Public License along 14 | // with this program; if not, write to the Free Software Foundation, Inc., 15 | // 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. 16 | 17 | // Package main provides an example of pinging a target IP address. 18 | package main 19 | -------------------------------------------------------------------------------- /pkg/tnf/doc.go: -------------------------------------------------------------------------------- 1 | // Copyright (C) 2020-2022 Red Hat, Inc. 2 | // 3 | // This program is free software; you can redistribute it and/or modify 4 | // it under the terms of the GNU General Public License as published by 5 | // the Free Software Foundation; either version 2 of the License, or 6 | // (at your option) any later version. 7 | // 8 | // This program is distributed in the hope that it will be useful, 9 | // but WITHOUT ANY WARRANTY; without even the implied warranty of 10 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 11 | // GNU General Public License for more details. 12 | // 13 | // You should have received a copy of the GNU General Public License along 14 | // with this program; if not, write to the Free Software Foundation, Inc., 15 | // 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. 16 | 17 | /* 18 | Package tnf contains the core Test runner interfaces. 19 | */ 20 | package tnf 21 | -------------------------------------------------------------------------------- /pkg/config/autodiscover/helm_info.go: -------------------------------------------------------------------------------- 1 | package autodiscover 2 | 3 | import ( 4 | "github.com/test-network-function/test-network-function/pkg/tnf/interactive" 5 | "github.com/test-network-function/test-network-function/pkg/utils" 6 | ) 7 | 8 | type HelmSetList struct { 9 | Items []HelmChart `json:""` 10 | } 11 | type HelmChart struct { 12 | Name string `json:"name"` 13 | Namespace string `json:"namespace"` 14 | Chart string `json:"chart"` 15 | } 16 | 17 | func GetClusterHelmCharts() (*HelmSetList, error) { 18 | var helmList HelmSetList 19 | 20 | out, err := utils.ExecuteCommand("helm list -A -o json", ocCommandTimeOut, interactive.GetContext(expectersVerboseModeEnabled)) 21 | if err != nil { 22 | return &helmList, err 23 | } 24 | 25 | if out != "" { 26 | err := jsonUnmarshal([]byte(out), &helmList.Items) 27 | if err != nil { 28 | return nil, err 29 | } 30 | } 31 | return &helmList, nil 32 | } 33 | -------------------------------------------------------------------------------- /pkg/tnf/handlers/owners/doc.go: -------------------------------------------------------------------------------- 1 | // Copyright (C) 2021 Red Hat, Inc. 2 | // 3 | // This program is free software; you can redistribute it and/or modify 4 | // it under the terms of the GNU General Public License as published by 5 | // the Free Software Foundation; either version 2 of the License, or 6 | // (at your option) any later version. 7 | // 8 | // This program is distributed in the hope that it will be useful, 9 | // but WITHOUT ANY WARRANTY; without even the implied warranty of 10 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 11 | // GNU General Public License for more details. 12 | // 13 | // You should have received a copy of the GNU General Public License along 14 | // with this program; if not, write to the Free Software Foundation, Inc., 15 | // 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. 16 | 17 | // Package owners provides a test for testing the pod's owners 18 | package owners 19 | -------------------------------------------------------------------------------- /pkg/tnf/handlers/checksubscription/check-subscription.json: -------------------------------------------------------------------------------- 1 | { 2 | "identifier": { 3 | "url": "http://test-network-function.com/tests/operator/check-subscription", 4 | "version": "v1.0.0" 5 | }, 6 | "description": "This test checks the subscription for a given operator, verifying that the operator was installed using OLM.", 7 | "testResult": 0, 8 | "testTimeout": 10000000000, 9 | "reelFirstStep": { 10 | "execute": "oc get subscription {{.SUBSCRIPTION_NAME}} -n {{.SUBSCRIPTION_NAMESPACE}} -o json | jq -r '.metadata.name'\n", 11 | "expect": [ 12 | "(?m)Error from server.*", 13 | "{{.SUBSCRIPTION_NAME}}" 14 | ], 15 | "timeout": 10000000000 16 | }, 17 | "resultContexts": [ 18 | { 19 | "pattern": "(?m)Error from server.*", 20 | "defaultResult": 2 21 | }, 22 | { 23 | "pattern": "{{.SUBSCRIPTION_NAME}}", 24 | "defaultResult": 1 25 | } 26 | ] 27 | } 28 | -------------------------------------------------------------------------------- /pkg/tnf/handlers/scaling/doc.go: -------------------------------------------------------------------------------- 1 | // Copyright (C) 2021 Red Hat, Inc. 2 | // 3 | // This program is free software; you can redistribute it and/or modify 4 | // it under the terms of the GNU General Public License as published by 5 | // the Free Software Foundation; either version 2 of the License, or 6 | // (at your option) any later version. 7 | // 8 | // This program is distributed in the hope that it will be useful, 9 | // but WITHOUT ANY WARRANTY; without even the implied warranty of 10 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 11 | // GNU General Public License for more details. 12 | // 13 | // You should have received a copy of the GNU General Public License along 14 | // with this program; if not, write to the Free Software Foundation, Inc., 15 | // 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. 16 | 17 | // Package scaling provides a test for deployments scale in/out 18 | package scaling 19 | -------------------------------------------------------------------------------- /pkg/tnf/testcases/data/cnf/doc.go: -------------------------------------------------------------------------------- 1 | // Copyright (C) 2020-2022 Red Hat, Inc. 2 | // 3 | // This program is free software; you can redistribute it and/or modify 4 | // it under the terms of the GNU General Public License as published by 5 | // the Free Software Foundation; either version 2 of the License, or 6 | // (at your option) any later version. 7 | // 8 | // This program is distributed in the hope that it will be useful, 9 | // but WITHOUT ANY WARRANTY; without even the implied warranty of 10 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 11 | // GNU General Public License for more details. 12 | // 13 | // You should have received a copy of the GNU General Public License along 14 | // with this program; if not, write to the Free Software Foundation, Inc., 15 | // 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. 16 | 17 | // Package cnf defines various test case templates definitions. 18 | package cnf 19 | -------------------------------------------------------------------------------- /pkg/tnf/handlers/doc.go: -------------------------------------------------------------------------------- 1 | // Copyright (C) 2020-2022 Red Hat, Inc. 2 | // 3 | // This program is free software; you can redistribute it and/or modify 4 | // it under the terms of the GNU General Public License as published by 5 | // the Free Software Foundation; either version 2 of the License, or 6 | // (at your option) any later version. 7 | // 8 | // This program is distributed in the hope that it will be useful, 9 | // but WITHOUT ANY WARRANTY; without even the implied warranty of 10 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 11 | // GNU General Public License for more details. 12 | // 13 | // You should have received a copy of the GNU General Public License along 14 | // with this program; if not, write to the Free Software Foundation, Inc., 15 | // 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. 16 | 17 | // Package handlers provides a variety of Test Handler implementations. 18 | package handlers 19 | -------------------------------------------------------------------------------- /pkg/tnf/handlers/nodeuncordon/doc.go: -------------------------------------------------------------------------------- 1 | // Copyright (C) 2021 Red Hat, Inc. 2 | // 3 | // This program is free software; you can redistribute it and/or modify 4 | // it under the terms of the GNU General Public License as published by 5 | // the Free Software Foundation; either version 2 of the License, or 6 | // (at your option) any later version. 7 | // 8 | // This program is distributed in the hope that it will be useful, 9 | // but WITHOUT ANY WARRANTY; without even the implied warranty of 10 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 11 | // GNU General Public License for more details. 12 | // 13 | // You should have received a copy of the GNU General Public License along 14 | // with this program; if not, write to the Free Software Foundation, Inc., 15 | // 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. 16 | 17 | // Package nodeuncordon provides a Test that uncordons a Node. 18 | package nodeuncordon 19 | -------------------------------------------------------------------------------- /pkg/tnf/testcases/doc.go: -------------------------------------------------------------------------------- 1 | // Copyright (C) 2020-2022 Red Hat, Inc. 2 | // 3 | // This program is free software; you can redistribute it and/or modify 4 | // it under the terms of the GNU General Public License as published by 5 | // the Free Software Foundation; either version 2 of the License, or 6 | // (at your option) any later version. 7 | // 8 | // This program is distributed in the hope that it will be useful, 9 | // but WITHOUT ANY WARRANTY; without even the implied warranty of 10 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 11 | // GNU General Public License for more details. 12 | // 13 | // You should have received a copy of the GNU General Public License along 14 | // with this program; if not, write to the Free Software Foundation, Inc., 15 | // 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. 16 | 17 | // Package testcases defines various test case templates configurations. 18 | package testcases 19 | -------------------------------------------------------------------------------- /test-network-function/diagnostic/doc.go: -------------------------------------------------------------------------------- 1 | // Copyright (C) 2021 Red Hat, Inc. 2 | // 3 | // This program is free software; you can redistribute it and/or modify 4 | // it under the terms of the GNU General Public License as published by 5 | // the Free Software Foundation; either version 2 of the License, or 6 | // (at your option) any later version. 7 | // 8 | // This program is distributed in the hope that it will be useful, 9 | // but WITHOUT ANY WARRANTY; without even the implied warranty of 10 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 11 | // GNU General Public License for more details. 12 | // 13 | // You should have received a copy of the GNU General Public License along 14 | // with this program; if not, write to the Free Software Foundation, Inc., 15 | // 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. 16 | 17 | // Package diagnostic gathers OpenShift cluster information. 18 | package diagnostic 19 | -------------------------------------------------------------------------------- /pkg/tnf/handlers/imagepullpolicy/doc.go: -------------------------------------------------------------------------------- 1 | // Copyright (C) 2020-2022 Red Hat, Inc. 2 | // This program is free software; you can redistribute it and/or modify 3 | // it under the terms of the GNU General Public License as published by 4 | // the Free Software Foundation; either version 2 of the License, or 5 | // (at your option) any later version. 6 | // 7 | // This program is distributed in the hope that it will be useful, 8 | // but WITHOUT ANY WARRANTY; without even the implied warranty of 9 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 10 | // GNU General Public License for more details. 11 | // 12 | // You should have received a copy of the GNU General Public License along 13 | // with this program; if not, write to the Free Software Foundation, Inc., 14 | // 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. 15 | 16 | // Package imagepullpolicy provides a test for imagepullpolicy. 17 | package imagepullpolicy 18 | -------------------------------------------------------------------------------- /pkg/tnf/handlers/logging/doc.go: -------------------------------------------------------------------------------- 1 | // This program is free software; you can redistribute it and/or modify 2 | // it under the terms of the GNU General Public License as published by 3 | // the Free Software Foundation; either version 2 of the License, or 4 | // (at your option) any later version. 5 | // 6 | // This program is distributed in the hope that it will be useful, 7 | // but WITHOUT ANY WARRANTY; without even the implied warranty of 8 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 9 | // GNU General Public License for more details. 10 | // 11 | // You should have received a copy of the GNU General Public License along 12 | // with this program; if not, write to the Free Software Foundation, Inc., 13 | // 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. 14 | 15 | // Package logging provide a Tnf.Test implementation for verifying that PUT 16 | // is using stderr and stdout to print logs 17 | package logging 18 | -------------------------------------------------------------------------------- /pkg/tnf/handlers/nodenames/doc.go: -------------------------------------------------------------------------------- 1 | // Copyright (C) 2021 Red Hat, Inc. 2 | // 3 | // This program is free software; you can redistribute it and/or modify 4 | // it under the terms of the GNU General Public License as published by 5 | // the Free Software Foundation; either version 2 of the License, or 6 | // (at your option) any later version. 7 | // 8 | // This program is distributed in the hope that it will be useful, 9 | // but WITHOUT ANY WARRANTY; without even the implied warranty of 10 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 11 | // GNU General Public License for more details. 12 | // 13 | // You should have received a copy of the GNU General Public License along 14 | // with this program; if not, write to the Free Software Foundation, Inc., 15 | // 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. 16 | 17 | // Package nodenames provides a test for reading the cluster's node names 18 | package nodenames 19 | -------------------------------------------------------------------------------- /pkg/tnf/handlers/operator/doc.go: -------------------------------------------------------------------------------- 1 | // Copyright (C) 2020-2022 Red Hat, Inc. 2 | // 3 | // This program is free software; you can redistribute it and/or modify 4 | // it under the terms of the GNU General Public License as published by 5 | // the Free Software Foundation; either version 2 of the License, or 6 | // (at your option) any later version. 7 | // 8 | // This program is distributed in the hope that it will be useful, 9 | // but WITHOUT ANY WARRANTY; without even the implied warranty of 10 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 11 | // GNU General Public License for more details. 12 | // 13 | // You should have received a copy of the GNU General Public License along 14 | // with this program; if not, write to the Free Software Foundation, Inc., 15 | // 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. 16 | 17 | // Package operator provides functionality to run tests on operators. 18 | package operator 19 | -------------------------------------------------------------------------------- /pkg/tnf/handlers/podnodename/doc.go: -------------------------------------------------------------------------------- 1 | // Copyright (C) 2021 Red Hat, Inc. 2 | // 3 | // This program is free software; you can redistribute it and/or modify 4 | // it under the terms of the GNU General Public License as published by 5 | // the Free Software Foundation; either version 2 of the License, or 6 | // (at your option) any later version. 7 | // 8 | // This program is distributed in the hope that it will be useful, 9 | // but WITHOUT ANY WARRANTY; without even the implied warranty of 10 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 11 | // GNU General Public License for more details. 12 | // 13 | // You should have received a copy of the GNU General Public License along 14 | // with this program; if not, write to the Free Software Foundation, Inc., 15 | // 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. 16 | 17 | // Package podnodename provides a test for reading the CNF pod's node 18 | package podnodename 19 | -------------------------------------------------------------------------------- /pkg/tnf/handlers/automountservice/doc.go: -------------------------------------------------------------------------------- 1 | // Copyright (C) 2020-2022 Red Hat, Inc. 2 | // This program is free software; you can redistribute it and/or modify 3 | // it under the terms of the GNU General Public License as published by 4 | // the Free Software Foundation; either version 2 of the License, or 5 | // (at your option) any later version. 6 | // 7 | // This program is distributed in the hope that it will be useful, 8 | // but WITHOUT ANY WARRANTY; without even the implied warranty of 9 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 10 | // GNU General Public License for more details. 11 | // 12 | // You should have received a copy of the GNU General Public License along 13 | // with this program; if not, write to the Free Software Foundation, Inc., 14 | // 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. 15 | 16 | // Package automountservice provides a test for automountservice. 17 | package automountservice 18 | -------------------------------------------------------------------------------- /pkg/tnf/handlers/generic/condition/doc.go: -------------------------------------------------------------------------------- 1 | // Copyright (C) 2020-2022 Red Hat, Inc. 2 | // 3 | // This program is free software; you can redistribute it and/or modify 4 | // it under the terms of the GNU General Public License as published by 5 | // the Free Software Foundation; either version 2 of the License, or 6 | // (at your option) any later version. 7 | // 8 | // This program is distributed in the hope that it will be useful, 9 | // but WITHOUT ANY WARRANTY; without even the implied warranty of 10 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 11 | // GNU General Public License for more details. 12 | // 13 | // You should have received a copy of the GNU General Public License along 14 | // with this program; if not, write to the Free Software Foundation, Inc., 15 | // 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. 16 | 17 | // Package condition defines the Condition Evaluate contract. 18 | package condition 19 | -------------------------------------------------------------------------------- /pkg/tnf/handlers/nodedebug/doc.go: -------------------------------------------------------------------------------- 1 | // Copyright (C) 2021 Red Hat, Inc. 2 | // 3 | // This program is free software; you can redistribute it and/or modify 4 | // it under the terms of the GNU General Public License as published by 5 | // the Free Software Foundation; either version 2 of the License, or 6 | // (at your option) any later version. 7 | // 8 | // This program is distributed in the hope that it will be useful, 9 | // but WITHOUT ANY WARRANTY; without even the implied warranty of 10 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 11 | // GNU General Public License for more details. 12 | // 13 | // You should have received a copy of the GNU General Public License along 14 | // with this program; if not, write to the Free Software Foundation, Inc., 15 | // 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. 16 | 17 | // Package nodedebug provides a test for executing a shell command in a node 18 | package nodedebug 19 | -------------------------------------------------------------------------------- /pkg/tnf/handlers/nodemcname/doc.go: -------------------------------------------------------------------------------- 1 | // Copyright (C) 2021 Red Hat, Inc. 2 | // 3 | // This program is free software; you can redistribute it and/or modify 4 | // it under the terms of the GNU General Public License as published by 5 | // the Free Software Foundation; either version 2 of the License, or 6 | // (at your option) any later version. 7 | // 8 | // This program is distributed in the hope that it will be useful, 9 | // but WITHOUT ANY WARRANTY; without even the implied warranty of 10 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 11 | // GNU General Public License for more details. 12 | // 13 | // You should have received a copy of the GNU General Public License along 14 | // with this program; if not, write to the Free Software Foundation, Inc., 15 | // 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. 16 | 17 | // Package nodemcname provides a test for reading a node's current mc name 18 | package nodemcname 19 | -------------------------------------------------------------------------------- /pkg/tnf/handlers/shutdown/doc.go: -------------------------------------------------------------------------------- 1 | // Copyright (C) 2021 Red Hat, Inc. 2 | // 3 | // This program is free software; you can redistribute it and/or modify 4 | // it under the terms of the GNU General Public License as published by 5 | // the Free Software Foundation; either version 2 of the License, or 6 | // (at your option) any later version. 7 | // 8 | // This program is distributed in the hope that it will be useful, 9 | // but WITHOUT ANY WARRANTY; without even the implied warranty of 10 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 11 | // GNU General Public License for more details. 12 | // 13 | // You should have received a copy of the GNU General Public License along 14 | // with this program; if not, write to the Free Software Foundation, Inc., 15 | // 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. 16 | 17 | // Package shutdown provides a test for checking the CNF pod's pre-stop lifecyle 18 | package shutdown 19 | -------------------------------------------------------------------------------- /pkg/tnf/testcases/data/operator/doc.go: -------------------------------------------------------------------------------- 1 | // Copyright (C) 2020-2022 Red Hat, Inc. 2 | // 3 | // This program is free software; you can redistribute it and/or modify 4 | // it under the terms of the GNU General Public License as published by 5 | // the Free Software Foundation; either version 2 of the License, or 6 | // (at your option) any later version. 7 | // 8 | // This program is distributed in the hope that it will be useful, 9 | // but WITHOUT ANY WARRANTY; without even the implied warranty of 10 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 11 | // GNU General Public License for more details. 12 | // 13 | // You should have received a copy of the GNU General Public License along 14 | // with this program; if not, write to the Free Software Foundation, Inc., 15 | // 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. 16 | 17 | // Package operator defines various test case templates definitions. 18 | package operator 19 | -------------------------------------------------------------------------------- /test-network-function/identifiers/doc.go: -------------------------------------------------------------------------------- 1 | // Copyright (C) 2021 Red Hat, Inc. 2 | // 3 | // This program is free software; you can redistribute it and/or modify 4 | // it under the terms of the GNU General Public License as published by 5 | // the Free Software Foundation; either version 2 of the License, or 6 | // (at your option) any later version. 7 | // 8 | // This program is distributed in the hope that it will be useful, 9 | // but WITHOUT ANY WARRANTY; without even the implied warranty of 10 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 11 | // GNU General Public License for more details. 12 | // 13 | // You should have received a copy of the GNU General Public License along 14 | // with this program; if not, write to the Free Software Foundation, Inc., 15 | // 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. 16 | 17 | /* 18 | Package identifiers contains TNF test identifiers. 19 | */ 20 | package identifiers 21 | -------------------------------------------------------------------------------- /pkg/config/configsections/helm.go: -------------------------------------------------------------------------------- 1 | // Copyright (C) 2021 Red Hat, Inc. 2 | // 3 | // This program is free software; you can redistribute it and/or modify 4 | // it under the terms of the GNU General Public License as published by 5 | // the Free Software Foundation; either version 2 of the License, or 6 | // (at your option) any later version. 7 | // 8 | // This program is distributed in the hope that it will be useful, 9 | // but WITHOUT ANY WARRANTY; without even the implied warranty of 10 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 11 | // GNU General Public License for more details. 12 | // 13 | // You should have received a copy of the GNU General Public License along 14 | // with this program; if not, write to the Free Software Foundation, Inc., 15 | // 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. 16 | 17 | package configsections 18 | 19 | type HelmChart struct { 20 | Version string 21 | Name string 22 | } 23 | -------------------------------------------------------------------------------- /pkg/tnf/dependencies/doc.go: -------------------------------------------------------------------------------- 1 | // Copyright (C) 2020-2022 Red Hat, Inc. 2 | // 3 | // This program is free software; you can redistribute it and/or modify 4 | // it under the terms of the GNU General Public License as published by 5 | // the Free Software Foundation; either version 2 of the License, or 6 | // (at your option) any later version. 7 | // 8 | // This program is distributed in the hope that it will be useful, 9 | // but WITHOUT ANY WARRANTY; without even the implied warranty of 10 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 11 | // GNU General Public License for more details. 12 | // 13 | // You should have received a copy of the GNU General Public License along 14 | // with this program; if not, write to the Free Software Foundation, Inc., 15 | // 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. 16 | 17 | // Package dependencies provides constants related to test runtime dependencies. 18 | package dependencies 19 | -------------------------------------------------------------------------------- /pkg/tnf/handlers/crdstatusexistence/crdstatusexistence.json: -------------------------------------------------------------------------------- 1 | { 2 | "identifier": { 3 | "url": "http://test-network-function.com/tests/crdStatusExistence", 4 | "version": "v1.0.0" 5 | }, 6 | "description": "This test checks whether a given CRD has defined status subresource spec for all its versions.", 7 | "testResult": 0, 8 | "testTimeout": {{ .TIMEOUT }}, 9 | "reelFirstStep": { 10 | "execute": 11 | "oc get crd {{ .CRD_NAME }} -o json | jq -r '[.spec.versions[]] | if all(.schema.openAPIV3Schema.properties.status) then \"OK\" else \"FAIL\" end'", 12 | "expect": [ 13 | "(?m)OK", 14 | "(?m)FAIL" 15 | ], 16 | "timeout": {{ .TIMEOUT }} 17 | }, 18 | "resultContexts": [ 19 | { 20 | "pattern": "(?m)OK", 21 | "defaultResult": 1 22 | }, 23 | { 24 | "pattern": "(?m)FAIL", 25 | "defaultResult": 2 26 | } 27 | ] 28 | } 29 | -------------------------------------------------------------------------------- /pkg/tnf/handlers/csidriver/doc.go: -------------------------------------------------------------------------------- 1 | // Copyright (C) 2021 Red Hat, Inc. 2 | // 3 | // This program is free software; you can redistribute it and/or modify 4 | // it under the terms of the GNU General Public License as published by 5 | // the Free Software Foundation; either version 2 of the License, or 6 | // (at your option) any later version. 7 | // 8 | // This program is distributed in the hope that it will be useful, 9 | // but WITHOUT ANY WARRANTY; without even the implied warranty of 10 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 11 | // GNU General Public License for more details. 12 | // 13 | // You should have received a copy of the GNU General Public License along 14 | // with this program; if not, write to the Free Software Foundation, Inc., 15 | // 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. 16 | 17 | // Package csidriver provides a test for reading the CNF cluster csi driver info 18 | package csidriver 19 | -------------------------------------------------------------------------------- /pkg/tnf/handlers/nodeport/doc.go: -------------------------------------------------------------------------------- 1 | // Copyright (C) 2021 Red Hat, Inc. 2 | // 3 | // This program is free software; you can redistribute it and/or modify 4 | // it under the terms of the GNU General Public License as published by 5 | // the Free Software Foundation; either version 2 of the License, or 6 | // (at your option) any later version. 7 | // 8 | // This program is distributed in the hope that it will be useful, 9 | // but WITHOUT ANY WARRANTY; without even the implied warranty of 10 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 11 | // GNU General Public License for more details. 12 | // 13 | // You should have received a copy of the GNU General Public License along 14 | // with this program; if not, write to the Free Software Foundation, Inc., 15 | // 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. 16 | 17 | // Package nodeport provides a test for testing services in the CNF pod's namespace 18 | package nodeport 19 | -------------------------------------------------------------------------------- /pkg/tnf/handlers/ping/doc.go: -------------------------------------------------------------------------------- 1 | // Copyright (C) 2020-2022 Red Hat, Inc. 2 | // 3 | // This program is free software; you can redistribute it and/or modify 4 | // it under the terms of the GNU General Public License as published by 5 | // the Free Software Foundation; either version 2 of the License, or 6 | // (at your option) any later version. 7 | // 8 | // This program is distributed in the hope that it will be useful, 9 | // but WITHOUT ANY WARRANTY; without even the implied warranty of 10 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 11 | // GNU General Public License for more details. 12 | // 13 | // You should have received a copy of the GNU General Public License along 14 | // with this program; if not, write to the Free Software Foundation, Inc., 15 | // 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. 16 | 17 | // Package ping provides a test ICMPv4 implementation using the `ping` Unix command. 18 | package ping 19 | -------------------------------------------------------------------------------- /pkg/tnf/handlers/rolebinding/doc.go: -------------------------------------------------------------------------------- 1 | // Copyright (C) 2021 Red Hat, Inc. 2 | // 3 | // This program is free software; you can redistribute it and/or modify 4 | // it under the terms of the GNU General Public License as published by 5 | // the Free Software Foundation; either version 2 of the License, or 6 | // (at your option) any later version. 7 | // 8 | // This program is distributed in the hope that it will be useful, 9 | // but WITHOUT ANY WARRANTY; without even the implied warranty of 10 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 11 | // GNU General Public License for more details. 12 | // 13 | // You should have received a copy of the GNU General Public License along 14 | // with this program; if not, write to the Free Software Foundation, Inc., 15 | // 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. 16 | 17 | // Package rolebinding provides a test for reading the CNF pod's RoleBindings 18 | package rolebinding 19 | -------------------------------------------------------------------------------- /.github/workflows/merge.yaml: -------------------------------------------------------------------------------- 1 | name: build 2 | 3 | on: 4 | pull_request: 5 | types: [ closed ] 6 | 7 | jobs: 8 | 9 | build: 10 | if: github.event.pull_request.merged == true 11 | name: Run Tests 12 | runs-on: ubuntu-latest 13 | steps: 14 | 15 | - name: Set up Go 1.17 16 | uses: actions/setup-go@v2 17 | with: 18 | go-version: 1.17.9 19 | 20 | - name: Check out code into the Go module directory 21 | uses: actions/checkout@v2 22 | 23 | - name: Rebuild mocks 24 | run: go install github.com/golang/mock/mockgen@v1.6.0 && make mocks 25 | 26 | - name: Run Tests 27 | run: make test 28 | env: 29 | SHELL: /bin/bash 30 | 31 | close_job: 32 | if: github.event.pull_request.merged == false 33 | runs-on: ubuntu-latest 34 | steps: 35 | - run: | 36 | echo PR #${{ github.event.number }} has been closed without being merged 37 | 38 | -------------------------------------------------------------------------------- /pkg/jsonschema/doc.go: -------------------------------------------------------------------------------- 1 | // Copyright (C) 2021 Red Hat, Inc. 2 | // 3 | // This program is free software; you can redistribute it and/or modify 4 | // it under the terms of the GNU General Public License as published by 5 | // the Free Software Foundation; either version 2 of the License, or 6 | // (at your option) any later version. 7 | // 8 | // This program is distributed in the hope that it will be useful, 9 | // but WITHOUT ANY WARRANTY; without even the implied warranty of 10 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 11 | // GNU General Public License for more details. 12 | // 13 | // You should have received a copy of the GNU General Public License along 14 | // with this program; if not, write to the Free Software Foundation, Inc., 15 | // 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. 16 | 17 | /* 18 | Package jsonschema provides utilities to validate input against a given schema. 19 | */ 20 | package jsonschema 21 | -------------------------------------------------------------------------------- /pkg/tnf/handlers/clusterversion/doc.go: -------------------------------------------------------------------------------- 1 | // Copyright (C) 2021 Red Hat, Inc. 2 | // 3 | // This program is free software; you can redistribute it and/or modify 4 | // it under the terms of the GNU General Public License as published by 5 | // the Free Software Foundation; either version 2 of the License, or 6 | // (at your option) any later version. 7 | // 8 | // This program is distributed in the hope that it will be useful, 9 | // but WITHOUT ANY WARRANTY; without even the implied warranty of 10 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 11 | // GNU General Public License for more details. 12 | // 13 | // You should have received a copy of the GNU General Public License along 14 | // with this program; if not, write to the Free Software Foundation, Inc., 15 | // 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. 16 | 17 | // Package clusterversion provides a test for reading the cluster's node names 18 | package clusterversion 19 | -------------------------------------------------------------------------------- /pkg/tnf/handlers/container/doc.go: -------------------------------------------------------------------------------- 1 | // Copyright (C) 2020-2022 Red Hat, Inc. 2 | // 3 | // This program is free software; you can redistribute it and/or modify 4 | // it under the terms of the GNU General Public License as published by 5 | // the Free Software Foundation; either version 2 of the License, or 6 | // (at your option) any later version. 7 | // 8 | // This program is distributed in the hope that it will be useful, 9 | // but WITHOUT ANY WARRANTY; without even the implied warranty of 10 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 11 | // GNU General Public License for more details. 12 | // 13 | // You should have received a copy of the GNU General Public License along 14 | // with this program; if not, write to the Free Software Foundation, Inc., 15 | // 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. 16 | 17 | // Package container provides functionality to test pod and container level checks. 18 | package container 19 | -------------------------------------------------------------------------------- /pkg/tnf/handlers/ipaddr/doc.go: -------------------------------------------------------------------------------- 1 | // Copyright (C) 2020-2022 Red Hat, Inc. 2 | // 3 | // This program is free software; you can redistribute it and/or modify 4 | // it under the terms of the GNU General Public License as published by 5 | // the Free Software Foundation; either version 2 of the License, or 6 | // (at your option) any later version. 7 | // 8 | // This program is distributed in the hope that it will be useful, 9 | // but WITHOUT ANY WARRANTY; without even the implied warranty of 10 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 11 | // GNU General Public License for more details. 12 | // 13 | // You should have received a copy of the GNU General Public License along 14 | // with this program; if not, write to the Free Software Foundation, Inc., 15 | // 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. 16 | 17 | // Package ipaddr provides an ip address polling test utilizing the `ip` Unix command. 18 | package ipaddr 19 | -------------------------------------------------------------------------------- /pkg/tnf/handlers/nodetainted/doc.go: -------------------------------------------------------------------------------- 1 | // Copyright (C) 2021 Red Hat, Inc. 2 | // 3 | // This program is free software; you can redistribute it and/or modify 4 | // it under the terms of the GNU General Public License as published by 5 | // the Free Software Foundation; either version 2 of the License, or 6 | // (at your option) any later version. 7 | // 8 | // This program is distributed in the hope that it will be useful, 9 | // but WITHOUT ANY WARRANTY; without even the implied warranty of 10 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 11 | // GNU General Public License for more details. 12 | // 13 | // You should have received a copy of the GNU General Public License along 14 | // with this program; if not, write to the Free Software Foundation, Inc., 15 | // 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. 16 | 17 | // Package nodetainted provides a test for verifying cluster nodes are not tainted 18 | package nodetainted 19 | -------------------------------------------------------------------------------- /cmd/oc/doc.go: -------------------------------------------------------------------------------- 1 | // Copyright (C) 2020-2022 Red Hat, Inc. 2 | // 3 | // This program is free software; you can redistribute it and/or modify 4 | // it under the terms of the GNU General Public License as published by 5 | // the Free Software Foundation; either version 2 of the License, or 6 | // (at your option) any later version. 7 | // 8 | // This program is distributed in the hope that it will be useful, 9 | // but WITHOUT ANY WARRANTY; without even the implied warranty of 10 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 11 | // GNU General Public License for more details. 12 | // 13 | // You should have received a copy of the GNU General Public License along 14 | // with this program; if not, write to the Free Software Foundation, Inc., 15 | // 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. 16 | 17 | // Package main provides an example of spawning an OpenShift client and using it to ping a target IP address. 18 | package main 19 | -------------------------------------------------------------------------------- /test-network-function/results/doc.go: -------------------------------------------------------------------------------- 1 | // Copyright (C) 2021 Red Hat, Inc. 2 | // 3 | // This program is free software; you can redistribute it and/or modify 4 | // it under the terms of the GNU General Public License as published by 5 | // the Free Software Foundation; either version 2 of the License, or 6 | // (at your option) any later version. 7 | // 8 | // This program is distributed in the hope that it will be useful, 9 | // but WITHOUT ANY WARRANTY; without even the implied warranty of 10 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 11 | // GNU General Public License for more details. 12 | // 13 | // You should have received a copy of the GNU General Public License along 14 | // with this program; if not, write to the Free Software Foundation, Inc., 15 | // 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. 16 | 17 | /* 18 | Package results contains a Codec to convert JUnit results to claim Results. 19 | */ 20 | package results 21 | -------------------------------------------------------------------------------- /pkg/junit/doc.go: -------------------------------------------------------------------------------- 1 | // Copyright (C) 2020-2022 Red Hat, Inc. 2 | // 3 | // This program is free software; you can redistribute it and/or modify 4 | // it under the terms of the GNU General Public License as published by 5 | // the Free Software Foundation; either version 2 of the License, or 6 | // (at your option) any later version. 7 | // 8 | // This program is distributed in the hope that it will be useful, 9 | // but WITHOUT ANY WARRANTY; without even the implied warranty of 10 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 11 | // GNU General Public License for more details. 12 | // 13 | // You should have received a copy of the GNU General Public License along 14 | // with this program; if not, write to the Free Software Foundation, Inc., 15 | // 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. 16 | 17 | /* 18 | Package junit provides utility conversion methods for encoding JUnit XML results to generic JSON. 19 | */ 20 | package junit 21 | -------------------------------------------------------------------------------- /pkg/tnf/handlers/mckernelarguments/doc.go: -------------------------------------------------------------------------------- 1 | // Copyright (C) 2021 Red Hat, Inc. 2 | // 3 | // This program is free software; you can redistribute it and/or modify 4 | // it under the terms of the GNU General Public License as published by 5 | // the Free Software Foundation; either version 2 of the License, or 6 | // (at your option) any later version. 7 | // 8 | // This program is distributed in the hope that it will be useful, 9 | // but WITHOUT ANY WARRANTY; without even the implied warranty of 10 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 11 | // GNU General Public License for more details. 12 | // 13 | // You should have received a copy of the GNU General Public License along 14 | // with this program; if not, write to the Free Software Foundation, Inc., 15 | // 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. 16 | 17 | // Package mckernelarguments provides a test for reading an mc's kernel arguments 18 | package mckernelarguments 19 | -------------------------------------------------------------------------------- /pkg/config/configsections/hpa.go: -------------------------------------------------------------------------------- 1 | // Copyright (C) 2021 Red Hat, Inc. 2 | // 3 | // This program is free software; you can redistribute it and/or modify 4 | // it under the terms of the GNU General Public License as published by 5 | // the Free Software Foundation; either version 2 of the License, or 6 | // (at your option) any later version. 7 | // 8 | // This program is distributed in the hope that it will be useful, 9 | // but WITHOUT ANY WARRANTY; without even the implied warranty of 10 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 11 | // GNU General Public License for more details. 12 | // 13 | // You should have received a copy of the GNU General Public License along 14 | // with this program; if not, write to the Free Software Foundation, Inc., 15 | // 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. 16 | 17 | package configsections 18 | 19 | type Hpa struct { 20 | MinReplicas int 21 | MaxReplicas int 22 | HpaName string 23 | } 24 | -------------------------------------------------------------------------------- /pkg/tnf/handlers/deploymentsdrain/doc.go: -------------------------------------------------------------------------------- 1 | // Copyright (C) 2021 Red Hat, Inc. 2 | // 3 | // This program is free software; you can redistribute it and/or modify 4 | // it under the terms of the GNU General Public License as published by 5 | // the Free Software Foundation; either version 2 of the License, or 6 | // (at your option) any later version. 7 | // 8 | // This program is distributed in the hope that it will be useful, 9 | // but WITHOUT ANY WARRANTY; without even the implied warranty of 10 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 11 | // GNU General Public License for more details. 12 | // 13 | // You should have received a copy of the GNU General Public License along 14 | // with this program; if not, write to the Free Software Foundation, Inc., 15 | // 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. 16 | 17 | // Package deploymentsdrain provides a test for draining a node from deployments pods 18 | package deploymentsdrain 19 | -------------------------------------------------------------------------------- /pkg/tnf/handlers/handler_template/doc.tmpl: -------------------------------------------------------------------------------- 1 | // Copyright (C) 2020-2022 Red Hat, Inc. 2 | // This program is free software; you can redistribute it and/or modify 3 | // it under the terms of the GNU General Public License as published by 4 | // the Free Software Foundation; either version 2 of the License, or 5 | // (at your option) any later version. 6 | // 7 | // This program is distributed in the hope that it will be useful, 8 | // but WITHOUT ANY WARRANTY; without even the implied warranty of 9 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 10 | // GNU General Public License for more details. 11 | // 12 | // You should have received a copy of the GNU General Public License along 13 | // with this program; if not, write to the Free Software Foundation, Inc., 14 | // 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. 15 | 16 | // Package {{ .LowerHandlername }} provides a test for {{ .LowerHandlername }}. 17 | package {{ .LowerHandlername }} 18 | -------------------------------------------------------------------------------- /pkg/tnf/handlers/nodeselector/doc.go: -------------------------------------------------------------------------------- 1 | // Copyright (C) 2021 Red Hat, Inc. 2 | // 3 | // This program is free software; you can redistribute it and/or modify 4 | // it under the terms of the GNU General Public License as published by 5 | // the Free Software Foundation; either version 2 of the License, or 6 | // (at your option) any later version. 7 | // 8 | // This program is distributed in the hope that it will be useful, 9 | // but WITHOUT ANY WARRANTY; without even the implied warranty of 10 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 11 | // GNU General Public License for more details. 12 | // 13 | // You should have received a copy of the GNU General Public License along 14 | // with this program; if not, write to the Free Software Foundation, Inc., 15 | // 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. 16 | 17 | // Package nodeselector provides a test for reading the CNF pod's nodeSelector and nodeAffinity 18 | package nodeselector 19 | -------------------------------------------------------------------------------- /test-network-function/doc.go: -------------------------------------------------------------------------------- 1 | // Copyright (C) 2020-2022 Red Hat, Inc. 2 | // 3 | // This program is free software; you can redistribute it and/or modify 4 | // it under the terms of the GNU General Public License as published by 5 | // the Free Software Foundation; either version 2 of the License, or 6 | // (at your option) any later version. 7 | // 8 | // This program is distributed in the hope that it will be useful, 9 | // but WITHOUT ANY WARRANTY; without even the implied warranty of 10 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 11 | // GNU General Public License for more details. 12 | // 13 | // You should have received a copy of the GNU General Public License along 14 | // with this program; if not, write to the Free Software Foundation, Inc., 15 | // 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. 16 | 17 | /* 18 | Package suite provides the entrypoint for running ginkgo tests and producing a claim file. 19 | */ 20 | package suite 21 | -------------------------------------------------------------------------------- /test-network-function/operator/doc.go: -------------------------------------------------------------------------------- 1 | // Copyright (C) 2020-2022 Red Hat, Inc. 2 | // 3 | // This program is free software; you can redistribute it and/or modify 4 | // it under the terms of the GNU General Public License as published by 5 | // the Free Software Foundation; either version 2 of the License, or 6 | // (at your option) any later version. 7 | // 8 | // This program is distributed in the hope that it will be useful, 9 | // but WITHOUT ANY WARRANTY; without even the implied warranty of 10 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 11 | // GNU General Public License for more details. 12 | // 13 | // You should have received a copy of the GNU General Public License along 14 | // with this program; if not, write to the Free Software Foundation, Inc., 15 | // 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. 16 | 17 | /* 18 | Package operator provides Ginkgo tests used to validate operator CNF facets. 19 | */ 20 | package operator 21 | -------------------------------------------------------------------------------- /pkg/tnf/handlers/clusterrolebinding/doc.go: -------------------------------------------------------------------------------- 1 | // Copyright (C) 2021 Red Hat, Inc. 2 | // 3 | // This program is free software; you can redistribute it and/or modify 4 | // it under the terms of the GNU General Public License as published by 5 | // the Free Software Foundation; either version 2 of the License, or 6 | // (at your option) any later version. 7 | // 8 | // This program is distributed in the hope that it will be useful, 9 | // but WITHOUT ANY WARRANTY; without even the implied warranty of 10 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 11 | // GNU General Public License for more details. 12 | // 13 | // You should have received a copy of the GNU General Public License along 14 | // with this program; if not, write to the Free Software Foundation, Inc., 15 | // 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. 16 | 17 | // Package clusterrolebinding provides a test for reading the CNF pod's ClusterRoleBinding 18 | package clusterrolebinding 19 | -------------------------------------------------------------------------------- /pkg/tnf/handlers/cnffsdiff/doc.go: -------------------------------------------------------------------------------- 1 | // Copyright (C) 2021 Red Hat, Inc. 2 | // 3 | // This program is free software; you can redistribute it and/or modify 4 | // it under the terms of the GNU General Public License as published by 5 | // the Free Software Foundation; either version 2 of the License, or 6 | // (at your option) any later version. 7 | // 8 | // This program is distributed in the hope that it will be useful, 9 | // but WITHOUT ANY WARRANTY; without even the implied warranty of 10 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 11 | // GNU General Public License for more details. 12 | // 13 | // You should have received a copy of the GNU General Public License along 14 | // with this program; if not, write to the Free Software Foundation, Inc., 15 | // 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. 16 | 17 | // Package cnffsdiff provides a test to check if a something was installed on the container during runtime. 18 | package cnffsdiff 19 | -------------------------------------------------------------------------------- /pkg/tnf/handlers/generic/condition/intcondition/doc.go: -------------------------------------------------------------------------------- 1 | // Copyright (C) 2020-2022 Red Hat, Inc. 2 | // 3 | // This program is free software; you can redistribute it and/or modify 4 | // it under the terms of the GNU General Public License as published by 5 | // the Free Software Foundation; either version 2 of the License, or 6 | // (at your option) any later version. 7 | // 8 | // This program is distributed in the hope that it will be useful, 9 | // but WITHOUT ANY WARRANTY; without even the implied warranty of 10 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 11 | // GNU General Public License for more details. 12 | // 13 | // You should have received a copy of the GNU General Public License along 14 | // with this program; if not, write to the Free Software Foundation, Inc., 15 | // 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. 16 | 17 | // Package intcondition exposes some common integer condition implementations. 18 | package intcondition 19 | -------------------------------------------------------------------------------- /pkg/tnf/handlers/readbootconfig/doc.go: -------------------------------------------------------------------------------- 1 | // Copyright (C) 2021 Red Hat, Inc. 2 | // 3 | // This program is free software; you can redistribute it and/or modify 4 | // it under the terms of the GNU General Public License as published by 5 | // the Free Software Foundation; either version 2 of the License, or 6 | // (at your option) any later version. 7 | // 8 | // This program is distributed in the hope that it will be useful, 9 | // but WITHOUT ANY WARRANTY; without even the implied warranty of 10 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 11 | // GNU General Public License for more details. 12 | // 13 | // You should have received a copy of the GNU General Public License along 14 | // with this program; if not, write to the Free Software Foundation, Inc., 15 | // 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. 16 | 17 | // Package readbootconfig provides a test for reading an node's next boot config /boot directory 18 | package readbootconfig 19 | -------------------------------------------------------------------------------- /pkg/tnf/handlers/bootconfigentries/doc.go: -------------------------------------------------------------------------------- 1 | // Copyright (C) 2021 Red Hat, Inc. 2 | // 3 | // This program is free software; you can redistribute it and/or modify 4 | // it under the terms of the GNU General Public License as published by 5 | // the Free Software Foundation; either version 2 of the License, or 6 | // (at your option) any later version. 7 | // 8 | // This program is distributed in the hope that it will be useful, 9 | // but WITHOUT ANY WARRANTY; without even the implied warranty of 10 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 11 | // GNU General Public License for more details. 12 | // 13 | // You should have received a copy of the GNU General Public License along 14 | // with this program; if not, write to the Free Software Foundation, Inc., 15 | // 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. 16 | 17 | // Package bootconfigentries provides a test for reading an node's next boot config /boot directory 18 | package bootconfigentries 19 | -------------------------------------------------------------------------------- /pkg/tnf/handlers/currentkernelcmdlineargs/doc.go: -------------------------------------------------------------------------------- 1 | // Copyright (C) 2021 Red Hat, Inc. 2 | // 3 | // This program is free software; you can redistribute it and/or modify 4 | // it under the terms of the GNU General Public License as published by 5 | // the Free Software Foundation; either version 2 of the License, or 6 | // (at your option) any later version. 7 | // 8 | // This program is distributed in the hope that it will be useful, 9 | // but WITHOUT ANY WARRANTY; without even the implied warranty of 10 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 11 | // GNU General Public License for more details. 12 | // 13 | // You should have received a copy of the GNU General Public License along 14 | // with this program; if not, write to the Free Software Foundation, Inc., 15 | // 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. 16 | 17 | // Package currentkernelcmdlineargs provides a test for reading an mc's kernel arguments 18 | package currentkernelcmdlineargs 19 | -------------------------------------------------------------------------------- /pkg/tnf/handlers/generic/condition/stringcondition/doc.go: -------------------------------------------------------------------------------- 1 | // Copyright (C) 2020-2022 Red Hat, Inc. 2 | // 3 | // This program is free software; you can redistribute it and/or modify 4 | // it under the terms of the GNU General Public License as published by 5 | // the Free Software Foundation; either version 2 of the License, or 6 | // (at your option) any later version. 7 | // 8 | // This program is distributed in the hope that it will be useful, 9 | // but WITHOUT ANY WARRANTY; without even the implied warranty of 10 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 11 | // GNU General Public License for more details. 12 | // 13 | // You should have received a copy of the GNU General Public License along 14 | // with this program; if not, write to the Free Software Foundation, Inc., 15 | // 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. 16 | 17 | // Package stringcondition exposes some common string condition implementations. 18 | package stringcondition 19 | -------------------------------------------------------------------------------- /pkg/tnf/handlers/podsets/doc.go: -------------------------------------------------------------------------------- 1 | // Copyright (C) 2021 Red Hat, Inc. 2 | // 3 | // This program is free software; you can redistribute it and/or modify 4 | // it under the terms of the GNU General Public License as published by 5 | // the Free Software Foundation; either version 2 of the License, or 6 | // (at your option) any later version. 7 | // 8 | // This program is distributed in the hope that it will be useful, 9 | // but WITHOUT ANY WARRANTY; without even the implied warranty of 10 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 11 | // GNU General Public License for more details. 12 | // 13 | // You should have received a copy of the GNU General Public License along 14 | // with this program; if not, write to the Free Software Foundation, Inc., 15 | // 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. 16 | 17 | // Package PodSet-deployments/statefulsets provides a test for reading the namespace's PodSet deployments/statefulsets 18 | package podsets 19 | -------------------------------------------------------------------------------- /pkg/tnf/identifier/doc.go: -------------------------------------------------------------------------------- 1 | // Copyright (C) 2020-2022 Red Hat, Inc. 2 | // 3 | // This program is free software; you can redistribute it and/or modify 4 | // it under the terms of the GNU General Public License as published by 5 | // the Free Software Foundation; either version 2 of the License, or 6 | // (at your option) any later version. 7 | // 8 | // This program is distributed in the hope that it will be useful, 9 | // but WITHOUT ANY WARRANTY; without even the implied warranty of 10 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 11 | // GNU General Public License for more details. 12 | // 13 | // You should have received a copy of the GNU General Public License along 14 | // with this program; if not, write to the Free Software Foundation, Inc., 15 | // 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. 16 | 17 | // Package identifier provides a test identifier definition for tnf.Test implementations and a catalog of known tests. 18 | package identifier 19 | -------------------------------------------------------------------------------- /pkg/tnf/handlers/base/redhat/doc.go: -------------------------------------------------------------------------------- 1 | // Copyright (C) 2020-2022 Red Hat, Inc. 2 | // 3 | // This program is free software; you can redistribute it and/or modify 4 | // it under the terms of the GNU General Public License as published by 5 | // the Free Software Foundation; either version 2 of the License, or 6 | // (at your option) any later version. 7 | // 8 | // This program is distributed in the hope that it will be useful, 9 | // but WITHOUT ANY WARRANTY; without even the implied warranty of 10 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 11 | // GNU General Public License for more details. 12 | // 13 | // You should have received a copy of the GNU General Public License along 14 | // with this program; if not, write to the Free Software Foundation, Inc., 15 | // 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. 16 | 17 | // Package redhat provides a tnf.Test implementation which tests whether a container is based on Red Hat technologies. 18 | package redhat 19 | -------------------------------------------------------------------------------- /pkg/tnf/handlers/sysctlallconfigsargs/doc.go: -------------------------------------------------------------------------------- 1 | // Copyright (C) 2021 Red Hat, Inc. 2 | // 3 | // This program is free software; you can redistribute it and/or modify 4 | // it under the terms of the GNU General Public License as published by 5 | // the Free Software Foundation; either version 2 of the License, or 6 | // (at your option) any later version. 7 | // 8 | // This program is distributed in the hope that it will be useful, 9 | // but WITHOUT ANY WARRANTY; without even the implied warranty of 10 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 11 | // GNU General Public License for more details. 12 | // 13 | // You should have received a copy of the GNU General Public License along 14 | // with this program; if not, write to the Free Software Foundation, Inc., 15 | // 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. 16 | 17 | // Package sysctlallconfigsargs provides a test for reading an node's list of sysctl config files 18 | package sysctlallconfigsargs 19 | -------------------------------------------------------------------------------- /test-network-function/common/doc.go: -------------------------------------------------------------------------------- 1 | // Copyright (C) 2020-2022 Red Hat, Inc. 2 | // 3 | // This program is free software; you can redistribute it and/or modify 4 | // it under the terms of the GNU General Public License as published by 5 | // the Free Software Foundation; either version 2 of the License, or 6 | // (at your option) any later version. 7 | // 8 | // This program is distributed in the hope that it will be useful, 9 | // but WITHOUT ANY WARRANTY; without even the implied warranty of 10 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 11 | // GNU General Public License for more details. 12 | // 13 | // You should have received a copy of the GNU General Public License along 14 | // with this program; if not, write to the Free Software Foundation, Inc., 15 | // 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. 16 | 17 | /* 18 | Package common contains constants, structures and utility function shared 19 | by multiple test suites. 20 | */ 21 | package common 22 | -------------------------------------------------------------------------------- /pkg/config/autodiscover/testdata/ipv4pod.json: -------------------------------------------------------------------------------- 1 | 2 | { 3 | "metadata": { 4 | "annotations": { 5 | "k8s.v1.cni.cncf.io/networks-status": "[{\n \"name\": \"\",\n \"interface\": \"LowerPriorityInterface\",\n \"ips\": [\n \"1.1.1.1\"\n ],\n \"default\": true,\n \"dns\": {}\n}]", 6 | "test-network-function.com/defaultnetworkinterface": "\"eth0\"" 7 | }, 8 | "labels": { 9 | "app": "partner", 10 | "test-network-function.com/generic": "orchestrator", 11 | "test-network-function.com/container": "target" 12 | }, 13 | "name": "I'mAPodName", 14 | "namespace": "tnf" 15 | }, 16 | "spec": { 17 | "containers": [ 18 | { 19 | "name": "I'mAContainer" 20 | } 21 | ] 22 | }, 23 | "status": { 24 | "podIPs": [ 25 | { 26 | "ip": "2.2.2.2" 27 | } 28 | ] 29 | } 30 | } -------------------------------------------------------------------------------- /pkg/tnf/handlers/crdstatusexistence/doc.go: -------------------------------------------------------------------------------- 1 | // Copyright (C) 2021 Red Hat, Inc. 2 | // 3 | // This program is free software; you can redistribute it and/or modify 4 | // it under the terms of the GNU General Public License as published by 5 | // the Free Software Foundation; either version 2 of the License, or 6 | // (at your option) any later version. 7 | // 8 | // This program is distributed in the hope that it will be useful, 9 | // but WITHOUT ANY WARRANTY; without even the implied warranty of 10 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 11 | // GNU General Public License for more details. 12 | // 13 | // You should have received a copy of the GNU General Public License along 14 | // with this program; if not, write to the Free Software Foundation, Inc., 15 | // 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. 16 | 17 | // Package crdstatusexistence provides a test for checking the existence of status subresource in a given CRD. 18 | package crdstatusexistence 19 | -------------------------------------------------------------------------------- /pkg/tnf/handlers/deploymentsnodes/doc.go: -------------------------------------------------------------------------------- 1 | // Copyright (C) 2021 Red Hat, Inc. 2 | // 3 | // This program is free software; you can redistribute it and/or modify 4 | // it under the terms of the GNU General Public License as published by 5 | // the Free Software Foundation; either version 2 of the License, or 6 | // (at your option) any later version. 7 | // 8 | // This program is distributed in the hope that it will be useful, 9 | // but WITHOUT ANY WARRANTY; without even the implied warranty of 10 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 11 | // GNU General Public License for more details. 12 | // 13 | // You should have received a copy of the GNU General Public License along 14 | // with this program; if not, write to the Free Software Foundation, Inc., 15 | // 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. 16 | 17 | // Package deploymentsnodes provides a test for reading node names of pods owned by deployments in a namespace 18 | package deploymentsnodes 19 | -------------------------------------------------------------------------------- /test-network-function/generic/doc.go: -------------------------------------------------------------------------------- 1 | // Copyright (C) 2020-2022 Red Hat, Inc. 2 | // 3 | // This program is free software; you can redistribute it and/or modify 4 | // it under the terms of the GNU General Public License as published by 5 | // the Free Software Foundation; either version 2 of the License, or 6 | // (at your option) any later version. 7 | // 8 | // This program is distributed in the hope that it will be useful, 9 | // but WITHOUT ANY WARRANTY; without even the implied warranty of 10 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 11 | // GNU General Public License for more details. 12 | // 13 | // You should have received a copy of the GNU General Public License along 14 | // with this program; if not, write to the Free Software Foundation, Inc., 15 | // 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. 16 | 17 | /* 18 | Package generic contains generally applicable tests, and utilities for managing 19 | their configuration. 20 | */ 21 | package generic 22 | -------------------------------------------------------------------------------- /pkg/tnf/handlers/generic/assertion/doc.go: -------------------------------------------------------------------------------- 1 | // Copyright (C) 2020-2022 Red Hat, Inc. 2 | // 3 | // This program is free software; you can redistribute it and/or modify 4 | // it under the terms of the GNU General Public License as published by 5 | // the Free Software Foundation; either version 2 of the License, or 6 | // (at your option) any later version. 7 | // 8 | // This program is distributed in the hope that it will be useful, 9 | // but WITHOUT ANY WARRANTY; without even the implied warranty of 10 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 11 | // GNU General Public License for more details. 12 | // 13 | // You should have received a copy of the GNU General Public License along 14 | // with this program; if not, write to the Free Software Foundation, Inc., 15 | // 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. 16 | 17 | // Package assertion defines the ability for users to include assertions on the regular expression matched in ReelMatch. 18 | package assertion 19 | -------------------------------------------------------------------------------- /pkg/tnf/handlers/podantiaffinity/doc.go: -------------------------------------------------------------------------------- 1 | // Copyright (C) 2021 Red Hat, Inc. 2 | // 3 | // This program is free software; you can redistribute it and/or modify 4 | // it under the terms of the GNU General Public License as published by 5 | // the Free Software Foundation; either version 2 of the License, or 6 | // (at your option) any later version. 7 | // 8 | // This program is distributed in the hope that it will be useful, 9 | // but WITHOUT ANY WARRANTY; without even the implied warranty of 10 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 11 | // GNU General Public License for more details. 12 | // 13 | // You should have received a copy of the GNU General Public License along 14 | // with this program; if not, write to the Free Software Foundation, Inc., 15 | // 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. 16 | 17 | // Package podantiaffinity provides a test for reading the CNF pod's podantiaffinity rule when relica is great than 1 18 | package podantiaffinity 19 | -------------------------------------------------------------------------------- /pkg/tnf/interactive/doc.go: -------------------------------------------------------------------------------- 1 | // Copyright (C) 2020-2022 Red Hat, Inc. 2 | // 3 | // This program is free software; you can redistribute it and/or modify 4 | // it under the terms of the GNU General Public License as published by 5 | // the Free Software Foundation; either version 2 of the License, or 6 | // (at your option) any later version. 7 | // 8 | // This program is distributed in the hope that it will be useful, 9 | // but WITHOUT ANY WARRANTY; without even the implied warranty of 10 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 11 | // GNU General Public License for more details. 12 | // 13 | // You should have received a copy of the GNU General Public License along 14 | // with this program; if not, write to the Free Software Foundation, Inc., 15 | // 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. 16 | 17 | // Package interactive provides common implementations of the expect.Expecter interface including oc, shell, ssh, and 18 | // pty. 19 | package interactive 20 | -------------------------------------------------------------------------------- /pkg/config/autodiscover/testdata/ipv6pod.json: -------------------------------------------------------------------------------- 1 | 2 | { 3 | "metadata": { 4 | "annotations": { 5 | "k8s.v1.cni.cncf.io/networks-status": "[{\n \"name\": \"\",\n \"interface\": \"LowerPriorityInterface\",\n \"ips\": [\n \"1.1.1.1\"\n ],\n \"default\": true,\n \"dns\": {}\n}]", 6 | "test-network-function.com/defaultnetworkinterface": "\"eth0\"" 7 | }, 8 | "labels": { 9 | "app": "partner", 10 | "test-network-function.com/generic": "orchestrator", 11 | "test-network-function.com/container": "target" 12 | }, 13 | "name": "I'mAPodName", 14 | "namespace": "tnf" 15 | }, 16 | "spec": { 17 | "containers": [ 18 | { 19 | "name": "I'mAContainer" 20 | } 21 | ] 22 | }, 23 | "status": { 24 | "podIPs": [ 25 | { 26 | "ip": "fd00:10:244:1::3" 27 | } 28 | ] 29 | } 30 | } -------------------------------------------------------------------------------- /pkg/config/autodiscover/testdata/testorchestrator.json: -------------------------------------------------------------------------------- 1 | 2 | { 3 | "metadata": { 4 | "annotations": { 5 | "k8s.v1.cni.cncf.io/networks-status": "[{\n \"name\": \"\",\n \"interface\": \"LowerPriorityInterface\",\n \"ips\": [\n \"1.1.1.1\"\n ],\n \"default\": true,\n \"dns\": {}\n}]", 6 | "test-network-function.com/defaultnetworkinterface": "\"eth0\"" 7 | }, 8 | "labels": { 9 | "app": "partner", 10 | "test-network-function.com/generic": "orchestrator", 11 | "test-network-function.com/container": "target" 12 | }, 13 | "name": "I'mAPodName", 14 | "namespace": "tnf" 15 | }, 16 | "spec": { 17 | "containers": [ 18 | { 19 | "name": "I'mAContainer" 20 | } 21 | ] 22 | }, 23 | "status": { 24 | "podIPs": [ 25 | { 26 | "ip": "2.2.2.2" 27 | } 28 | ] 29 | } 30 | } -------------------------------------------------------------------------------- /test-network-function/networking/doc.go: -------------------------------------------------------------------------------- 1 | // Copyright (C) 2020-2022 Red Hat, Inc. 2 | // 3 | // This program is free software; you can redistribute it and/or modify 4 | // it under the terms of the GNU General Public License as published by 5 | // the Free Software Foundation; either version 2 of the License, or 6 | // (at your option) any later version. 7 | // 8 | // This program is distributed in the hope that it will be useful, 9 | // but WITHOUT ANY WARRANTY; without even the implied warranty of 10 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 11 | // GNU General Public License for more details. 12 | // 13 | // You should have received a copy of the GNU General Public License along 14 | // with this program; if not, write to the Free Software Foundation, Inc., 15 | // 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. 16 | 17 | /* 18 | Package networking contains tests that check connectivity and networking config 19 | related best practices. 20 | */ 21 | package networking 22 | -------------------------------------------------------------------------------- /test-network-function/accesscontrol/doc.go: -------------------------------------------------------------------------------- 1 | // Copyright (C) 2020-2022 Red Hat, Inc. 2 | // 3 | // This program is free software; you can redistribute it and/or modify 4 | // it under the terms of the GNU General Public License as published by 5 | // the Free Software Foundation; either version 2 of the License, or 6 | // (at your option) any later version. 7 | // 8 | // This program is distributed in the hope that it will be useful, 9 | // but WITHOUT ANY WARRANTY; without even the implied warranty of 10 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 11 | // GNU General Public License for more details. 12 | // 13 | // You should have received a copy of the GNU General Public License along 14 | // with this program; if not, write to the Free Software Foundation, Inc., 15 | // 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. 16 | 17 | /* 18 | Package accesscontrol contains tests related to pod privilege, role-binding, 19 | namespace, host resource etc. 20 | */ 21 | package accesscontrol 22 | -------------------------------------------------------------------------------- /test-network-function/lifecycle/doc.go: -------------------------------------------------------------------------------- 1 | // Copyright (C) 2020-2022 Red Hat, Inc. 2 | // 3 | // This program is free software; you can redistribute it and/or modify 4 | // it under the terms of the GNU General Public License as published by 5 | // the Free Software Foundation; either version 2 of the License, or 6 | // (at your option) any later version. 7 | // 8 | // This program is distributed in the hope that it will be useful, 9 | // but WITHOUT ANY WARRANTY; without even the implied warranty of 10 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 11 | // GNU General Public License for more details. 12 | // 13 | // You should have received a copy of the GNU General Public License along 14 | // with this program; if not, write to the Free Software Foundation, Inc., 15 | // 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. 16 | 17 | /* 18 | Package lifecycle contains k8s resource lifecycle related tests, such as pod 19 | scheduling, scaling, termination etc. 20 | */ 21 | package lifecycle 22 | -------------------------------------------------------------------------------- /pkg/tnf/handlers/imagepullpolicy/imagepullpolicy.json: -------------------------------------------------------------------------------- 1 | { 2 | "identifier" : { 3 | "url" : "http://test-network-function.com/tests/imagepullpolicy", 4 | "version": "v1.0.0" 5 | }, 6 | "description": "A generic test used to get Image Pull Policy type", 7 | "testResult": 0, 8 | "testTimeout": 5000000000, 9 | "reelFirstStep": { 10 | "execute": "oc get pod {{.POD_NAME}} -n {{.POD_NAMESPACE}} -o json | jq -r '.spec.containers[{{.CONTAINER_NUM}}].imagePullPolicy'", 11 | "expect":["(?m)IfNotPresent", 12 | "(?m)Always", 13 | "(?m)Never", 14 | "(?)"], 15 | "timeout": 5000000000 16 | }, 17 | "resultContexts":[ 18 | { 19 | "pattern": "(?m)IfNotPresent", 20 | "defaultResult": 1 21 | }, 22 | { 23 | "pattern": "(?m)Always", 24 | "defaultResult": 2 25 | }, 26 | { 27 | "pattern": "(?m)Never", 28 | "defaultResult": 2 29 | } 30 | ] 31 | } 32 | -------------------------------------------------------------------------------- /test-network-function/platform/doc.go: -------------------------------------------------------------------------------- 1 | // Copyright (C) 2020-2022 Red Hat, Inc. 2 | // 3 | // This program is free software; you can redistribute it and/or modify 4 | // it under the terms of the GNU General Public License as published by 5 | // the Free Software Foundation; either version 2 of the License, or 6 | // (at your option) any later version. 7 | // 8 | // This program is distributed in the hope that it will be useful, 9 | // but WITHOUT ANY WARRANTY; without even the implied warranty of 10 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 11 | // GNU General Public License for more details. 12 | // 13 | // You should have received a copy of the GNU General Public License along 14 | // with this program; if not, write to the Free Software Foundation, Inc., 15 | // 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. 16 | 17 | /* 18 | Package platform contains tests related to platform alteration such as kernel 19 | taint, boot param, huge page config, base image etc 20 | */ 21 | package platform 22 | -------------------------------------------------------------------------------- /pkg/tnf/reel/doc.go: -------------------------------------------------------------------------------- 1 | // Copyright (C) 2020-2022 Red Hat, Inc. 2 | // 3 | // This program is free software; you can redistribute it and/or modify 4 | // it under the terms of the GNU General Public License as published by 5 | // the Free Software Foundation; either version 2 of the License, or 6 | // (at your option) any later version. 7 | // 8 | // This program is distributed in the hope that it will be useful, 9 | // but WITHOUT ANY WARRANTY; without even the implied warranty of 10 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 11 | // GNU General Public License for more details. 12 | // 13 | // You should have received a copy of the GNU General Public License along 14 | // with this program; if not, write to the Free Software Foundation, Inc., 15 | // 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. 16 | 17 | /* 18 | Package reel runs a target subprocess with programmatic control over interaction with it. 19 | Programmatic control uses a Read-Execute-Expect-Loop ("REEL") pattern. 20 | */ 21 | package reel 22 | -------------------------------------------------------------------------------- /pkg/tnf/handlers/checksubscription/doc.go: -------------------------------------------------------------------------------- 1 | // Copyright (C) 2021 Red Hat, Inc. 2 | // 3 | // This program is free software; you can redistribute it and/or modify 4 | // it under the terms of the GNU General Public License as published by 5 | // the Free Software Foundation; either version 2 of the License, or 6 | // (at your option) any later version. 7 | // 8 | // This program is distributed in the hope that it will be useful, 9 | // but WITHOUT ANY WARRANTY; without even the implied warranty of 10 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 11 | // GNU General Public License for more details. 12 | // 13 | // You should have received a copy of the GNU General Public License along 14 | // with this program; if not, write to the Free Software Foundation, Inc., 15 | // 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. 16 | 17 | // Package checksubscription provides a Test that checks the subscription for a given operator. This verifies that the 18 | // operator was installed using OLM. 19 | package checksubscription 20 | -------------------------------------------------------------------------------- /test-network-function/observability/doc.go: -------------------------------------------------------------------------------- 1 | // Copyright (C) 2020-2022 Red Hat, Inc. 2 | // 3 | // This program is free software; you can redistribute it and/or modify 4 | // it under the terms of the GNU General Public License as published by 5 | // the Free Software Foundation; either version 2 of the License, or 6 | // (at your option) any later version. 7 | // 8 | // This program is distributed in the hope that it will be useful, 9 | // but WITHOUT ANY WARRANTY; without even the implied warranty of 10 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 11 | // GNU General Public License for more details. 12 | // 13 | // You should have received a copy of the GNU General Public License along 14 | // with this program; if not, write to the Free Software Foundation, Inc., 15 | // 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. 16 | 17 | /* 18 | Package observability contains tests related to the observability of the 19 | CNF workloads under test, such as logging, status reporting etc 20 | */ 21 | package observability 22 | -------------------------------------------------------------------------------- /pkg/config/testdata/tnf_test_config.yml: -------------------------------------------------------------------------------- 1 | testTarget: 2 | containersUnderTest: 3 | - namespace: default 4 | podName: test 5 | containerName: test 6 | defaultNetworkDevice: eth0 7 | multusIpAddresses: 8 | - 10.217.0.8 9 | operators: 10 | - name: etcdoperator.v0.9.4 11 | namespace: default 12 | autogenerate: false 13 | tests: 14 | - OPERATOR_STATUS 15 | podsUnderTest: # FKA cnfs 16 | - name: ubuntu 17 | namespace: default 18 | tests: 19 | - PRIVILEGED_POD 20 | - PRIVILEGED_ROLE 21 | deploymentsUnderTest: 22 | - name: test 23 | namespace: default 24 | replicas: 2 25 | 26 | certifiedcontainerinfo: 27 | - name: nginx-116 # working example 28 | repository: rhel8 29 | certifiedoperatorinfo: 30 | - name: etcd-operator 31 | organization: redhat-marketplace 32 | acceptedKernelTaints: 33 | - module: "taint1" 34 | - module: "taint2" 35 | targetCrdFilters: 36 | - nameSuffix: "group1.test1.com" 37 | - nameSuffix: "test2.com" 38 | -------------------------------------------------------------------------------- /test-network-function/certification/doc.go: -------------------------------------------------------------------------------- 1 | // Copyright (C) 2020-2022 Red Hat, Inc. 2 | // 3 | // This program is free software; you can redistribute it and/or modify 4 | // it under the terms of the GNU General Public License as published by 5 | // the Free Software Foundation; either version 2 of the License, or 6 | // (at your option) any later version. 7 | // 8 | // This program is distributed in the hope that it will be useful, 9 | // but WITHOUT ANY WARRANTY; without even the implied warranty of 10 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 11 | // GNU General Public License for more details. 12 | // 13 | // You should have received a copy of the GNU General Public License along 14 | // with this program; if not, write to the Free Software Foundation, Inc., 15 | // 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. 16 | 17 | /* 18 | Package certification contains tests that retrieve results from other 19 | affiliated certification project through an API query, e.g. CVP and OVP 20 | */ 21 | package certification 22 | -------------------------------------------------------------------------------- /script/run-cfd-container.sh: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bash 2 | 3 | if [ "$TNF_RUN_CFD_TEST" == "true" ]; then 4 | 5 | export TNF_IMAGE_NAME=cnf-tests 6 | export TNF_IMAGE_TAG="${TNF_CFD_IMAGE_TAG:-4.6}" 7 | export TNF_OFFICIAL_ORG=quay.io/openshift-kni/ 8 | export TNF_OFFICIAL_IMAGE="${TNF_OFFICIAL_ORG}${TNF_IMAGE_NAME}:${TNF_IMAGE_TAG}" 9 | export TNF_CFD_SKIP="${TNF_CFD_SKIP:-performance|sriov|ptp|sctp|xt_u32|dpdk|ovn}" 10 | export TNF_CMD="/usr/bin/test-run.sh" 11 | export OUTPUT_ARG="--junit" 12 | export CONTAINER_NETWORK_MODE="host" 13 | 14 | if [[ -n "$KUBECONFIG" ]]; then 15 | export LOCAL_KUBECONFIG=$KUBECONFIG 16 | elif [[ -f "$HOME/.kube/config" ]]; then 17 | export LOCAL_KUBECONFIG=$HOME/.kube/config 18 | fi 19 | 20 | # For older verions of docker, dns server may need to be set explicitly, e.g. 21 | # 22 | # export DNS_ARG=172.0.0.53 23 | ./run-container.sh -ginkgo.v -ginkgo.skip=${TNF_CFD_SKIP} 24 | else 25 | # removing report if not running, so the final claim won't include stale reports 26 | rm -f ${OUTPUT_LOC}/validation_junit.xml 27 | fi -------------------------------------------------------------------------------- /pkg/config/configsections/crdfilter.go: -------------------------------------------------------------------------------- 1 | // Copyright (C) 2021 Red Hat, Inc. 2 | // 3 | // This program is free software; you can redistribute it and/or modify 4 | // it under the terms of the GNU General Public License as published by 5 | // the Free Software Foundation; either version 2 of the License, or 6 | // (at your option) any later version. 7 | // 8 | // This program is distributed in the hope that it will be useful, 9 | // but WITHOUT ANY WARRANTY; without even the implied warranty of 10 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 11 | // GNU General Public License for more details. 12 | // 13 | // You should have received a copy of the GNU General Public License along 14 | // with this program; if not, write to the Free Software Foundation, Inc., 15 | // 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. 16 | 17 | package configsections 18 | 19 | // CrdFilter defines a CustomResourceDefinition config filter. 20 | type CrdFilter struct { 21 | NameSuffix string `yaml:"nameSuffix" json:"nameSuffix"` 22 | // labels []Label 23 | } 24 | -------------------------------------------------------------------------------- /pkg/config/autodiscover/testdata/ipv4ipv6pod.json: -------------------------------------------------------------------------------- 1 | 2 | { 3 | "metadata": { 4 | "annotations": { 5 | "k8s.v1.cni.cncf.io/networks-status": "[{\n \"name\": \"\",\n \"interface\": \"LowerPriorityInterface\",\n \"ips\": [\n \"1.1.1.1\"\n ],\n \"default\": true,\n \"dns\": {}\n}]", 6 | "test-network-function.com/defaultnetworkinterface": "\"eth0\"" 7 | }, 8 | "labels": { 9 | "app": "partner", 10 | "test-network-function.com/generic": "orchestrator", 11 | "test-network-function.com/container": "target" 12 | }, 13 | "name": "I'mAPodName", 14 | "namespace": "tnf" 15 | }, 16 | "spec": { 17 | "containers": [ 18 | { 19 | "name": "I'mAContainer" 20 | } 21 | ] 22 | }, 23 | "status": { 24 | "podIPs": [ 25 | { 26 | "ip": "2.2.2.2" 27 | }, 28 | { 29 | "ip": "fd00:10:244:1::3" 30 | } 31 | ] 32 | } 33 | } -------------------------------------------------------------------------------- /pkg/tnf/handlers/generic/doc.go: -------------------------------------------------------------------------------- 1 | // Copyright (C) 2020-2022 Red Hat, Inc. 2 | // 3 | // This program is free software; you can redistribute it and/or modify 4 | // it under the terms of the GNU General Public License as published by 5 | // the Free Software Foundation; either version 2 of the License, or 6 | // (at your option) any later version. 7 | // 8 | // This program is distributed in the hope that it will be useful, 9 | // but WITHOUT ANY WARRANTY; without even the implied warranty of 10 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 11 | // GNU General Public License for more details. 12 | // 13 | // You should have received a copy of the GNU General Public License along 14 | // with this program; if not, write to the Free Software Foundation, Inc., 15 | // 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. 16 | 17 | /* 18 | Package generic provides a simplified interface for creating a tnf.Test and corresponding reel.Handler from generic JSON 19 | input. This exposes the ability for test writers to create tests using only JSON. 20 | */ 21 | package generic 22 | -------------------------------------------------------------------------------- /pkg/tnf/handlers/podantiaffinity/podantiaffinity.json: -------------------------------------------------------------------------------- 1 | { 2 | "identifier": { 3 | "url": "http://test-network-function.com/tests/testPodHighAvailability", 4 | "version": "v1.0.0" 5 | }, 6 | "description": "This test checks cnf pod antiaffinity rule in cnf deployment.", 7 | "testResult": 0, 8 | "testTimeout": 10000000000, 9 | "reelFirstStep": { 10 | "execute": 11 | "oc get deployment {{.DEPLOYMENT_NAME}} -n {{.DEPLOYMENT_NAMESPACE}} -o json | jq -r ' if .spec.replicas > 1 then if .spec.template.spec.affinity.podAntiAffinity != null then \"OK\" else \"Antiaffinity missing\" end else \"Replica count is 1\" end '\n", 12 | "expect": [ 13 | "(?m)OK", 14 | "(?m)Antiaffinity missing", 15 | "(?m)Replica count is 1" 16 | ], 17 | "timeout": 10000000000 18 | }, 19 | "resultContexts": [ 20 | { 21 | "pattern": "(?m)OK", 22 | "defaultResult": 1 23 | }, 24 | { 25 | "pattern": "(?m)Antiaffinity missing", 26 | "defaultResult": 2 27 | }, 28 | { 29 | "pattern": "(?m)Replica count is 1", 30 | "defaultResult": 2 31 | } 32 | ] 33 | } 34 | -------------------------------------------------------------------------------- /pkg/tnf/handlers/generic/testdata/assertion_error.json: -------------------------------------------------------------------------------- 1 | { 2 | "identifier": { 3 | "url": "http://test-network-function.com/tests/unit/assertion_error", 4 | "version": "v1.0.0" 5 | }, 6 | "description": "checks for RHEL version.", 7 | "reelFirstStep": { 8 | "execute": "if [ -e /etc/redhat-release ]; then cat /etc/redhat-release; else echo \"Unknown Base Image\"; fi\n", 9 | "expect": [ 10 | "(?m)Red Hat Enterprise Linux Server release (\\d+\\.\\d+) \\((\\w+)\\)" 11 | ], 12 | "timeout": 2000000000 13 | }, 14 | "resultContexts": [ 15 | { 16 | "pattern": "(?m)Red Hat Enterprise Linux Server release (\\d+\\.\\d+) \\((\\w+)\\)", 17 | "defaultResult": 1, 18 | "composedAssertions": [ 19 | { 20 | "assertions": [ 21 | { 22 | "groupIdx": 1, 23 | "condition": { 24 | "type": "isInt" 25 | } 26 | } 27 | ], 28 | "logic": { 29 | "type": "and" 30 | } 31 | } 32 | ] 33 | } 34 | ], 35 | "testResult": 0, 36 | "testTimeout": 2000000000 37 | } 38 | -------------------------------------------------------------------------------- /pkg/tnf/testcases/files/cnf/privilegedroles.yml: -------------------------------------------------------------------------------- 1 | testcase: 2 | - name: CLUSTER_ROLE_BINDING_BY_SA 3 | skiptest: false 4 | command: "oc get clusterrolebinding -n %s -o json | jq --arg name 'ServiceAccount' --arg null ',null,' --arg subjects 'subjects' --arg ns '%s' --arg sa '%s' -jr 'if (.items|length)>0 then .items[] | if (has($subjects)) then .subjects[] | select((.namespace==$ns) and (.kind==$name) and (.name==$sa)).name else $null end else $null end'" 5 | action: deny 6 | resulttype: "string" 7 | expectedType: "function" 8 | expectedstatus: 9 | - "FN_SERVICE_ACCOUNT_NAME" 10 | - name: ROLE_BINDING_BY_SA 11 | skiptest: false 12 | command: "oc get rolebinding -n %s -o json | jq --arg name 'ServiceAccount' --arg null ',null,' --arg ns '%s' --arg subjects 'subjects' --arg sa '%s' -jr 'if (.items|length)>0 then .items[] | if (has($subjects)) then .subjects[] | select((.namespace==$ns) and (.kind==$name) and (.name==$sa)).name else $null end else $null end'" 13 | action: allow 14 | resulttype: "string" 15 | expectedType: "function" 16 | expectedstatus: 17 | - "FN_SERVICE_ACCOUNT_NAME" 18 | - "null" 19 | -------------------------------------------------------------------------------- /pkg/tnf/handlers/ping/testdata/hostname_no_packet_loss.txt: -------------------------------------------------------------------------------- 1 | PING www.google.com (172.217.12.132) 56(84) bytes of data. 2 | 64 bytes from lga34s19-in-f4.1e100.net (172.217.12.132): icmp_seq=1 ttl=61 time=25.4 ms 3 | 64 bytes from lga34s19-in-f4.1e100.net (172.217.12.132): icmp_seq=2 ttl=61 time=27.1 ms 4 | 64 bytes from lga34s19-in-f4.1e100.net (172.217.12.132): icmp_seq=3 ttl=61 time=26.7 ms 5 | 64 bytes from lga34s19-in-f4.1e100.net (172.217.12.132): icmp_seq=4 ttl=61 time=24.2 ms 6 | 64 bytes from lga34s19-in-f4.1e100.net (172.217.12.132): icmp_seq=5 ttl=61 time=28.0 ms 7 | 64 bytes from lga34s19-in-f4.1e100.net (172.217.12.132): icmp_seq=6 ttl=61 time=37.0 ms 8 | 64 bytes from lga34s19-in-f4.1e100.net (172.217.12.132): icmp_seq=7 ttl=61 time=21.6 ms 9 | 64 bytes from lga34s19-in-f4.1e100.net (172.217.12.132): icmp_seq=8 ttl=61 time=30.6 ms 10 | 64 bytes from lga34s19-in-f4.1e100.net (172.217.12.132): icmp_seq=9 ttl=61 time=27.3 ms 11 | 64 bytes from lga34s19-in-f4.1e100.net (172.217.12.132): icmp_seq=10 ttl=61 time=27.9 ms 12 | 13 | --- www.google.com ping statistics --- 14 | 10 packets transmitted, 10 received, 0% packet loss, time 9014ms 15 | rtt min/avg/max/mdev = 21.650/27.619/37.003/3.885 ms 16 | -------------------------------------------------------------------------------- /cmd/tnf/main.go: -------------------------------------------------------------------------------- 1 | package main 2 | 3 | import ( 4 | log "github.com/sirupsen/logrus" 5 | "github.com/spf13/cobra" 6 | 7 | claim "github.com/test-network-function/test-network-function/cmd/tnf/addclaim" 8 | "github.com/test-network-function/test-network-function/cmd/tnf/generate/catalog" 9 | "github.com/test-network-function/test-network-function/cmd/tnf/generate/handler" 10 | "github.com/test-network-function/test-network-function/cmd/tnf/grade" 11 | "github.com/test-network-function/test-network-function/cmd/tnf/jsontest" 12 | ) 13 | 14 | var ( 15 | rootCmd = &cobra.Command{ 16 | Use: "tnf", 17 | Short: "A CLI for creating, validating , and test-network-function tests.", 18 | } 19 | 20 | generate = &cobra.Command{ 21 | Use: "generate", 22 | Short: "generator tool for various tnf artifacts.", 23 | } 24 | ) 25 | 26 | func main() { 27 | rootCmd.AddCommand(claim.NewCommand()) 28 | rootCmd.AddCommand(generate) 29 | generate.AddCommand(catalog.NewCommand()) 30 | generate.AddCommand(handler.NewCommand()) 31 | rootCmd.AddCommand(jsontest.NewCommand()) 32 | rootCmd.AddCommand(grade.NewCommand()) 33 | if err := rootCmd.Execute(); err != nil { 34 | log.Fatal(err) 35 | } 36 | } 37 | -------------------------------------------------------------------------------- /pkg/config/configsections/podset.go: -------------------------------------------------------------------------------- 1 | // Copyright (C) 2021 Red Hat, Inc. 2 | // 3 | // This program is free software; you can redistribute it and/or modify 4 | // it under the terms of the GNU General Public License as published by 5 | // the Free Software Foundation; either version 2 of the License, or 6 | // (at your option) any later version. 7 | // 8 | // This program is distributed in the hope that it will be useful, 9 | // but WITHOUT ANY WARRANTY; without even the implied warranty of 10 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 11 | // GNU General Public License for more details. 12 | // 13 | // You should have received a copy of the GNU General Public License along 14 | // with this program; if not, write to the Free Software Foundation, Inc., 15 | // 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. 16 | 17 | package configsections 18 | 19 | // PodSet defines a podset (deployment/Statefulset) in the cluster. 20 | type PodSet struct { 21 | Name string 22 | Namespace string 23 | Replicas int 24 | Hpa Hpa 25 | Type PodSetType 26 | } 27 | 28 | type PodSetType string 29 | 30 | const ( 31 | Deployment PodSetType = "deployment" 32 | StateFulSet PodSetType = "statefulset" 33 | ) 34 | -------------------------------------------------------------------------------- /pkg/config/doc.go: -------------------------------------------------------------------------------- 1 | // Copyright (C) 2020-2022 Red Hat, Inc. 2 | // 3 | // This program is free software; you can redistribute it and/or modify 4 | // it under the terms of the GNU General Public License as published by 5 | // the Free Software Foundation; either version 2 of the License, or 6 | // (at your option) any later version. 7 | // 8 | // This program is distributed in the hope that it will be useful, 9 | // but WITHOUT ANY WARRANTY; without even the implied warranty of 10 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 11 | // GNU General Public License for more details. 12 | // 13 | // You should have received a copy of the GNU General Public License along 14 | // with this program; if not, write to the Free Software Foundation, Inc., 15 | // 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. 16 | 17 | /* 18 | Package config provides test-network-function configuration through a central place. Configuration data 19 | is automatically included in the claim. Configuration should all be contained in a single yaml file, with each 20 | configuration area under its own key. 21 | The env var "TNF_CONFIGURATION_PATH" identifies the config file. If not set, the default of `tnf_config.yml` is used. 22 | */ 23 | package config 24 | -------------------------------------------------------------------------------- /pkg/tnf/handlers/generic/assertion/testdata/and_composed_assertions_positive_test.json: -------------------------------------------------------------------------------- 1 | { 2 | "assertions": [ 3 | { 4 | "groupIdx": 1, 5 | "condition": { 6 | "type": "equals", 7 | "expected": "iperf" 8 | } 9 | }, 10 | { 11 | "groupIdx": 2, 12 | "condition": { 13 | "type": "isInt" 14 | } 15 | }, 16 | { 17 | "groupIdx": 2, 18 | "condition": { 19 | "type": "intComparison", 20 | "comparison": "==", 21 | "input": 1 22 | } 23 | }, 24 | { 25 | "groupIdx": 2, 26 | "condition": { 27 | "type": "intComparison", 28 | "comparison": "<=", 29 | "input": 1 30 | } 31 | }, 32 | { 33 | "groupIdx": 2, 34 | "condition": { 35 | "type": "intComparison", 36 | "comparison": ">=", 37 | "input": 1 38 | } 39 | }, 40 | { 41 | "groupIdx": 2, 42 | "condition": { 43 | "type": "intComparison", 44 | "comparison": ">", 45 | "input": 0 46 | } 47 | }, 48 | { 49 | "groupIdx": 2, 50 | "condition": { 51 | "type": "intComparison", 52 | "comparison": "<", 53 | "input": 100 54 | } 55 | } 56 | ], 57 | "logic": { 58 | "type": "and" 59 | } 60 | } -------------------------------------------------------------------------------- /pkg/tnf/handlers/generic/assertion/testdata/or_composed_assertions_positive_test.json: -------------------------------------------------------------------------------- 1 | { 2 | "assertions": [ 3 | { 4 | "groupIdx": 1, 5 | "condition": { 6 | "type": "equals", 7 | "expected": "iperf" 8 | } 9 | }, 10 | { 11 | "groupIdx": 2, 12 | "condition": { 13 | "type": "isInt" 14 | } 15 | }, 16 | { 17 | "groupIdx": 2, 18 | "condition": { 19 | "type": "intComparison", 20 | "comparison": "==", 21 | "input": 100 22 | } 23 | }, 24 | { 25 | "groupIdx": 2, 26 | "condition": { 27 | "type": "intComparison", 28 | "comparison": "<=", 29 | "input": 1 30 | } 31 | }, 32 | { 33 | "groupIdx": 2, 34 | "condition": { 35 | "type": "intComparison", 36 | "comparison": ">=", 37 | "input": 1 38 | } 39 | }, 40 | { 41 | "groupIdx": 2, 42 | "condition": { 43 | "type": "intComparison", 44 | "comparison": ">", 45 | "input": 0 46 | } 47 | }, 48 | { 49 | "groupIdx": 2, 50 | "condition": { 51 | "type": "intComparison", 52 | "comparison": "<", 53 | "input": 100 54 | } 55 | } 56 | ], 57 | "logic": { 58 | "type": "or" 59 | } 60 | } -------------------------------------------------------------------------------- /pkg/config/autodiscover/operator_test.go: -------------------------------------------------------------------------------- 1 | // Copyright (C) 2021 Red Hat, Inc. 2 | // 3 | // This program is free software; you can redistribute it and/or modify 4 | // it under the terms of the GNU General Public License as published by 5 | // the Free Software Foundation; either version 2 of the License, or 6 | // (at your option) any later version. 7 | // 8 | // This program is distributed in the hope that it will be useful, 9 | // but WITHOUT ANY WARRANTY; without even the implied warranty of 10 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 11 | // GNU General Public License for more details. 12 | // 13 | // You should have received a copy of the GNU General Public License along 14 | // with this program; if not, write to the Free Software Foundation, Inc., 15 | // 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. 16 | 17 | package autodiscover 18 | 19 | import ( 20 | "testing" 21 | 22 | "github.com/stretchr/testify/assert" 23 | ) 24 | 25 | func TestBuildOperatorFromCSVResource(t *testing.T) { 26 | csvResource := loadCSVResource(csvFilePath) 27 | operator := buildOperatorFromCSVResource(&csvResource, true) 28 | 29 | assert.Equal(t, "CSVNamespace", operator.Namespace) 30 | assert.Equal(t, "CSVName", operator.Name) 31 | assert.Equal(t, []string{"OPERATOR_STATUS", "ANOTHER_TEST"}, operator.Tests) 32 | } 33 | -------------------------------------------------------------------------------- /pkg/config/autodiscover/container_test.go: -------------------------------------------------------------------------------- 1 | // Copyright (C) 2021 Red Hat, Inc. 2 | // 3 | // This program is free software; you can redistribute it and/or modify 4 | // it under the terms of the GNU General Public License as published by 5 | // the Free Software Foundation; either version 2 of the License, or 6 | // (at your option) any later version. 7 | // 8 | // This program is distributed in the hope that it will be useful, 9 | // but WITHOUT ANY WARRANTY; without even the implied warranty of 10 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 11 | // GNU General Public License for more details. 12 | // 13 | // You should have received a copy of the GNU General Public License along 14 | // with this program; if not, write to the Free Software Foundation, Inc., 15 | // 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. 16 | 17 | package autodiscover 18 | 19 | import ( 20 | "testing" 21 | 22 | "github.com/stretchr/testify/assert" 23 | ) 24 | 25 | func TestBuildContainers(t *testing.T) { 26 | subjectPod := loadPodResource(testSubjectFilePath) 27 | subjectContainers := buildContainers(&subjectPod) 28 | assert.Equal(t, 1, len(subjectContainers)) 29 | 30 | assert.Equal(t, "tnf", subjectContainers[0].Namespace) 31 | assert.Equal(t, "I'mAPodName", subjectContainers[0].PodName) 32 | assert.Equal(t, "I'mAContainer", subjectContainers[0].ContainerName) 33 | } 34 | -------------------------------------------------------------------------------- /pkg/tnf/handlers/ping/testdata/ip_address_passing_packet_loss.txt: -------------------------------------------------------------------------------- 1 | PING 192.168.1.5 (192.168.1.5) 56(84) bytes of data. 2 | 64 bytes from 192.168.1.5: icmp_seq=1 ttl=61 time=14.8 ms 3 | 64 bytes from 192.168.1.5: icmp_seq=2 ttl=61 time=11.2 ms 4 | 64 bytes from 192.168.1.5: icmp_seq=3 ttl=61 time=10.9 ms 5 | 64 bytes from 192.168.1.5: icmp_seq=5 ttl=61 time=9.68 ms 6 | 64 bytes from 192.168.1.5: icmp_seq=6 ttl=61 time=4.55 ms 7 | 64 bytes from 192.168.1.5: icmp_seq=7 ttl=61 time=3.38 ms 8 | 64 bytes from 192.168.1.5: icmp_seq=8 ttl=61 time=3.67 ms 9 | 64 bytes from 192.168.1.5: icmp_seq=9 ttl=61 time=3.77 ms 10 | 64 bytes from 192.168.1.5: icmp_seq=10 ttl=61 time=3.77 ms 11 | 64 bytes from 192.168.1.5: icmp_seq=11 ttl=61 time=3.77 ms 12 | 64 bytes from 192.168.1.5: icmp_seq=12 ttl=61 time=3.77 ms 13 | 64 bytes from 192.168.1.5: icmp_seq=13 ttl=61 time=3.77 ms 14 | 64 bytes from 192.168.1.5: icmp_seq=14 ttl=61 time=3.77 ms 15 | 64 bytes from 192.168.1.5: icmp_seq=15 ttl=61 time=3.77 ms 16 | 64 bytes from 192.168.1.5: icmp_seq=16 ttl=61 time=3.77 ms 17 | 64 bytes from 192.168.1.5: icmp_seq=17 ttl=61 time=3.77 ms 18 | 64 bytes from 192.168.1.5: icmp_seq=18 ttl=61 time=3.77 ms 19 | 64 bytes from 192.168.1.5: icmp_seq=19 ttl=61 time=3.77 ms 20 | 21 | --- 192.168.1.5 ping statistics --- 22 | 20 packets transmitted, 19 received, 5% packet loss, time 19297ms 23 | rtt min/avg/max/mdev = 3.381/7.772/14.867/4.167 ms 24 | 25 | -------------------------------------------------------------------------------- /examples/ping.json: -------------------------------------------------------------------------------- 1 | { 2 | "description": "Pings www.redhat.com 5 times using the Unix ping executable.", 3 | "testResult": 0, 4 | "testTimeout": 10000000000, 5 | "reelFirstStep": { 6 | "execute": "ping -c 5 www.redhat.com\n", 7 | "expect": [ 8 | "(?m)(\\d+) packets transmitted, (\\d+)( packets){0,1} received, (?:\\+(\\d+) errors)?.*$" 9 | ], 10 | "timeout": 10000000000 11 | }, 12 | "identifier": { 13 | "url": "http://test-network-function.com/tests/example/ping", 14 | "version": "v1.0.0" 15 | }, 16 | "resultContexts": [ 17 | { 18 | "pattern": "(?m)(\\d+) packets transmitted, (\\d+)( packets){0,1} received, (?:\\+(\\d+) errors)?.*$", 19 | "defaultResult": 1, 20 | "composedAssertions": [ 21 | { 22 | "assertions": [ 23 | { 24 | "groupIdx": 1, 25 | "condition": { 26 | "type": "intComparison", 27 | "input": 5, 28 | "comparison": "==" 29 | } 30 | }, 31 | { 32 | "groupIdx": 2, 33 | "condition": { 34 | "type": "intComparison", 35 | "input": 5, 36 | "comparison": "==" 37 | } 38 | } 39 | ], 40 | "logic": { 41 | "type": "and" 42 | } 43 | } 44 | ] 45 | } 46 | ] 47 | } 48 | -------------------------------------------------------------------------------- /pkg/config/configsections/container_test.go: -------------------------------------------------------------------------------- 1 | // Copyright (C) 2020-2022 Red Hat, Inc. 2 | // 3 | // This program is free software; you can redistribute it and/or modify 4 | // it under the terms of the GNU General Public License as published by 5 | // the Free Software Foundation; either version 2 of the License, or 6 | // (at your option) any later version. 7 | // 8 | // This program is distributed in the hope that it will be useful, 9 | // but WITHOUT ANY WARRANTY; without even the implied warranty of 10 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 11 | // GNU General Public License for more details. 12 | // 13 | // You should have received a copy of the GNU General Public License along 14 | // with this program; if not, write to the Free Software Foundation, Inc., 15 | // 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. 16 | 17 | package configsections 18 | 19 | import ( 20 | "testing" 21 | 22 | "github.com/stretchr/testify/assert" 23 | ) 24 | 25 | func TestString(t *testing.T) { 26 | cID := ContainerIdentifier{ 27 | NodeName: "node1", 28 | Namespace: "namespace1", 29 | PodName: "pod1", 30 | ContainerName: "container1", 31 | ContainerUID: "uid1", 32 | ContainerRuntime: "runtime1", 33 | } 34 | assert.Equal(t, "node:node1 ns:namespace1 podName:pod1 containerName:container1 containerUID:uid1 containerRuntime:runtime1", cID.String()) 35 | } 36 | -------------------------------------------------------------------------------- /cmd/tnf/grade/grade.go: -------------------------------------------------------------------------------- 1 | package grade 2 | 3 | import ( 4 | "fmt" 5 | "os" 6 | 7 | "github.com/spf13/cobra" 8 | "github.com/test-network-function/test-network-function/pkg/gradetool" 9 | ) 10 | 11 | var ( 12 | results string 13 | policy string 14 | OutputPath string 15 | 16 | grade = &cobra.Command{ 17 | Use: "gradetool", 18 | Short: "gradetool", 19 | RunE: runGradetool, 20 | } 21 | ) 22 | 23 | func runGradetool(cmd *cobra.Command, args []string) error { 24 | resultsPath := results 25 | policyPath := policy 26 | outputPath := OutputPath 27 | 28 | err := gradetool.GenerateGrade(resultsPath, policyPath, outputPath) 29 | if err != nil { 30 | fmt.Println(err) 31 | os.Exit(1) 32 | } 33 | return nil 34 | } 35 | 36 | func NewCommand() *cobra.Command { 37 | grade.Flags().StringVarP( 38 | &results, "results", "r", "", 39 | "Path to the input test results file", 40 | ) 41 | 42 | grade.Flags().StringVarP( 43 | &policy, "policy", "p", "", 44 | "Path to the input policy file", 45 | ) 46 | grade.Flags().StringVarP( 47 | &OutputPath, "OutputPath", "o", "", 48 | "Path to the output file", 49 | ) 50 | err := grade.MarkFlagRequired("results") 51 | if err != nil { 52 | return nil 53 | } 54 | err = grade.MarkFlagRequired("policy") 55 | if err != nil { 56 | return nil 57 | } 58 | err = grade.MarkFlagRequired("OutputPath") 59 | if err != nil { 60 | return nil 61 | } 62 | return grade 63 | } 64 | -------------------------------------------------------------------------------- /pkg/config/configsections/misc.go: -------------------------------------------------------------------------------- 1 | // Copyright (C) 2020-2022 Red Hat, Inc. 2 | // 3 | // This program is free software; you can redistribute it and/or modify 4 | // it under the terms of the GNU General Public License as published by 5 | // the Free Software Foundation; either version 2 of the License, or 6 | // (at your option) any later version. 7 | // 8 | // This program is distributed in the hope that it will be useful, 9 | // but WITHOUT ANY WARRANTY; without even the implied warranty of 10 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 11 | // GNU General Public License for more details. 12 | // 13 | // You should have received a copy of the GNU General Public License along 14 | // with this program; if not, write to the Free Software Foundation, Inc., 15 | // 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. 16 | 17 | package configsections 18 | 19 | // Types defined in this file are not currently in use. Move them out when starting to use. 20 | // May remove this altogether in the future 21 | 22 | // CNFType defines a type to be either Operator or Container 23 | type CNFType string 24 | 25 | // Permission defines roles and cluster roles resources 26 | type Permission struct { 27 | // Name is the name of Roles and Cluster Roles that is specified in the CSV 28 | Name string `yaml:"name" json:"name"` 29 | 30 | // Role is the role type either CLUSTER_ROLE or ROLE 31 | Role string `yaml:"role" json:"role"` 32 | } 33 | -------------------------------------------------------------------------------- /pkg/tnf/handlers/generic/match.go: -------------------------------------------------------------------------------- 1 | // Copyright (C) 2020-2022 Red Hat, Inc. 2 | // 3 | // This program is free software; you can redistribute it and/or modify 4 | // it under the terms of the GNU General Public License as published by 5 | // the Free Software Foundation; either version 2 of the License, or 6 | // (at your option) any later version. 7 | // 8 | // This program is distributed in the hope that it will be useful, 9 | // but WITHOUT ANY WARRANTY; without even the implied warranty of 10 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 11 | // GNU General Public License for more details. 12 | // 13 | // You should have received a copy of the GNU General Public License along 14 | // with this program; if not, write to the Free Software Foundation, Inc., 15 | // 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. 16 | 17 | package generic 18 | 19 | // Match follows the Container design pattern, and is used to store the arguments to a reel.Handler's ReelMatch 20 | // function in a single data transfer object. 21 | type Match struct { 22 | 23 | // Pattern is the pattern causing a match in reel.Handler ReelMatch. 24 | Pattern string `json:"pattern,omitempty" yaml:"pattern,omitempty"` 25 | 26 | // Before contains all output preceding Match. 27 | Before string `json:"before,omitempty" yaml:"before,omitempty"` 28 | 29 | // Match is the matched string. 30 | Match string `json:"match,omitempty" yaml:"match,omitempty"` 31 | } 32 | -------------------------------------------------------------------------------- /test-network-function/common/constant.go: -------------------------------------------------------------------------------- 1 | // Copyright (C) 2020-2022 Red Hat, Inc. 2 | // 3 | // This program is free software; you can redistribute it and/or modify 4 | // it under the terms of the GNU General Public License as published by 5 | // the Free Software Foundation; either version 2 of the License, or 6 | // (at your option) any later version. 7 | // 8 | // This program is distributed in the hope that it will be useful, 9 | // but WITHOUT ANY WARRANTY; without even the implied warranty of 10 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 11 | // GNU General Public License for more details. 12 | // 13 | // You should have received a copy of the GNU General Public License along 14 | // with this program; if not, write to the Free Software Foundation, Inc., 15 | // 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. 16 | 17 | package common 18 | 19 | // Constants shared by multiple test suite packages 20 | const ( 21 | ConfiguredTestFile = "testconfigure.yml" 22 | defaultTimeoutSeconds = 10 23 | AccessControlTestKey = "access-control" 24 | DiagnosticTestKey = "diagnostic" 25 | LifecycleTestKey = "lifecycle" 26 | AffiliatedCertTestKey = "affiliated-certification" 27 | NetworkingTestKey = "networking" 28 | ObservabilityTestKey = "observability" 29 | OperatorTestKey = "operator" 30 | PlatformAlterationTestKey = "platform-alteration" 31 | CommonTestKey = "common" 32 | ) 33 | -------------------------------------------------------------------------------- /pkg/config/autodiscover/testdata/testtarget.json: -------------------------------------------------------------------------------- 1 | 2 | { 3 | "metadata": { 4 | "annotations": { 5 | "k8s.v1.cni.cncf.io/networks-status": "[{\n \"name\": \"k8s-pod-network\",\n \"ips\": [\n \"10.244.205.205\"\n ],\n \"default\": true,\n \"dns\": {}\n},{\n \"name\": \"default/macvlan-conf1\",\n \"interface\": \"net1\",\n \"ips\": [\n \"3.3.3.3\"\n ],\n \"mac\": \"62:a2:5a:1f:80:15\",\n \"dns\": {}\n},{\n \"name\": \"default/macvlan-conf2\",\n \"interface\": \"net2\",\n \"ips\": [\n \"4.4.4.4\"\n ],\n \"mac\": \"62:a2:5a:1f:80:16\",\n \"dns\": {}\n}]", 6 | "test-network-function.com/host_resource_tests": "[\"OneTestName\",\"AnotherTestName\"]", 7 | "test-network-function.com/defaultnetworkinterface": "\"eth0\"" 8 | }, 9 | "labels": { 10 | "app": "test", 11 | "test-network-function.com/generic": "target", 12 | "test-network-function.com/container": "target" 13 | }, 14 | "name": "I'mAPodName", 15 | "namespace": "tnf" 16 | }, 17 | "spec": { 18 | "containers": [ 19 | { 20 | "image": "quay.io/testnetworkfunction/cnf-test-partner:latest", 21 | "name": "I'mAContainer" 22 | } 23 | ] 24 | }, 25 | "status": { 26 | "podIPs": [ 27 | { 28 | "ip": "10.217.1.89" 29 | } 30 | ] 31 | } 32 | } -------------------------------------------------------------------------------- /pkg/tnf/handlers/ping/testdata/ip_address_error_packet_loss.txt: -------------------------------------------------------------------------------- 1 | PING 192.168.1.1 (192.168.1.1) 56(84) bytes of data. 2 | 64 bytes from 192.168.1.1: icmp_seq=1 ttl=61 time=1.79 ms 3 | 64 bytes from 192.168.1.1: icmp_seq=2 ttl=61 time=3.37 ms 4 | 64 bytes from 192.168.1.1: icmp_seq=3 ttl=61 time=2.14 ms 5 | 64 bytes from 192.168.1.1: icmp_seq=4 ttl=61 time=3.62 ms 6 | From 10.0.2.2 icmp_seq=5 Destination Net Unreachable 7 | From 10.0.2.2 icmp_seq=6 Destination Net Unreachable 8 | From 10.0.2.2 icmp_seq=7 Destination Net Unreachable 9 | From 10.0.2.2 icmp_seq=8 Destination Net Unreachable 10 | 64 bytes from 192.168.1.1: icmp_seq=9 ttl=61 time=297 ms 11 | 64 bytes from 192.168.1.1: icmp_seq=10 ttl=61 time=258 ms 12 | 64 bytes from 192.168.1.1: icmp_seq=11 ttl=61 time=276 ms 13 | 64 bytes from 192.168.1.1: icmp_seq=12 ttl=61 time=1.58 ms 14 | 64 bytes from 192.168.1.1: icmp_seq=13 ttl=61 time=445 ms 15 | 64 bytes from 192.168.1.1: icmp_seq=14 ttl=61 time=3.57 ms 16 | 64 bytes from 192.168.1.1: icmp_seq=15 ttl=61 time=60.5 ms 17 | 64 bytes from 192.168.1.1: icmp_seq=16 ttl=61 time=585 ms 18 | 64 bytes from 192.168.1.1: icmp_seq=17 ttl=61 time=155 ms 19 | 64 bytes from 192.168.1.1: icmp_seq=18 ttl=61 time=20.4 ms 20 | 64 bytes from 192.168.1.1: icmp_seq=19 ttl=61 time=26.7 ms 21 | 64 bytes from 192.168.1.1: icmp_seq=20 ttl=61 time=2.14 ms 22 | 23 | --- 192.168.1.1 ping statistics --- 24 | 20 packets transmitted, 16 received, +4 errors, 20% packet loss, time 19118ms 25 | rtt min/avg/max/mdev = 1.582/134.079/585.861/179.394 ms 26 | -------------------------------------------------------------------------------- /test-network-function/version/version.go: -------------------------------------------------------------------------------- 1 | // Copyright (C) 2020-2022 Red Hat, Inc. 2 | // 3 | // This program is free software; you can redistribute it and/or modify 4 | // it under the terms of the GNU General Public License as published by 5 | // the Free Software Foundation; either version 2 of the License, or 6 | // (at your option) any later version. 7 | // 8 | // This program is distributed in the hope that it will be useful, 9 | // but WITHOUT ANY WARRANTY; without even the implied warranty of 10 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 11 | // GNU General Public License for more details. 12 | // 13 | // You should have received a copy of the GNU General Public License along 14 | // with this program; if not, write to the Free Software Foundation, Inc., 15 | // 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. 16 | 17 | package version 18 | 19 | import ( 20 | "encoding/json" 21 | "os" 22 | "path" 23 | ) 24 | 25 | var ( 26 | defaultVersionFile = path.Join("..", "version.json") 27 | ) 28 | 29 | // Version refers to the `test-network-function` version tag. 30 | type Version struct { 31 | // Tag is the Git tag for the version. 32 | Tag string `json:"tag" yaml:"tag"` 33 | } 34 | 35 | // GetVersion extracts the test-network-function version. 36 | func GetVersion() (*Version, error) { 37 | contents, err := os.ReadFile(defaultVersionFile) 38 | if err != nil { 39 | return nil, err 40 | } 41 | version := &Version{} 42 | err = json.Unmarshal(contents, version) 43 | return version, err 44 | } 45 | -------------------------------------------------------------------------------- /pkg/tnf/handlers/generic/condition/condition.go: -------------------------------------------------------------------------------- 1 | // Copyright (C) 2020-2022 Red Hat, Inc. 2 | // 3 | // This program is free software; you can redistribute it and/or modify 4 | // it under the terms of the GNU General Public License as published by 5 | // the Free Software Foundation; either version 2 of the License, or 6 | // (at your option) any later version. 7 | // 8 | // This program is distributed in the hope that it will be useful, 9 | // but WITHOUT ANY WARRANTY; without even the implied warranty of 10 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 11 | // GNU General Public License for more details. 12 | // 13 | // You should have received a copy of the GNU General Public License along 14 | // with this program; if not, write to the Free Software Foundation, Inc., 15 | // 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. 16 | 17 | package condition 18 | 19 | import "regexp" 20 | 21 | const ( 22 | // TypeKey is the JSON key indicating a condition payload. 23 | TypeKey = "type" 24 | ) 25 | 26 | // Condition represents the polymorphic behavior of the ability to Evaluate. Given a regular expression, match, and 27 | // match index, it is useful to make assertions using Condition implementations. For example, if a Ping test returns a 28 | // matching summary, it is convenient to evaluate that summary indicates zero errors. 29 | type Condition interface { 30 | 31 | // Evaluate evaluates a Condition implementation for groupIdx group of a matched expression. 32 | Evaluate(match string, regex *regexp.Regexp, groupIdx int) (bool, error) 33 | } 34 | -------------------------------------------------------------------------------- /pkg/config/configsections/request.go: -------------------------------------------------------------------------------- 1 | // Copyright (C) 2020-2022 Red Hat, Inc. 2 | // 3 | // This program is free software; you can redistribute it and/or modify 4 | // it under the terms of the GNU General Public License as published by 5 | // the Free Software Foundation; either version 2 of the License, or 6 | // (at your option) any later version. 7 | // 8 | // This program is distributed in the hope that it will be useful, 9 | // but WITHOUT ANY WARRANTY; without even the implied warranty of 10 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 11 | // GNU General Public License for more details. 12 | // 13 | // You should have received a copy of the GNU General Public License along 14 | // with this program; if not, write to the Free Software Foundation, Inc., 15 | // 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. 16 | 17 | package configsections 18 | 19 | // CertifiedOperatorRequestInfo contains all certified operator request info 20 | type CertifiedOperatorRequestInfo struct { 21 | 22 | // Name is the name of the `operator bundle package name` that you want to check if exists in the RedHat catalog 23 | Name string `yaml:"name" json:"name"` 24 | 25 | // Organization as understood by the operator publisher , e.g. `redhat-marketplace` 26 | Organization string `yaml:"organization" json:"organization"` 27 | } 28 | 29 | // AcceptedKernelTaintsInfo contains all certified operator request info 30 | type AcceptedKernelTaintsInfo struct { 31 | 32 | // Accepted modules that cause taints that we want to supply to the test suite 33 | Module string `yaml:"module" json:"module"` 34 | } 35 | -------------------------------------------------------------------------------- /pkg/tnf/interactive/ssh.go: -------------------------------------------------------------------------------- 1 | // Copyright (C) 2020-2022 Red Hat, Inc. 2 | // 3 | // This program is free software; you can redistribute it and/or modify 4 | // it under the terms of the GNU General Public License as published by 5 | // the Free Software Foundation; either version 2 of the License, or 6 | // (at your option) any later version. 7 | // 8 | // This program is distributed in the hope that it will be useful, 9 | // but WITHOUT ANY WARRANTY; without even the implied warranty of 10 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 11 | // GNU General Public License for more details. 12 | // 13 | // You should have received a copy of the GNU General Public License along 14 | // with this program; if not, write to the Free Software Foundation, Inc., 15 | // 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. 16 | 17 | package interactive 18 | 19 | import ( 20 | "fmt" 21 | "time" 22 | ) 23 | 24 | const ( 25 | sshCommand = "ssh" 26 | sshSeparator = "@" 27 | ) 28 | 29 | // SpawnSSH spawns an SSH session to a generic linux host using ssh provided by openssh-clients. Takes care of 30 | // establishing the pseudo-terminal (PTY) through expect.SpawnGeneric(). 31 | // TODO: This method currently relies upon passwordless SSH setup beforehand. Handle all types of auth. 32 | func SpawnSSH(spawner *Spawner, user, host string, timeout time.Duration, opts ...Option) (*Context, error) { 33 | sshArgs := getSSHString(user, host) 34 | return (*spawner).Spawn(sshCommand, []string{sshArgs}, timeout, opts...) 35 | } 36 | 37 | func getSSHString(user, host string) string { 38 | return fmt.Sprintf("%s%s%s", user, sshSeparator, host) 39 | } 40 | -------------------------------------------------------------------------------- /test-network-function/generic/suite.go: -------------------------------------------------------------------------------- 1 | // Copyright (C) 2020-2022 Red Hat, Inc. 2 | // 3 | // This program is free software; you can redistribute it and/or modify 4 | // it under the terms of the GNU General Public License as published by 5 | // the Free Software Foundation; either version 2 of the License, or 6 | // (at your option) any later version. 7 | // 8 | // This program is distributed in the hope that it will be useful, 9 | // but WITHOUT ANY WARRANTY; without even the implied warranty of 10 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 11 | // GNU General Public License for more details. 12 | // 13 | // You should have received a copy of the GNU General Public License along 14 | // with this program; if not, write to the Free Software Foundation, Inc., 15 | // 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. 16 | 17 | package generic 18 | 19 | import ( 20 | "github.com/onsi/ginkgo/v2" 21 | "github.com/test-network-function/test-network-function/pkg/config" 22 | "github.com/test-network-function/test-network-function/pkg/tnf/testcases" 23 | "github.com/test-network-function/test-network-function/test-network-function/results" 24 | ) 25 | 26 | const ( 27 | testsKey = "generic" 28 | ) 29 | 30 | // Runs the "generic" CNF test cases. 31 | var _ = ginkgo.Describe(testsKey, func() { 32 | conf, _ := ginkgo.GinkgoConfiguration() 33 | if testcases.IsInFocus(conf.FocusStrings, testsKey) { 34 | env := config.GetTestEnvironment() 35 | ginkgo.BeforeEach(func() { 36 | env.LoadAndRefresh() 37 | }) 38 | ginkgo.ReportAfterEach(results.RecordResult) 39 | ginkgo.AfterEach(env.CloseLocalShellContext) 40 | } 41 | }) 42 | -------------------------------------------------------------------------------- /pkg/config/configsections/node.go: -------------------------------------------------------------------------------- 1 | // Copyright (C) 2020-2022 Red Hat, Inc. 2 | // 3 | // This program is free software; you can redistribute it and/or modify 4 | // it under the terms of the GNU General Public License as published by 5 | // the Free Software Foundation; either version 2 of the License, or 6 | // (at your option) any later version. 7 | // 8 | // This program is distributed in the hope that it will be useful, 9 | // but WITHOUT ANY WARRANTY; without even the implied warranty of 10 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 11 | // GNU General Public License for more details. 12 | // 13 | // You should have received a copy of the GNU General Public License along 14 | // with this program; if not, write to the Free Software Foundation, Inc., 15 | // 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. 16 | 17 | package configsections 18 | 19 | // WorkerLabel const for k8s worker 20 | const WorkerLabel = "node-role.kubernetes.io/worker" 21 | 22 | // MasterLabel const for k8s for master 23 | const MasterLabel = "node-role.kubernetes.io/master" 24 | 25 | // Node defines in the cluster. with name of the node and the type of this node master/worker,,,,. 26 | type Node struct { 27 | Name string 28 | Labels []string 29 | } 30 | 31 | // IsMaster Function that return if the node is master 32 | func (node Node) IsMaster() bool { 33 | for _, t := range node.Labels { 34 | if t == MasterLabel { 35 | return true 36 | } 37 | } 38 | return false 39 | } 40 | 41 | // IsWorker Function that return if the node is worker 42 | func (node Node) IsWorker() bool { 43 | for _, t := range node.Labels { 44 | if t == WorkerLabel { 45 | return true 46 | } 47 | } 48 | return false 49 | } 50 | -------------------------------------------------------------------------------- /pkg/tnf/handlers/generic/assertion/or_test.go: -------------------------------------------------------------------------------- 1 | // Copyright (C) 2020-2022 Red Hat, Inc. 2 | // 3 | // This program is free software; you can redistribute it and/or modify 4 | // it under the terms of the GNU General Public License as published by 5 | // the Free Software Foundation; either version 2 of the License, or 6 | // (at your option) any later version. 7 | // 8 | // This program is distributed in the hope that it will be useful, 9 | // but WITHOUT ANY WARRANTY; without even the implied warranty of 10 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 11 | // GNU General Public License for more details. 12 | // 13 | // You should have received a copy of the GNU General Public License along 14 | // with this program; if not, write to the Free Software Foundation, Inc., 15 | // 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. 16 | 17 | package assertion_test 18 | 19 | import ( 20 | "testing" 21 | 22 | "github.com/stretchr/testify/assert" 23 | "github.com/test-network-function/test-network-function/pkg/tnf/handlers/generic/assertion" 24 | ) 25 | 26 | func TestNewOrBooleanLogic(t *testing.T) { 27 | logic := assertion.NewOrBooleanLogic() 28 | assert.Equal(t, assertion.OrBooleanLogicKey, logic.Type) 29 | } 30 | 31 | func TestOrBooleanLogic_Evaluate(t *testing.T) { 32 | for _, testCase := range andBooleanLogicTestCases { 33 | logic := assertion.NewOrBooleanLogic() 34 | actualResult, actualError := logic.Evaluate(testCase.assertions, testCase.match, &testCase.regex) 35 | assert.Equal(t, assertion.OrBooleanLogicKey, logic.Type) 36 | assert.Equal(t, testCase.expectedOrBooleanLogicResult, actualResult) 37 | assert.Equal(t, testCase.expectedOrBooleanLogicError, actualError != nil) 38 | } 39 | } 40 | -------------------------------------------------------------------------------- /pkg/tnf/handlers/generic/testdata/base.json: -------------------------------------------------------------------------------- 1 | { 2 | "identifier": { 3 | "url": "http://test-network-function.com/tests/unit/base", 4 | "version": "v1.0.0" 5 | }, 6 | "description": "checks for RHEL version.", 7 | "reelFirstStep": { 8 | "execute": "if [ -e /etc/redhat-release ]; then cat /etc/redhat-release; else echo \"Unknown Base Image\"; fi\n", 9 | "expect": [ 10 | "(?m)Unknown Base Image", 11 | "(?m)Red Hat Enterprise Linux Server release (\\d+\\.\\d+) \\((\\w+)\\)", 12 | "(?m)contrived match" 13 | ], 14 | "timeout": 2000000000 15 | }, 16 | "resultContexts": [ 17 | { 18 | "pattern": "(?m)Unknown Base Image", 19 | "defaultResult": 2 20 | }, 21 | { 22 | "pattern": "(?m)Red Hat Enterprise Linux Server release (\\d+\\.\\d+) \\((\\w+)\\)", 23 | "defaultResult": 1, 24 | "composedAssertions": [ 25 | { 26 | "assertions": [ 27 | { 28 | "groupIdx": 1, 29 | "condition": { 30 | "type": "equals", 31 | "expected": "7.8" 32 | } 33 | }, 34 | { 35 | "groupIdx": 2, 36 | "condition": { 37 | "type": "equals", 38 | "expected": "Maipo" 39 | } 40 | } 41 | ], 42 | "logic": { 43 | "type": "and" 44 | } 45 | } 46 | ] 47 | }, 48 | { 49 | "pattern": "(?m)contrived match", 50 | "defaultResult": 0, 51 | "nextStep": { 52 | "execute": "ls -al\n", 53 | "expect": ["(?m).+"], 54 | "timeout": 2000000000 55 | } 56 | } 57 | ], 58 | "testResult": 0, 59 | "testTimeout": 2000000000 60 | } 61 | -------------------------------------------------------------------------------- /pkg/tnf/testcases/data/operator/operator.go: -------------------------------------------------------------------------------- 1 | // Copyright (C) 2020-2022 Red Hat, Inc. 2 | // 3 | // This program is free software; you can redistribute it and/or modify 4 | // it under the terms of the GNU General Public License as published by 5 | // the Free Software Foundation; either version 2 of the License, or 6 | // (at your option) any later version. 7 | // 8 | // This program is distributed in the hope that it will be useful, 9 | // but WITHOUT ANY WARRANTY; without even the implied warranty of 10 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 11 | // GNU General Public License for more details. 12 | // 13 | // You should have received a copy of the GNU General Public License along 14 | // with this program; if not, write to the Free Software Foundation, Inc., 15 | // 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. 16 | 17 | package operator 18 | 19 | // OperatorJSON test templates for collecting operator status 20 | var OperatorJSON = string(`{ 21 | "testcase": [ 22 | { 23 | "name": "CSV_INSTALLED", 24 | "skiptest": true, 25 | "command": "oc get csv %s -n %s -o json | jq -r '.status.phase'", 26 | "action": "allow", 27 | "resulttype": "string", 28 | "expectedstatus": [ 29 | "Succeeded" 30 | ] 31 | }, 32 | { 33 | "name": "CSV_SCC", 34 | "skiptest": true, 35 | "command": "oc get csv %s -n %s -o json | jq -r 'if .spec.install.spec.clusterPermissions == null then null else . end ` + 36 | `| if . == null then \"EMPTY\" else .spec.install.spec.clusterPermissions[].rules[].resourceNames end | if length == 0 then \"EMPTY\" else . end'", 37 | "action": "allow", 38 | "resulttype": "string", 39 | "expectedstatus": [ 40 | "EMPTY" 41 | ] 42 | } 43 | ] 44 | }`) 45 | -------------------------------------------------------------------------------- /pkg/tnf/handlers/generic/assertion/logic.go: -------------------------------------------------------------------------------- 1 | // Copyright (C) 2020-2022 Red Hat, Inc. 2 | // 3 | // This program is free software; you can redistribute it and/or modify 4 | // it under the terms of the GNU General Public License as published by 5 | // the Free Software Foundation; either version 2 of the License, or 6 | // (at your option) any later version. 7 | // 8 | // This program is distributed in the hope that it will be useful, 9 | // but WITHOUT ANY WARRANTY; without even the implied warranty of 10 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 11 | // GNU General Public License for more details. 12 | // 13 | // You should have received a copy of the GNU General Public License along 14 | // with this program; if not, write to the Free Software Foundation, Inc., 15 | // 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. 16 | 17 | package assertion 18 | 19 | import ( 20 | "regexp" 21 | ) 22 | 23 | const ( 24 | // LogicKey is the JSON key used to represent a BooleanLogic payload. 25 | LogicKey = "logic" 26 | // TypeKey is the JSON key used to represent a BooleanLogic type. 27 | TypeKey = "type" 28 | ) 29 | 30 | // BooleanLogic represents boolean logic. Given a set of conditions, it is useful to make assertions over the set using 31 | // some sort of boolean logic ("and" and "or", for example). 32 | type BooleanLogic interface { 33 | 34 | // Evaluate evaluates assertions against a match using an implementation-dependent BooleanLogic. Evaluate returns 35 | // whether or not the expression evaluated to true, and an optional error if the expression could not be evaluated 36 | // properly. An example of an error case might be making an assertion for a match index that does not exist. 37 | Evaluate(assertions []Assertion, match string, regex *regexp.Regexp) (bool, error) 38 | } 39 | -------------------------------------------------------------------------------- /pkg/junit/convert_test.go: -------------------------------------------------------------------------------- 1 | // Copyright (C) 2021 Red Hat, Inc. 2 | // 3 | // This program is free software; you can redistribute it and/or modify 4 | // it under the terms of the GNU General Public License as published by 5 | // the Free Software Foundation; either version 2 of the License, or 6 | // (at your option) any later version. 7 | // 8 | // This program is distributed in the hope that it will be useful, 9 | // but WITHOUT ANY WARRANTY; without even the implied warranty of 10 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 11 | // GNU General Public License for more details. 12 | // 13 | // You should have received a copy of the GNU General Public License along 14 | // with this program; if not, write to the Free Software Foundation, Inc., 15 | // 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. 16 | 17 | package junit_test 18 | 19 | import ( 20 | "path" 21 | "testing" 22 | 23 | "github.com/stretchr/testify/assert" 24 | "github.com/test-network-function/test-network-function/pkg/junit" 25 | ) 26 | 27 | const ( 28 | testJunitXMLFilename = "success.junit.xml" 29 | testKey = "cnf-certification-tests_junit" 30 | ) 31 | 32 | func TestExtractTestSuiteResults(t *testing.T) { 33 | junitResults, err := junit.ExportJUnitAsMap(path.Join("testdata", testJunitXMLFilename)) 34 | claim := make(map[string]interface{}) 35 | claim[testKey] = junitResults 36 | assert.Nil(t, err) 37 | assert.NotNil(t, junitResults) 38 | results, err := junit.ExtractTestSuiteResults(claim, testKey) 39 | assert.Nil(t, err) 40 | // positive test 41 | assert.Equal(t, true, results["[It] operator Runs test on operators operator-install-status-CSV_INSTALLED"].Passed) 42 | // negative test 43 | assert.Equal(t, false, results["[It] platform-alteration platform-alteration-boot-params"].Passed) 44 | } 45 | -------------------------------------------------------------------------------- /pkg/config/autodiscover/pod_test.go: -------------------------------------------------------------------------------- 1 | // Copyright (C) 2021 Red Hat, Inc. 2 | // 3 | // This program is free software; you can redistribute it and/or modify 4 | // it under the terms of the GNU General Public License as published by 5 | // the Free Software Foundation; either version 2 of the License, or 6 | // (at your option) any later version. 7 | // 8 | // This program is distributed in the hope that it will be useful, 9 | // but WITHOUT ANY WARRANTY; without even the implied warranty of 10 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 11 | // GNU General Public License for more details. 12 | // 13 | // You should have received a copy of the GNU General Public License along 14 | // with this program; if not, write to the Free Software Foundation, Inc., 15 | // 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. 16 | 17 | package autodiscover 18 | 19 | import ( 20 | "testing" 21 | 22 | "github.com/stretchr/testify/assert" 23 | ) 24 | 25 | func TestBuildPodUnderTest(t *testing.T) { 26 | orchestratorPodResource := loadPodResource(testOrchestratorFilePath) 27 | orchestratorPod := buildPodUnderTest(&orchestratorPodResource) 28 | 29 | subjectPodResource := loadPodResource(testSubjectFilePath) 30 | subjectPod := buildPodUnderTest(&subjectPodResource) 31 | 32 | assert.Equal(t, "tnf", orchestratorPod.Namespace) 33 | assert.Equal(t, "I'mAPodName", orchestratorPod.Name) 34 | assert.NotEqual(t, "I'mAContainer", orchestratorPod.Name) 35 | // no tests set on pod and the config file will not be loaded from the unit test context: no tests should be set. 36 | assert.Equal(t, []string{}, orchestratorPod.Tests) 37 | 38 | assert.Equal(t, "tnf", subjectPod.Namespace) 39 | assert.Equal(t, "I'mAPodName", subjectPod.Name) 40 | assert.Equal(t, []string{"OneTestName", "AnotherTestName"}, subjectPod.Tests) 41 | } 42 | -------------------------------------------------------------------------------- /schemas/gradetool-policy-schema.json: -------------------------------------------------------------------------------- 1 | { 2 | "$id": "http://test-network-function.com/policy3", 3 | "title": "Claim Policy Schema", 4 | "additionalProperties": false, 5 | "definitions": { 6 | "identifier": { 7 | "$id": "#identifier", 8 | "type": "object", 9 | "description": "identifier is a per testcase unique identifier.", 10 | "properties": { 11 | "url": { 12 | "type": "string", 13 | "description": "url stores the unique url for a test." 14 | }, 15 | "version": { 16 | "type": "string", 17 | "description": "version stores the semantic version of the test." 18 | } 19 | }, 20 | "additionalProperties": false, 21 | "required": [ 22 | "url", 23 | "version" 24 | ] 25 | }, 26 | "grade": { 27 | "$id": "#grade", 28 | "type": "object", 29 | "description": "the certification grade", 30 | "properties": { 31 | "gradeName": { 32 | "type": "string", 33 | "description": "the name of the grade (i.e., good, better, or best)" 34 | }, 35 | "requiredPassingTests": { 36 | "type": "array", 37 | "description": "the test identifiers that must pass to achieve the given grade.", 38 | "items": { 39 | "$ref": "#identifier" 40 | } 41 | }, 42 | "nextGrade": { 43 | "$ref": "#grade", 44 | "description": "CNF Certification grading is progressive. nextGrade allows one to define the next better level" 45 | } 46 | }, 47 | "required": [ 48 | "gradeName", 49 | "requiredPassingTests" 50 | ] 51 | } 52 | }, 53 | "properties": { 54 | "grades": { 55 | "type": "object", 56 | "$ref": "#grade" 57 | } 58 | } 59 | } -------------------------------------------------------------------------------- /test-network-function/common/suite.go: -------------------------------------------------------------------------------- 1 | // Copyright (C) 2020-2022 Red Hat, Inc. 2 | // 3 | // This program is free software; you can redistribute it and/or modify 4 | // it under the terms of the GNU General Public License as published by 5 | // the Free Software Foundation; either version 2 of the License, or 6 | // (at your option) any later version. 7 | // 8 | // This program is distributed in the hope that it will be useful, 9 | // but WITHOUT ANY WARRANTY; without even the implied warranty of 10 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 11 | // GNU General Public License for more details. 12 | // 13 | // You should have received a copy of the GNU General Public License along 14 | // with this program; if not, write to the Free Software Foundation, Inc., 15 | // 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. 16 | 17 | package common 18 | 19 | import ( 20 | "github.com/onsi/ginkgo/v2" 21 | log "github.com/sirupsen/logrus" 22 | configpkg "github.com/test-network-function/test-network-function/pkg/config" 23 | "github.com/test-network-function/test-network-function/pkg/config/autodiscover" 24 | ) 25 | 26 | var env *configpkg.TestEnvironment 27 | 28 | func RemoveLabelsFromAllNodes() { 29 | for name := range autodiscover.GetNodesList() { 30 | autodiscover.DeleteDebugLabel(name) 31 | } 32 | } 33 | 34 | func RemoveDebugPods() { 35 | env = configpkg.GetTestEnvironment() 36 | env.LoadAndRefresh() 37 | for name, node := range env.NodesUnderTest { 38 | if !(node.HasDebugPod()) { 39 | continue 40 | } 41 | node.DebugContainer.CloseOc() 42 | autodiscover.DeleteDebugLabel(name) 43 | } 44 | } 45 | 46 | var _ = ginkgo.BeforeSuite(func() { 47 | }) 48 | 49 | var _ = ginkgo.AfterSuite(func() { 50 | // clean up added label to nodes 51 | log.Info("Clean up added labels to nodes") 52 | RemoveDebugPods() 53 | }) 54 | -------------------------------------------------------------------------------- /go.mod: -------------------------------------------------------------------------------- 1 | module github.com/test-network-function/test-network-function 2 | 3 | go 1.17 4 | 5 | replace github.com/google/goexpect => github.com/test-network-function/goexpect v0.0.1 6 | 7 | require ( 8 | github.com/Masterminds/semver/v3 v3.1.1 9 | github.com/basgys/goxml2json v1.1.0 10 | github.com/bitly/go-simplejson v0.5.0 // indirect 11 | github.com/golang/mock v1.6.0 12 | github.com/google/goexpect v0.0.0-20210330220015-096e5d1cbd97 13 | github.com/google/goterm v0.0.0-20190703233501-fc88cf888a3f 14 | github.com/onsi/ginkgo/v2 v2.1.3 15 | github.com/onsi/gomega v1.19.0 16 | github.com/sirupsen/logrus v1.8.1 17 | github.com/spf13/cobra v1.4.0 18 | github.com/stretchr/testify v1.7.5 19 | github.com/test-network-function/test-network-function-claim v1.0.5 20 | github.com/xeipuuv/gojsonschema v1.2.0 21 | golang.org/x/sys v0.0.0-20211216021012-1d35b9e2eb4e // indirect 22 | google.golang.org/grpc v1.47.0 23 | gopkg.in/yaml.v2 v2.4.0 24 | ) 25 | 26 | require ( 27 | github.com/go-yaml/yaml v2.1.0+incompatible 28 | github.com/hashicorp/go-version v1.5.0 29 | ) 30 | 31 | require ( 32 | github.com/davecgh/go-spew v1.1.1 // indirect 33 | github.com/golang/protobuf v1.5.2 // indirect 34 | github.com/inconshreveable/mousetrap v1.0.0 // indirect 35 | github.com/pmezard/go-difflib v1.0.0 // indirect 36 | github.com/spf13/pflag v1.0.5 // indirect 37 | github.com/xeipuuv/gojsonpointer v0.0.0-20180127040702-4e3ac2762d5f // indirect 38 | github.com/xeipuuv/gojsonreference v0.0.0-20180127040603-bd5ef7bd5415 // indirect 39 | golang.org/x/crypto v0.0.0-20210817164053-32db794688a5 // indirect 40 | golang.org/x/net v0.0.0-20220225172249-27dd8689420f // indirect 41 | golang.org/x/text v0.3.7 // indirect 42 | google.golang.org/genproto v0.0.0-20211208223120-3a66f561d7aa // indirect 43 | google.golang.org/protobuf v1.27.1 // indirect 44 | gopkg.in/yaml.v3 v3.0.1 // indirect 45 | ) 46 | -------------------------------------------------------------------------------- /pkg/tnf/interactive/shell.go: -------------------------------------------------------------------------------- 1 | // Copyright (C) 2020-2022 Red Hat, Inc. 2 | // 3 | // This program is free software; you can redistribute it and/or modify 4 | // it under the terms of the GNU General Public License as published by 5 | // the Free Software Foundation; either version 2 of the License, or 6 | // (at your option) any later version. 7 | // 8 | // This program is distributed in the hope that it will be useful, 9 | // but WITHOUT ANY WARRANTY; without even the implied warranty of 10 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 11 | // GNU General Public License for more details. 12 | // 13 | // You should have received a copy of the GNU General Public License along 14 | // with this program; if not, write to the Free Software Foundation, Inc., 15 | // 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. 16 | 17 | package interactive 18 | 19 | import ( 20 | "log" 21 | "os" 22 | "time" 23 | ) 24 | 25 | const ( 26 | shellEnvironmentVariableKey = "SHELL" 27 | defaultTimeoutSeconds = 10 28 | defaultTimeout = defaultTimeoutSeconds * time.Second 29 | ) 30 | 31 | // SpawnShell creates an interactive shell subprocess based on the value of $SHELL, spawning the appropriate underlying 32 | // PTY. 33 | func SpawnShell(spawner *Spawner, timeout time.Duration, opts ...Option) (*Context, error) { 34 | shellEnv := os.Getenv(shellEnvironmentVariableKey) 35 | var args []string 36 | return (*spawner).Spawn(shellEnv, args, timeout, opts...) 37 | } 38 | 39 | // 40 | // 41 | // GetContext spawns a new shell session and returns its context 42 | func GetContext(verbose bool) *Context { 43 | context, err := SpawnShell(CreateGoExpectSpawner(), defaultTimeout, Verbose(verbose), SendTimeout(defaultTimeout)) 44 | if err != nil || context == nil || context.GetExpecter() == nil { 45 | log.Panicf("can't get a proper context for test execution") 46 | } 47 | return context 48 | } 49 | -------------------------------------------------------------------------------- /pkg/jsonschema/utils.go: -------------------------------------------------------------------------------- 1 | // Copyright (C) 2021 Red Hat, Inc. 2 | // 3 | // This program is free software; you can redistribute it and/or modify 4 | // it under the terms of the GNU General Public License as published by 5 | // the Free Software Foundation; either version 2 of the License, or 6 | // (at your option) any later version. 7 | // 8 | // This program is distributed in the hope that it will be useful, 9 | // but WITHOUT ANY WARRANTY; without even the implied warranty of 10 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 11 | // GNU General Public License for more details. 12 | // 13 | // You should have received a copy of the GNU General Public License along 14 | // with this program; if not, write to the Free Software Foundation, Inc., 15 | // 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. 16 | 17 | package jsonschema 18 | 19 | import ( 20 | "os" 21 | 22 | "github.com/xeipuuv/gojsonschema" 23 | ) 24 | 25 | // ValidateJSONFileAgainstSchema validates a given file against the supplied JSON schema. 26 | func ValidateJSONFileAgainstSchema(filename, schemaPath string) (*gojsonschema.Result, error) { 27 | inputBytes, err := os.ReadFile(filename) 28 | if err != nil { 29 | return nil, err 30 | } 31 | return ValidateJSONAgainstSchema(inputBytes, schemaPath) 32 | } 33 | 34 | // ValidateJSONAgainstSchema validates a given byte array against the supplied JSON schema. 35 | func ValidateJSONAgainstSchema(inputBytes []byte, schemaPath string) (*gojsonschema.Result, error) { 36 | schemaBytes, err := os.ReadFile(schemaPath) 37 | if err != nil { 38 | return nil, err 39 | } 40 | 41 | schemaLoader := gojsonschema.NewStringLoader(string(schemaBytes)) 42 | if err != nil { 43 | return nil, err 44 | } 45 | 46 | inputLoader := gojsonschema.NewStringLoader(string(inputBytes)) 47 | schema, err := gojsonschema.NewSchema(schemaLoader) 48 | if err != nil { 49 | return nil, err 50 | } 51 | return schema.Validate(inputLoader) 52 | } 53 | -------------------------------------------------------------------------------- /pkg/tnf/testcases/data/cnf/gatherfacts.go: -------------------------------------------------------------------------------- 1 | // Copyright (C) 2020-2022 Red Hat, Inc. 2 | // 3 | // This program is free software; you can redistribute it and/or modify 4 | // it under the terms of the GNU General Public License as published by 5 | // the Free Software Foundation; either version 2 of the License, or 6 | // (at your option) any later version. 7 | // 8 | // This program is distributed in the hope that it will be useful, 9 | // but WITHOUT ANY WARRANTY; without even the implied warranty of 10 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 11 | // GNU General Public License for more details. 12 | // 13 | // You should have received a copy of the GNU General Public License along 14 | // with this program; if not, write to the Free Software Foundation, Inc., 15 | // 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. 16 | 17 | package cnf 18 | 19 | // GatherPodFactsJSON test templates for collecting facts 20 | var GatherPodFactsJSON = string(`{ 21 | "testcase": [ 22 | { 23 | "name": "NAME", 24 | "skiptest": false, 25 | "command": "oc get pod %s -n %s -o json | jq -r '.metadata.name'", 26 | "action": "allow", 27 | "resulttype": "string", 28 | "expectedtype": "regex", 29 | "expectedstatus": [ 30 | "ALLOW_ALL" 31 | ] 32 | }, 33 | { 34 | "name": "CONTAINER_COUNT", 35 | "skiptest": false, 36 | "command": "oc get pod %s -n %s -o json | jq -r '.spec.containers | length'", 37 | "action": "allow", 38 | "resulttype": "integer", 39 | "expectedType": "regex", 40 | "expectedstatus": [ 41 | "DIGIT" 42 | ] 43 | }, 44 | { 45 | "name": "SERVICE_ACCOUNT_NAME", 46 | "skiptest": false, 47 | "command": "oc get pod %s -n %s -o json | jq -r '.spec.serviceAccountName'", 48 | "action": "allow", 49 | "resulttype": "string", 50 | "expectedType": "regex", 51 | "expectedstatus": [ 52 | "ALLOW_ALL" 53 | ] 54 | } 55 | ] 56 | }`) 57 | -------------------------------------------------------------------------------- /docs/images/overview.drawio: -------------------------------------------------------------------------------- 1 | 3VrZcqM4FP0aP8YldnhMnGUeekmVa6qnn7pkEIYZjGghx/Z8/UggDEh4DZCMSaqCroRA5567SZkYs9X2hcAs+ooDlEx0EGwnxuNE1zVT1yf8FwS7UuI4XilYkjgQg2rBPP4XCSEQ0nUcoLw1kGKc0DhrC32cpsinLRkkBG/aw0KctN+awSVSBHMfJqr0RxzQqJS6Fqjlf6B4GVVv1oDoWcFqsBDkEQzwpiEynibGjGBMy7vVdoYSDl6FS/nc84He/YcRlNJzHnhJol+zr/DHvfc0/5NqL9rvx7s73S6neYPJWqxYfC3dVRAQvE4DxGcBE+NhE8UUzTPo894NUzqTRXSVsJbGbsM4SWY4waR41gggckOfyXNK8D+o0WP7LlqErEddh1jaGyIUbRsisa4XhFeIkh0bUvU6AmNBsj3mm1plVqWyqKEuvXoQCpos93PXSLIbAeYFwA6Ma2jxn05ci4s/gVPakJdXT3i7Et6GirfmdeENhsJbV/DOcMAEWr+wh6Hud9I5sBe2ZfcDry7Da6vwOpaKrjkUuI4C7uzbMxNwIAn3yCinCs5ssbQNZhu0FKdIQliIYBIvU9b0GYRsfuOBQxczn3wvOlZxEPDXdGqvrd+x2A462T6QPtzTzgWlwT0PfzWqAcyjAhatrRUuf4WUIZ0WEh0Ye11VIY+h88AAJLu/OKxTq2r+FHMUjcetwLxs7U5pIMdr4qMjyzRFvIdkiehp20dBK5Sr+mxGgw51VTKCEkjjt3YC0KVD8YZXHLOV7eligjZdTJkG5brFU82ALU9ktScy5GBVAqNMVFBqv+zrWaZ5KqsYxHPRxIRGeIlTmDzVUsn66jFfMM4EWf5GlO5EpgfXFLfpiLYxLVmmW6L5s9FVk4w3dk3GjcrNKj89SU7zTHJexjpm23DXGJBxEuRHSClxqSLpudwz7ePjDc09Np7dlF/cK0ENNbg3CSr8Xm+M1Bp0FDw7SEglPwDAcgBQMwoAXAjaFG4SuMHnj6Ow7vXN4XdFv+q7G+HP5wlCyFIEGuO0rAYpjFOenDyjLfL7TQJdH3UngQvX4obTS9ZhapL376hpulJse7AMGygojhEOas+uX+Ta6zjinB9HxjCmQeKB4pBtOQvRrsxCDN2ZWsenOpCHXByjXOk98obGqfHu8fG65x0bP0yM2ht+7azImruoojx9bjgqsIA5CkQ1lSu2djPllCEzs6O6PbB5MJRnU+vbiW4nVGyitPRg/17jquMuL7zWPd9mcLNt3cnulvzv9wyleRSHtJqOfV45Y9l/u0q2vLaS9xttTSUboyrZU5TcUA9YwZwWVsgtkuAk4Y2b2bCz7Lbr29tgUx16hzoG21Iy1CRuhgn6PmeyVxb5QkxWzEzgisOaLvKsy1xuSCHWhyukYw9pgGLqcGF0bQF0sKC6omwbIf+riD90Amg6EsOuTQAteSLZRQ+8DcVMTvYU2d5B3HqyZGlSztrhuM0xw6j5efdcGqUisFul4hSY+gkvUrReEYkZTFzvh3Zx+PW+Te0PKxTfp3c1XhOUJcwycsSdxTvP2dTzNMdbdO2XhSGyi82XHoxLcx0pK7IU43JGNS7V0xWHmNt+M58POcQ0PvoQ01TjSIvB6S0wuAvkURmsUliNF5//aPKTHCXqFXqyei/N4di7p7YtpXHWqGmcaf8PEofLKo9B0gPjzPRgmHNFlTm2c5w2Z1PQM6cWqC+J2RojqOPV18jkdD4tOYck2ejkca/1X3IyYY1bg5rup+XHiM5rcLpYEl20a32NTJfeYh1r1v+xWw6v/+/ZePoP -------------------------------------------------------------------------------- /pkg/gradetool/gradetool_test.go: -------------------------------------------------------------------------------- 1 | // Copyright (C) 2020-2021 Red Hat, Inc. 2 | // 3 | // This program is free software; you can redistribute it and/or modify 4 | // it under the terms of the GNU General Public License as published by 5 | // the Free Software Foundation; either version 2 of the License, or 6 | // (at your option) any later version. 7 | // 8 | // This program is distributed in the hope that it will be useful, 9 | // but WITHOUT ANY WARRANTY; without even the implied warranty of 10 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 11 | // GNU General Public License for more details. 12 | // 13 | // You should have received a copy of the GNU General Public License along 14 | // with this program; if not, write to the Free Software Foundation, Inc., 15 | // 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. 16 | 17 | package gradetool 18 | 19 | import ( 20 | "os" 21 | "os/exec" 22 | "path" 23 | "testing" 24 | 25 | "github.com/stretchr/testify/assert" 26 | ) 27 | 28 | const ( 29 | testDataPath = "testdata/" 30 | goodClaim = testDataPath + "claim-good.json" 31 | badClaim = testDataPath + "claim-missing-field.json" 32 | goodPolicy = testDataPath + "policy-good.json" 33 | badPolicy = testDataPath + "policy-duplicate-grade.json" 34 | outPath = testDataPath + "out.json" 35 | ) 36 | 37 | var ( 38 | testOutPath = path.Join("..", "..", "test-out.json") 39 | ) 40 | 41 | func TestMain(m *testing.M) { 42 | policySchemaPath = path.Join("..", "..", policySchemaPath) 43 | os.Exit(m.Run()) 44 | } 45 | 46 | func TestGenerateGrade_Success(t *testing.T) { 47 | err := GenerateGrade(goodClaim, goodPolicy, testOutPath) 48 | assert.Nil(t, err) 49 | assertFilesMatch(t, outPath, testOutPath) 50 | } 51 | 52 | func TestGenerateGrade_ErrorInput(t *testing.T) { 53 | err := GenerateGrade(goodClaim, badPolicy, testOutPath) 54 | assert.NotNil(t, err) 55 | err = GenerateGrade(badClaim, goodPolicy, testOutPath) 56 | assert.NotNil(t, err) 57 | } 58 | 59 | func assertFilesMatch(t *testing.T, pathA, pathB string) { 60 | command := exec.Command("cmp", "-s", pathA, pathB) 61 | err := command.Run() 62 | assert.Nil(t, err) 63 | } 64 | -------------------------------------------------------------------------------- /pkg/config/configsections/node_test.go: -------------------------------------------------------------------------------- 1 | // Copyright (C) 2020-2022 Red Hat, Inc. 2 | // 3 | // This program is free software; you can redistribute it and/or modify 4 | // it under the terms of the GNU General Public License as published by 5 | // the Free Software Foundation; either version 2 of the License, or 6 | // (at your option) any later version. 7 | // 8 | // This program is distributed in the hope that it will be useful, 9 | // but WITHOUT ANY WARRANTY; without even the implied warranty of 10 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 11 | // GNU General Public License for more details. 12 | // 13 | // You should have received a copy of the GNU General Public License along 14 | // with this program; if not, write to the Free Software Foundation, Inc., 15 | // 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. 16 | 17 | package configsections 18 | 19 | import ( 20 | "testing" 21 | 22 | "github.com/stretchr/testify/assert" 23 | ) 24 | 25 | func TestIsMaster(t *testing.T) { 26 | testCases := []struct { 27 | nodeLabel string 28 | expectedOutput bool 29 | }{ 30 | { 31 | expectedOutput: true, 32 | nodeLabel: MasterLabel, 33 | }, 34 | { 35 | expectedOutput: false, 36 | nodeLabel: WorkerLabel, 37 | }, 38 | { 39 | expectedOutput: false, 40 | nodeLabel: "", 41 | }, 42 | } 43 | 44 | for _, tc := range testCases { 45 | testNode := Node{ 46 | Name: "mastertest", 47 | Labels: []string{tc.nodeLabel}, 48 | } 49 | assert.Equal(t, tc.expectedOutput, testNode.IsMaster()) 50 | } 51 | } 52 | 53 | func TestIsWorker(t *testing.T) { 54 | testCases := []struct { 55 | nodeLabel string 56 | expectedOutput bool 57 | }{ 58 | { 59 | expectedOutput: true, 60 | nodeLabel: WorkerLabel, 61 | }, 62 | { 63 | expectedOutput: false, 64 | nodeLabel: MasterLabel, 65 | }, 66 | { 67 | expectedOutput: false, 68 | nodeLabel: "", 69 | }, 70 | } 71 | 72 | for _, tc := range testCases { 73 | testNode := Node{ 74 | Name: "workertest", 75 | Labels: []string{tc.nodeLabel}, 76 | } 77 | assert.Equal(t, tc.expectedOutput, testNode.IsWorker()) 78 | } 79 | } 80 | -------------------------------------------------------------------------------- /COMMITMENT: -------------------------------------------------------------------------------- 1 | GPL Cooperation Commitment 2 | Version 1.0 3 | 4 | Before filing or continuing to prosecute any legal proceeding or claim 5 | (other than a Defensive Action) arising from termination of a Covered 6 | License, we commit to extend to the person or entity ('you') accused 7 | of violating the Covered License the following provisions regarding 8 | cure and reinstatement, taken from GPL version 3. As used here, the 9 | term 'this License' refers to the specific Covered License being 10 | enforced. 11 | 12 | However, if you cease all violation of this License, then your 13 | license from a particular copyright holder is reinstated (a) 14 | provisionally, unless and until the copyright holder explicitly 15 | and finally terminates your license, and (b) permanently, if the 16 | copyright holder fails to notify you of the violation by some 17 | reasonable means prior to 60 days after the cessation. 18 | 19 | Moreover, your license from a particular copyright holder is 20 | reinstated permanently if the copyright holder notifies you of the 21 | violation by some reasonable means, this is the first time you 22 | have received notice of violation of this License (for any work) 23 | from that copyright holder, and you cure the violation prior to 30 24 | days after your receipt of the notice. 25 | 26 | We intend this Commitment to be irrevocable, and binding and 27 | enforceable against us and assignees of or successors to our 28 | copyrights. 29 | 30 | Definitions 31 | 32 | 'Covered License' means the GNU General Public License, version 2 33 | (GPLv2), the GNU Lesser General Public License, version 2.1 34 | (LGPLv2.1), or the GNU Library General Public License, version 2 35 | (LGPLv2), all as published by the Free Software Foundation. 36 | 37 | 'Defensive Action' means a legal proceeding or claim that We bring 38 | against you in response to a prior proceeding or claim initiated by 39 | you or your affiliate. 40 | 41 | 'We' means each contributor to this repository as of the date of 42 | inclusion of this file, including subsidiaries of a corporate 43 | contributor. 44 | 45 | This work is available under a Creative Commons Attribution-ShareAlike 46 | 4.0 International license (https://creativecommons.org/licenses/by-sa/4.0/). -------------------------------------------------------------------------------- /pkg/tnf/handlers/generic/assertion/or.go: -------------------------------------------------------------------------------- 1 | // Copyright (C) 2020-2022 Red Hat, Inc. 2 | // 3 | // This program is free software; you can redistribute it and/or modify 4 | // it under the terms of the GNU General Public License as published by 5 | // the Free Software Foundation; either version 2 of the License, or 6 | // (at your option) any later version. 7 | // 8 | // This program is distributed in the hope that it will be useful, 9 | // but WITHOUT ANY WARRANTY; without even the implied warranty of 10 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 11 | // GNU General Public License for more details. 12 | // 13 | // You should have received a copy of the GNU General Public License along 14 | // with this program; if not, write to the Free Software Foundation, Inc., 15 | // 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. 16 | 17 | package assertion 18 | 19 | import ( 20 | "regexp" 21 | ) 22 | 23 | const ( 24 | // OrBooleanLogicKey is the sentinel used for Type to identify OrBooleanLogicKey in a JSON/YAML payload. 25 | OrBooleanLogicKey = "or" 26 | ) 27 | 28 | // OrBooleanLogic is an implementation of the BooleanLogic interface. OrBooleanLogic dictates that at least one 29 | // assertion in a Assertions evaluates as true. Although OrBooleanLogic is exposed for serialization purposes, 30 | // it is recommended to instantiate instances of OrBooleanLogic using NewOrBooleanLogic. 31 | type OrBooleanLogic struct { 32 | // Type stores the sentinel which represents the type of BooleanLogic implemented. 33 | Type string `json:"type" yaml:"type"` 34 | } 35 | 36 | // NewOrBooleanLogic creates an instance of OrBooleanLogic. 37 | func NewOrBooleanLogic() *OrBooleanLogic { 38 | return &OrBooleanLogic{Type: OrBooleanLogicKey} 39 | } 40 | 41 | // Evaluate evaluates an arbitrarily sized array of Assertion and ensures at least one assertion passes. 42 | func (o OrBooleanLogic) Evaluate(assertions []Assertion, match string, regex *regexp.Regexp) (bool, error) { 43 | for _, assertion := range assertions { 44 | assertionResult, err := (*assertion.Condition).Evaluate(match, regex, assertion.GroupIdx) 45 | if err != nil { 46 | return false, err 47 | } 48 | if assertionResult { 49 | return true, nil 50 | } 51 | } 52 | return false, nil 53 | } 54 | -------------------------------------------------------------------------------- /pkg/tnf/testcases/data/cnf/privilegedroles.go: -------------------------------------------------------------------------------- 1 | // Copyright (C) 2020-2022 Red Hat, Inc. 2 | // 3 | // This program is free software; you can redistribute it and/or modify 4 | // it under the terms of the GNU General Public License as published by 5 | // the Free Software Foundation; either version 2 of the License, or 6 | // (at your option) any later version. 7 | // 8 | // This program is distributed in the hope that it will be useful, 9 | // but WITHOUT ANY WARRANTY; without even the implied warranty of 10 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 11 | // GNU General Public License for more details. 12 | // 13 | // You should have received a copy of the GNU General Public License along 14 | // with this program; if not, write to the Free Software Foundation, Inc., 15 | // 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. 16 | 17 | package cnf 18 | 19 | // RolesJSON test templates for testing permission 20 | //nolint:lll 21 | var RolesJSON = string(`{ 22 | "testcase": [ 23 | { 24 | "name": "CLUSTER_ROLE_BINDING_BY_SA", 25 | "skiptest": true, 26 | "command": "oc get clusterrolebinding -n %s -o json | jq --arg name 'ServiceAccount' --arg null ',null,' --arg subjects 'subjects' --arg ns '%s' --arg sa '%s' -jr 'if (.items|length)>0 then .items[] | if (has($subjects)) then .subjects[] | select((.namespace==$ns) and (.kind==$name) and (.name==$sa)).name else $null end else $null end'", 27 | "action": "deny", 28 | "loop": 0, 29 | "resulttype": "array", 30 | "expectedtype": "function", 31 | "expectedstatus": [ 32 | "FN_SERVICE_ACCOUNT_NAME" 33 | ] 34 | }, 35 | { 36 | "name": "ROLE_BINDING_BY_SA", 37 | "skiptest": true, 38 | "loop": 0, 39 | "command": "oc get rolebinding -n %s -o json | jq --arg name 'ServiceAccount' --arg null ',null,' --arg ns '%s' --arg subjects 'subjects' --arg sa '%s' -jr 'if (.items|length)>0 then .items[] | if (has($subjects)) then .subjects[] | select((.namespace==$ns) and (.kind==$name) and (.name==$sa)).name else $null end else $null end'", 40 | "action": "allow", 41 | "resulttype": "array", 42 | "expectedtype": "function", 43 | "expectedstatus": [ 44 | "FN_SERVICE_ACCOUNT_NAME", 45 | "null" 46 | ] 47 | } 48 | ] 49 | }`) 50 | -------------------------------------------------------------------------------- /pkg/tnf/handlers/generic/assertion/and_test.go: -------------------------------------------------------------------------------- 1 | // Copyright (C) 2020-2022 Red Hat, Inc. 2 | // 3 | // This program is free software; you can redistribute it and/or modify 4 | // it under the terms of the GNU General Public License as published by 5 | // the Free Software Foundation; either version 2 of the License, or 6 | // (at your option) any later version. 7 | // 8 | // This program is distributed in the hope that it will be useful, 9 | // but WITHOUT ANY WARRANTY; without even the implied warranty of 10 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 11 | // GNU General Public License for more details. 12 | // 13 | // You should have received a copy of the GNU General Public License along 14 | // with this program; if not, write to the Free Software Foundation, Inc., 15 | // 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. 16 | 17 | package assertion_test 18 | 19 | import ( 20 | "testing" 21 | 22 | "github.com/stretchr/testify/assert" 23 | "github.com/test-network-function/test-network-function/pkg/tnf/handlers/generic/assertion" 24 | "github.com/test-network-function/test-network-function/pkg/tnf/handlers/generic/condition" 25 | "github.com/test-network-function/test-network-function/pkg/tnf/handlers/generic/condition/stringcondition" 26 | ) 27 | 28 | var ( 29 | equalsAnotherThingStringCondition = stringcondition.NewEqualsCondition("AnotherThing") 30 | equalsSomethingStringCondition = stringcondition.NewEqualsCondition("Something") 31 | ) 32 | 33 | var equalsAnotherThingCondition condition.Condition = equalsAnotherThingStringCondition 34 | var equalsSomeThingCondition condition.Condition = equalsSomethingStringCondition 35 | 36 | func TestNewAndBooleanLogic(t *testing.T) { 37 | logic := assertion.NewAndBooleanLogic() 38 | assert.Equal(t, assertion.AndBooleanLogicKey, logic.Type) 39 | } 40 | 41 | func TestAndBooleanLogic_Evaluate(t *testing.T) { 42 | for _, testCase := range andBooleanLogicTestCases { 43 | logic := assertion.NewAndBooleanLogic() 44 | actualResult, actualError := logic.Evaluate(testCase.assertions, testCase.match, &testCase.regex) 45 | assert.Equal(t, assertion.AndBooleanLogicKey, logic.Type) 46 | assert.Equal(t, testCase.expectedAndBooleanLogicResult, actualResult) 47 | assert.Equal(t, testCase.expectedAndBooleanLogicError, actualError != nil) 48 | } 49 | } 50 | -------------------------------------------------------------------------------- /pkg/config/configsections/pod.go: -------------------------------------------------------------------------------- 1 | // Copyright (C) 2020-2022 Red Hat, Inc. 2 | // 3 | // This program is free software; you can redistribute it and/or modify 4 | // it under the terms of the GNU General Public License as published by 5 | // the Free Software Foundation; either version 2 of the License, or 6 | // (at your option) any later version. 7 | // 8 | // This program is distributed in the hope that it will be useful, 9 | // but WITHOUT ANY WARRANTY; without even the implied warranty of 10 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 11 | // GNU General Public License for more details. 12 | // 13 | // You should have received a copy of the GNU General Public License along 14 | // with this program; if not, write to the Free Software Foundation, Inc., 15 | // 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. 16 | 17 | package configsections 18 | 19 | // Pod defines cloud network function in the cluster 20 | type Pod struct { 21 | // Name is the name of a single Pod to test 22 | Name string `yaml:"name" json:"name"` 23 | 24 | // Namespace where the Pod is deployed 25 | Namespace string `yaml:"namespace" json:"namespace"` 26 | 27 | // ServiceAccount name used by the pod 28 | ServiceAccount string `yaml:"serviceaccount" json:"serviceaccount"` 29 | 30 | // ContainerCount is the count of containers inside the pod 31 | ContainerCount int `yaml:"containercount" json:"containercount"` 32 | 33 | // Tests this is list of test that need to run against the Pod. 34 | Tests []string `yaml:"tests" json:"tests"` 35 | 36 | DefaultNetworkIPAddresses []string `yaml:"defaultnetworkipaddresses,omitempty" json:"defaultnetworkipaddresses,omitempty"` 37 | 38 | // OpenShift Default network interface name (i.e., eth0) 39 | DefaultNetworkDevice string `yaml:"defaultNetworkDevice" json:"defaultNetworkDevice"` 40 | 41 | // MultusIPAddressesPerNet are the overlay IPs. 42 | MultusIPAddressesPerNet map[string][]string `yaml:"multusIpAddressesPerNet,omitempty" json:"multusIpAddressesPerNet,omitempty"` 43 | 44 | // Representation of the container in this pod used to run networing tests 45 | ContainerList []Container `yaml:"containerfornettests,omitempty" json:"containerfornettests,omitempty"` 46 | 47 | // IsManaged indicates whether this pod belongs to any other resource (deployment/statefulset). 48 | IsManaged bool 49 | } 50 | -------------------------------------------------------------------------------- /pkg/tnf/handlers/generic/condition/stringcondition/string.go: -------------------------------------------------------------------------------- 1 | // Copyright (C) 2020-2022 Red Hat, Inc. 2 | // 3 | // This program is free software; you can redistribute it and/or modify 4 | // it under the terms of the GNU General Public License as published by 5 | // the Free Software Foundation; either version 2 of the License, or 6 | // (at your option) any later version. 7 | // 8 | // This program is distributed in the hope that it will be useful, 9 | // but WITHOUT ANY WARRANTY; without even the implied warranty of 10 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 11 | // GNU General Public License for more details. 12 | // 13 | // You should have received a copy of the GNU General Public License along 14 | // with this program; if not, write to the Free Software Foundation, Inc., 15 | // 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. 16 | 17 | package stringcondition 18 | 19 | import ( 20 | "fmt" 21 | "regexp" 22 | ) 23 | 24 | const ( 25 | // EqualsConditionKey is the sentinel key identifying a string == comparison. 26 | EqualsConditionKey = "equals" 27 | ) 28 | 29 | // EqualsCondition is an implementation of the condition.Condition interface which evaluates string equality of a match 30 | // against Expected. Although EqualsCondition is exported for serialization reasons, it is recommended to instantiate 31 | // new instances of EqualsCondition using NewEqualsCondition. 32 | type EqualsCondition struct { 33 | // Type stores the sentinel which represents the type of Condition implemented. 34 | Type string `json:"type" yaml:"type"` 35 | // Expected is the expected string value. 36 | Expected string `json:"expected,omitempty" yaml:"expected,omitempty"` 37 | } 38 | 39 | // NewEqualsCondition creates an EqualsCondition. 40 | func NewEqualsCondition(expected string) *EqualsCondition { 41 | return &EqualsCondition{Type: EqualsConditionKey, Expected: expected} 42 | } 43 | 44 | // Evaluate evaluates string equality for a match against Expected. 45 | func (e EqualsCondition) Evaluate(match string, regex *regexp.Regexp, matchIdx int) (bool, error) { 46 | matches := regex.FindStringSubmatch(match) 47 | if len(matches) < matchIdx { 48 | return false, fmt.Errorf("matches \"%s\" has no index: %d", matches, matchIdx) 49 | } 50 | foundMatch := matches[matchIdx] 51 | return e.Expected == foundMatch, nil 52 | } 53 | -------------------------------------------------------------------------------- /pkg/config/config_instance_test.go: -------------------------------------------------------------------------------- 1 | // Copyright (C) 2020-2022 Red Hat, Inc. 2 | // 3 | // This program is free software; you can redistribute it and/or modify 4 | // it under the terms of the GNU General Public License as published by 5 | // the Free Software Foundation; either version 2 of the License, or 6 | // (at your option) any later version. 7 | // 8 | // This program is distributed in the hope that it will be useful, 9 | // but WITHOUT ANY WARRANTY; without even the implied warranty of 10 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 11 | // GNU General Public License for more details. 12 | // 13 | // You should have received a copy of the GNU General Public License along 14 | // with this program; if not, write to the Free Software Foundation, Inc., 15 | // 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. 16 | 17 | package config 18 | 19 | import ( 20 | "testing" 21 | 22 | "github.com/stretchr/testify/assert" 23 | "github.com/test-network-function/test-network-function/pkg/config/configsections" 24 | ) 25 | 26 | const ( 27 | filePath = "testdata/tnf_test_config.yml" 28 | ) 29 | 30 | const ( 31 | testDeploymentsNumber = 1 32 | testDeploymentName = "test" 33 | testDeploymentNamespace = "default" 34 | testDeploymentReplicas = 2 35 | 36 | testCrdsNumber = 2 37 | testCrdNameSuffix1 = "group1.test1.com" 38 | testCrdNameSuffix2 = "test2.com" 39 | ) 40 | 41 | func testLoadedDeployments(t *testing.T, deployments []configsections.PodSet) { 42 | assert.Equal(t, len(deployments), testDeploymentsNumber) 43 | assert.Equal(t, deployments[0].Name, testDeploymentName) 44 | assert.Equal(t, deployments[0].Namespace, testDeploymentNamespace) 45 | assert.Equal(t, deployments[0].Replicas, testDeploymentReplicas) 46 | } 47 | 48 | func testLoadedCrds(t *testing.T, crds []configsections.CrdFilter) { 49 | assert.Equal(t, len(crds), testCrdsNumber) 50 | assert.Equal(t, crds[0].NameSuffix, testCrdNameSuffix1) 51 | assert.Equal(t, crds[1].NameSuffix, testCrdNameSuffix2) 52 | } 53 | 54 | func TestLoadConfigFromFile(t *testing.T) { 55 | env := GetTestEnvironment() 56 | assert.Nil(t, env.loadConfigFromFile(filePath)) 57 | assert.NotNil(t, env.loadConfigFromFile(filePath)) // Loading when already loaded is an error case 58 | testLoadedDeployments(t, env.Config.DeploymentsUnderTest) 59 | testLoadedCrds(t, env.Config.CrdFilters) 60 | } 61 | -------------------------------------------------------------------------------- /pkg/tnf/handlers/handler_template/handler_test.tmpl: -------------------------------------------------------------------------------- 1 | // Copyright (C) 2020-2022 Red Hat, Inc. 2 | // 3 | // This program is free software; you can redistribute it and/or modify 4 | // it under the terms of the GNU General Public License as published by 5 | // the Free Software Foundation; either version 2 of the License, or 6 | // (at your option) any later version. 7 | // 8 | // This program is distributed in the hope that it will be useful, 9 | // but WITHOUT ANY WARRANTY; without even the implied warranty of 10 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 11 | // GNU General Public License for more details. 12 | // 13 | // You should have received a copy of the GNU General Public License along 14 | // with this program; if not, write to the Free Software Foundation, Inc., 15 | // 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. 16 | 17 | package {{ .LowerHandlername }} 18 | 19 | import ( 20 | "testing" 21 | ) 22 | 23 | const ( 24 | // adding special variable 25 | ) 26 | 27 | // Test_New{{ .UpperHandlername }} is the unit test for New{{ .UpperHandlername }}(). 28 | func Test_New{{ .UpperHandlername }}(t *testing.T) { 29 | // Todo: Write test. 30 | } 31 | 32 | // Test_{{ .UpperHandlername }}_Args is the unit test for {{ .UpperHandlername }}_Args(). 33 | func Test{{ .UpperHandlername }}_Args(t *testing.T) { 34 | // Todo: Write test. 35 | } 36 | 37 | // Test_{{ .UpperHandlername }}_GetIdentifier is the unit test for {{ .UpperHandlername }}_GetIdentifier(). 38 | func Test{{ .UpperHandlername }}_GetIdentifier(t *testing.T) { 39 | // Todo: Write test. 40 | } 41 | 42 | // Test_{{ .UpperHandlername }}_ReelFirst is the unit test for {{ .UpperHandlername }}_ReelFirst(). 43 | func Test{{ .UpperHandlername }}_ReelFirst(t *testing.T) { 44 | // Todo: Write test. 45 | } 46 | 47 | // Test_{{ .UpperHandlername }}_ReelEOF is the unit test for {{ .UpperHandlername }}_ReelEOF(). 48 | func Test{{ .UpperHandlername }}_ReelEOF(t *testing.T) { 49 | // Todo: Write test. 50 | } 51 | 52 | // Test_{{ .UpperHandlername }}_ReelTimeout is the unit test for {{ .UpperHandlername }}}_ReelTimeout(). 53 | func Test{{ .UpperHandlername }}_ReelTimeout(t *testing.T) { 54 | // Todo: Write test. 55 | } 56 | 57 | // Test_{{ .UpperHandlername }}_ReelMatch is the unit test for {{ .UpperHandlername }}_ReelMatch(). 58 | func Test{{ .UpperHandlername }}_ReelMatch(t *testing.T) { 59 | // Todo: Write test. 60 | } 61 | -------------------------------------------------------------------------------- /pkg/tnf/handlers/generic/assertion/and.go: -------------------------------------------------------------------------------- 1 | // Copyright (C) 2020-2022 Red Hat, Inc. 2 | // 3 | // This program is free software; you can redistribute it and/or modify 4 | // it under the terms of the GNU General Public License as published by 5 | // the Free Software Foundation; either version 2 of the License, or 6 | // (at your option) any later version. 7 | // 8 | // This program is distributed in the hope that it will be useful, 9 | // but WITHOUT ANY WARRANTY; without even the implied warranty of 10 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 11 | // GNU General Public License for more details. 12 | // 13 | // You should have received a copy of the GNU General Public License along 14 | // with this program; if not, write to the Free Software Foundation, Inc., 15 | // 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. 16 | 17 | package assertion 18 | 19 | import ( 20 | "regexp" 21 | ) 22 | 23 | const ( 24 | // AndBooleanLogicKey is the sentinel used for Type to identify AndBooleanLogic in a JSON/YAML payload. 25 | AndBooleanLogicKey = "and" 26 | ) 27 | 28 | // AndBooleanLogic is an implementation of the BooleanLogic interface. AndBooleanLogic dictates that all assertions in 29 | // a assertion.Assertions must evaluate as true. Although AndBooleanLogic is exposed for serialization purposes, 30 | // it is recommended to instantiate instances of AndBooleanLogic using NewAndBooleanLogic. 31 | type AndBooleanLogic struct { 32 | // Type stores the sentinel which represents the type of BooleanLogic implemented. 33 | Type string `json:"type" yaml:"type"` 34 | } 35 | 36 | // NewAndBooleanLogic creates an instance of AndBooleanLogic. 37 | func NewAndBooleanLogic() *AndBooleanLogic { 38 | return &AndBooleanLogic{Type: AndBooleanLogicKey} 39 | } 40 | 41 | // Evaluate evaluates an arbitrarily sized array of Assertion and ensures each assertion passes. 42 | func (a AndBooleanLogic) Evaluate(assertions []Assertion, match string, regex *regexp.Regexp) (bool, error) { 43 | // TODO This could be multi-threaded, but is unlikely worth doing from a risk-reward standpoint. 44 | for _, assertion := range assertions { 45 | assertionResult, err := (*assertion.Condition).Evaluate(match, regex, assertion.GroupIdx) 46 | // exit early if the condition is false or an error is encountered 47 | if !assertionResult || err != nil { 48 | return assertionResult, err 49 | } 50 | } 51 | return true, nil 52 | } 53 | -------------------------------------------------------------------------------- /pkg/tnf/testcases/files/cnf/privilegedpod.yml: -------------------------------------------------------------------------------- 1 | testcase: 2 | - name: HOST_NETWORK_CHECK 3 | skiptest: true 4 | loop: 0 5 | command: "oc get pod %s -n %s -o json | jq -r '.spec.hostNetwork'" 6 | action: allow 7 | expectedType: "regex" 8 | expectedstatus: 9 | - NULL_FALSE 10 | - name: HOST_PORT_CHECK 11 | skiptest: true 12 | loop: 0 13 | command: "oc get pod %s -n %s -o go-template='{{$putName := .metadata.name}}{{$cut := (index .spec.containers %d)}}{{range $cut.ports }}{{if .hostPort}}PUT {{$putName}} - CUT {{$cut.name}} has declared hostPort {{.hostPort}}{{\"\\n\"}}{{end}}{{end}}'" 14 | action: allow 15 | expectedType: "regex" 16 | expectedstatus: 17 | - "^()*$" 18 | - name: HOST_PATH_CHECK 19 | skiptest: true 20 | loop: 0 21 | command: "oc get pod %s -n %s -o json | jq -r '.spec.hostpath.path'" 22 | action: allow 23 | expectedType: "regex" 24 | expectedstatus: 25 | - NULL_FALSE 26 | - name: HOST_IPC_CHECK 27 | skiptest: true 28 | loop: 0 29 | command: "oc get pod %s -n %s -o json | jq -r '.spec.hostipc'" 30 | action: allow 31 | expectedType: "regex" 32 | expectedstatus: 33 | - NULL_FALSE 34 | - name: HOST_PID_CHECK 35 | skiptest: true 36 | loop: 0 37 | command: "oc get pod %s -n %s -o json | jq -r '.spec.hostpid'" 38 | action: allow 39 | expectedType: "regex" 40 | expectedstatus: 41 | - NULL_FALSE 42 | - name: CAPABILITY_CHECK 43 | skiptest: true 44 | loop: 0 45 | command: "oc get pod %s -n %s -o json | jq -r '.spec.containers[%d].securityContext.capabilities.add'" 46 | resultType: array 47 | action: deny 48 | expectedType: "regex" 49 | expectedstatus: 50 | - NET_ADMIN 51 | - SYS_ADMIN 52 | - NET_RAW 53 | - IPC_LOCK 54 | - name: ROOT_CHECK 55 | skiptest: true 56 | loop: 0 57 | command: "oc get pod %s -n %s -o json | jq -r '.spec.containers[%d].securityContext.runAsUser'" 58 | resulttype: string 59 | action: allow 60 | expectedType: "regex" 61 | expectedstatus: 62 | - NON_ZERO 63 | - name: PRIVILEGE_ESCALATION 64 | skiptest: true 65 | loop: 0 66 | command: "oc get pod %s -n %s -o json | jq -r '.spec.containers[%d].securityContext.allowPrivilegeEscalation'" 67 | action: allow 68 | expectedType: "regex" 69 | expectedstatus: 70 | - NULL_FALSE 71 | -------------------------------------------------------------------------------- /pkg/tnf/handlers/bootconfigentries/bootconfigentries_test.go: -------------------------------------------------------------------------------- 1 | // Copyright (C) 2021 Red Hat, Inc. 2 | // 3 | // This program is free software; you can redistribute it and/or modify 4 | // it under the terms of the GNU General Public License as published by 5 | // the Free Software Foundation; either version 2 of the License, or 6 | // (at your option) any later version. 7 | // 8 | // This program is distributed in the hope that it will be useful, 9 | // but WITHOUT ANY WARRANTY; without even the implied warranty of 10 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 11 | // GNU General Public License for more details. 12 | // 13 | // You should have received a copy of the GNU General Public License along 14 | // with this program; if not, write to the Free Software Foundation, Inc., 15 | // 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. 16 | 17 | package bootconfigentries_test 18 | 19 | import ( 20 | "regexp" 21 | "testing" 22 | "time" 23 | 24 | "github.com/stretchr/testify/assert" 25 | "github.com/test-network-function/test-network-function/pkg/tnf" 26 | "github.com/test-network-function/test-network-function/pkg/tnf/handlers/bootconfigentries" 27 | ) 28 | 29 | func TestNewBootConfigEntries(t *testing.T) { 30 | newBootConfig := bootconfigentries.NewBootConfigEntries(testTimeoutDuration) 31 | assert.NotNil(t, newBootConfig) 32 | assert.Equal(t, tnf.ERROR, newBootConfig.Result()) 33 | } 34 | 35 | func Test_ReelFirst(t *testing.T) { 36 | newBootConfig := bootconfigentries.NewBootConfigEntries(testTimeoutDuration) 37 | assert.NotNil(t, newBootConfig) 38 | firstStep := newBootConfig.ReelFirst() 39 | re := regexp.MustCompile(firstStep.Expect[0]) 40 | matches := re.FindStringSubmatch(testInput) 41 | assert.Len(t, matches, 1) 42 | assert.Equal(t, testInput, matches[0]) 43 | } 44 | 45 | func Test_ReelMatch(t *testing.T) { 46 | newBootConfig := bootconfigentries.NewBootConfigEntries(testTimeoutDuration) 47 | assert.NotNil(t, newBootConfig) 48 | step := newBootConfig.ReelMatch("", "", testInput) 49 | assert.Nil(t, step) 50 | assert.Equal(t, tnf.SUCCESS, newBootConfig.Result()) 51 | } 52 | 53 | // Just ensure there are no panics. 54 | func Test_ReelEof(t *testing.T) { 55 | newBootConfig := bootconfigentries.NewBootConfigEntries(testTimeoutDuration) 56 | assert.NotNil(t, newBootConfig) 57 | newBootConfig.ReelEOF() 58 | } 59 | 60 | const ( 61 | testTimeoutDuration = time.Second * 2 62 | testInput = `ostree-1-rhcos.conf 63 | ostree-2-rhcos.conf 64 | ` 65 | ) 66 | --------------------------------------------------------------------------------