Skip to content

Commit

Permalink
doc: add doc for operator config
Browse files Browse the repository at this point in the history
  • Loading branch information
tylergu committed Jun 24, 2022
1 parent 2062836 commit a52b521
Show file tree
Hide file tree
Showing 24 changed files with 64 additions and 3,599 deletions.
55 changes: 32 additions & 23 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -15,29 +15,38 @@
To run the test:
```
python3 acto.py \
--seed SEED, -s SEED seed CR file
--operator OPERATOR, -o OPERATOR
yaml file for deploying the operator with kubectl
--helm OPERATOR_CHART
Path of operator helm chart
--kustomize KUSTOMIZE
Path of folder with kustomize
--init INIT Path of init yaml file (deploy before operator)
--duration DURATION, -d DURATION
Number of hours to run
--preload-images [PRELOAD_IMAGES ...]
Docker images to preload into Kind cluster
--crd-name CRD_NAME Name of CRD to use, required if there are multiple CRDs
--helper-crd HELPER_CRD
generated CRD file that helps with the input generation
--custom-fields CUSTOM_FIELDS
Python source file containing a list of custom fields
--analysis-result ANALYSIS_RESULT
JSON file resulted from the code analysis
--context CONTEXT Cached context data
--num-workers NUM_WORKERS
Number of concurrent workers to run Acto with
--dryrun Only generate test cases without executing them
--config CONFIG, -c CONFIG
Operator port config path
--duration DURATION, -d DURATION
Number of hours to run
--preload-images [PRELOAD_IMAGES [PRELOAD_IMAGES ...]]
Docker images to preload into Kind cluster
--helper-crd HELPER_CRD
generated CRD file that helps with the input generation
--context CONTEXT Cached context data
--num-workers NUM_WORKERS
Number of concurrent workers to run Acto with
--dryrun Only generate test cases without executing them
```

## Operator config example
```json
{
"deploy": {
"method": "YAML", // Three deploy methods [YAML HELM KUSTOMIZE]
"file": "data/rabbitmq-operator/operator.yaml", // the deployment file
"init": null // any yaml to deploy for deploying the operator itself
},
"crd_name": null, // name of the CRD to test, optional if there is only one CRD
"custom_fields": "data.rabbitmq-operator.prune", // to guide the pruning
"seed_custom_resource": "data/rabbitmq-operator/cr.yaml", // the seed CR file
"analysis": {
"github_link": "https://github.com/rabbitmq/cluster-operator.git", // github link for the operator repo
"commit": "f2ab5cecca7fa4bbba62ba084bfa4ae1b25d15ff", // specific commit hash of the repo
"type": "RabbitmqCluster", // the root type of the CR
"package": "github.com/rabbitmq/cluster-operator/api/v1beta1" // package of the root type
}
}
```

## Known Issues
Expand Down
35 changes: 12 additions & 23 deletions acto.py
Original file line number Diff line number Diff line change
Expand Up @@ -308,8 +308,8 @@ def __init__(self,
# first make sure images are present locally
for image in self.context['preload_images']:
subprocess.run(['docker', 'pull', image])
subprocess.run(['docker', 'image', 'save', '-o',
self.images_archive] + list(self.context['preload_images']))
subprocess.run(['docker', 'image', 'save', '-o', self.images_archive] +
list(self.context['preload_images']))

# Generate test cases
self.test_plan = self.input_model.generate_test_plan()
Expand Down Expand Up @@ -339,12 +339,16 @@ def __learn(self, context_file, helper_crd):
process_crd(self.context, apiclient, 'learn', self.crd_name, helper_crd)
kind_delete_cluster('learn')

with tempfile.TemporaryDirectory() as project_src:
subprocess.run(['git', 'clone', self.operator_config.github_link, project_src])
subprocess.run(['git', '-C', project_src, 'checkout', self.operator_config.commit])
self.context['analysis_result'] = analyze(project_src,
self.operator_config.seedType.type,
self.operator_config.seedType.package)
if self.operator_config.analysis != None:
with tempfile.TemporaryDirectory() as project_src:
subprocess.run(
['git', 'clone', self.operator_config.analysis.github_link, project_src])
subprocess.run([
'git', '-C', project_src, 'checkout', self.operator_config.analysis.commit
])
self.context['analysis_result'] = analyze(project_src,
self.operator_config.analysis.type,
self.operator_config.analysis.package)
with open(context_file, 'w') as context_fout:
json.dump(self.context, context_fout, cls=ActoEncoder)

Expand Down Expand Up @@ -402,21 +406,6 @@ def thread_excepthook(args):
parser = argparse.ArgumentParser(
description='Automatic, Continuous Testing for k8s/openshift Operators')
parser.add_argument('--config', '-c', dest='config', help='Operator port config path')
deploy_method = parser.add_mutually_exclusive_group(required=True)
deploy_method.add_argument('--operator',
'-o',
dest='operator',
required=False,
help="yaml file for deploying the\
operator with kubectl")
deploy_method.add_argument('--helm',
dest='operator_chart',
required=False,
help='Path of operator helm chart')
deploy_method.add_argument('--kustomize',
dest='kustomize',
required=False,
help='Path of folder with kustomize')
parser.add_argument('--duration',
'-d',
dest='duration',
Expand Down
20 changes: 11 additions & 9 deletions common.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,27 +22,26 @@ def __init__(self, method: str, file: str, init: str) -> None:
self.init = init


class SeedType:
class AnalysisConfig:

def __init__(self, type: str, package: str) -> None:
def __init__(self, github_link: str, commit: str, type: str, package: str) -> None:
self.github_link = github_link
self.commit = commit
self.type = type
self.package = package


class OperatorConfig:

def __init__(self, github_link: str, commit: str, deploy: DeployConfig, crd_name: str,
custom_fields: str, context: str, seed_custom_resource: str, source_path: str,
seedType: SeedType) -> None:
self.github_link = github_link
self.commit = commit
def __init__(self, deploy: DeployConfig, crd_name: str, custom_fields: str, context: str,
seed_custom_resource: str, source_path: str, analysis: AnalysisConfig) -> None:
self.deploy = deploy
self.crd_name = crd_name
self.custom_fields = custom_fields
self.context = context
self.seed_custom_resource = seed_custom_resource
self.source_path = source_path
self.seedType = seedType
self.analysis = analysis


class Diff:
Expand Down Expand Up @@ -348,7 +347,10 @@ def kind_delete_cluster(name: str):
subprocess.run(cmd)


def kubectl(args: list, cluster_name: str, capture_output=False, text=False) -> subprocess.CompletedProcess:
def kubectl(args: list,
cluster_name: str,
capture_output=False,
text=False) -> subprocess.CompletedProcess:
cmd = ['kubectl']
cmd.extend(args)

Expand Down
4 changes: 2 additions & 2 deletions data/cass-operator/config.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,4 @@
{
"github_link": "https://github.com/k8ssandra/cass-operator.git",
"commit": "241e71cdd32bd9f8a7e5c00d5427cdcaf9f55497",
"deploy": {
"method": "KUSTOMIZE",
"file": "github.com/k8ssandra/cass-operator/config/deployments/cluster?ref=v1.10.3",
Expand All @@ -10,6 +8,8 @@
"custom_fields": "data.cass-operator.prune",
"seed_custom_resource": "data/cass-operator/cr.yaml",
"seedType": {
"github_link": "https://github.com/k8ssandra/cass-operator.git",
"commit": "241e71cdd32bd9f8a7e5c00d5427cdcaf9f55497",
"type": "CassandraDatacenter",
"package": "github.com/k8ssandra/cass-operator/apis/cassandra/v1beta1"
}
Expand Down
5 changes: 0 additions & 5 deletions data/casskop-operator/candidates.yaml

This file was deleted.

17 changes: 0 additions & 17 deletions data/casskop-operator/cassandra-operator/Chart.yaml

This file was deleted.

8 changes: 0 additions & 8 deletions data/casskop-operator/cassandra-operator/OWNERS

This file was deleted.

Loading

0 comments on commit a52b521

Please sign in to comment.