Skip to content

Commit 332f09e

Browse files
authored
Merge pull request #61 from rhmdnd/reimplement-manual-remediations
Reimplement manual remediations
2 parents 5b0741f + 5d7f382 commit 332f09e

4 files changed

Lines changed: 443 additions & 112 deletions

File tree

Makefile

Lines changed: 20 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -19,23 +19,23 @@ PLATFORM?=ocp
1919
all: e2e
2020

2121
.PHONY: e2e
22-
e2e: e2e-platform e2e-node ## Run the e2e tests. This runs both platform and node compliance tests.
22+
e2e: install-jq e2e-platform e2e-node ## Run the e2e tests. This runs both platform and node compliance tests.
2323

2424
.PHONY: e2e-platform
25-
e2e-platform: ## Run only platform compliance tests
26-
set -o pipefail; go test $(TEST_FLAGS) . -run=^TestPlatformCompliance$$ -install-operator=$(INSTALL_OPERATOR) -bypass-remediations="$(BYPASS_REMEDIATIONS)" -test-type="platform" | tee .e2e-platform-test-results.out
25+
e2e-platform: install-jq ## Run only platform compliance tests
26+
set -o pipefail; PATH=$$PATH:/tmp/bin go test $(TEST_FLAGS) . -run=^TestPlatformCompliance$$ -install-operator=$(INSTALL_OPERATOR) -bypass-remediations="$(BYPASS_REMEDIATIONS)" -test-type="platform" | tee .e2e-platform-test-results.out
2727

2828
.PHONY: e2e-node
29-
e2e-node: ## Run only node compliance tests
30-
set -o pipefail; go test $(TEST_FLAGS) . -run=^TestNodeCompliance$$ -install-operator=$(INSTALL_OPERATOR) -bypass-remediations="$(BYPASS_REMEDIATIONS)" -test-type="node" | tee .e2e-node-test-results.out
29+
e2e-node: install-jq ## Run only node compliance tests
30+
set -o pipefail; PATH=$$PATH:/tmp/bin go test $(TEST_FLAGS) . -run=^TestNodeCompliance$$ -install-operator=$(INSTALL_OPERATOR) -bypass-remediations="$(BYPASS_REMEDIATIONS)" -test-type="node" | tee .e2e-node-test-results.out
3131

3232
.PHONY: e2e-profile
33-
e2e-profile: ## Run TestProfile test only
34-
set -o pipefail; go test $(TEST_FLAGS) . -run=^TestProfile$$ -profile="$(PROFILE)" -product="$(PRODUCT)" -install-operator=$(INSTALL_OPERATOR) | tee .e2e-profile-test-results.out
33+
e2e-profile: install-jq ## Run TestProfile test only
34+
set -o pipefail; PATH=$$PATH:/tmp/bin go test $(TEST_FLAGS) . -run=^TestProfile$$ -profile="$(PROFILE)" -product="$(PRODUCT)" -install-operator=$(INSTALL_OPERATOR) | tee .e2e-profile-test-results.out
3535

3636
.PHONY: e2e-profile-remediations
37-
e2e-profile-remediations: ## Run TestProfile test only
38-
set -o pipefail; go test $(TEST_FLAGS) . -run=^TestProfileRemediations$$ -profile="$(PROFILE)" -product="$(PRODUCT)" -install-operator=$(INSTALL_OPERATOR) | tee .e2e-profile-test-results.out
37+
e2e-profile-remediations: install-jq ## Run TestProfile test only
38+
set -o pipefail; PATH=$$PATH:/tmp/bin go test $(TEST_FLAGS) . -run=^TestProfileRemediations$$ -profile="$(PROFILE)" -product="$(PRODUCT)" -install-operator=$(INSTALL_OPERATOR) | tee .e2e-profile-test-results.out
3939

4040
.PHONY: help
4141
help: ## Show this help screen
@@ -76,3 +76,14 @@ $(BUILD_DIR)/gofumpt: $(BUILD_DIR)
7676

7777
$(BUILD_DIR):
7878
@mkdir -p $(BUILD_DIR)
79+
80+
.PHONY: install-jq
81+
install-jq: ## Install jq if not available
82+
@if ! command -v jq >/dev/null 2>&1; then \
83+
echo "Installing jq..."; \
84+
mkdir -p /tmp/bin && \
85+
curl -L https://github.com/jqlang/jq/releases/download/jq-1.6/jq-linux64 -o /tmp/bin/jq && \
86+
chmod +x /tmp/bin/jq; \
87+
else \
88+
echo "jq is already installed"; \
89+
fi

config/config.go

Lines changed: 46 additions & 41 deletions
Original file line numberDiff line numberDiff line change
@@ -15,34 +15,36 @@ import (
1515
// TestConfig holds all the configuration arguments for the test suite
1616
// that can be passed between helper and test packages.
1717
type TestConfig struct {
18-
APIPollInterval time.Duration
19-
E2eSettings string
20-
TestProfileBundleName string
21-
OpenShiftBundleName string
22-
RHCOSBundleName string
23-
Profile string
24-
Product string
25-
Platform string
26-
ContentImage string
27-
ContentDir string
28-
LogDir string
29-
InstallOperator bool
30-
BypassRemediations bool
31-
TestType string
32-
OperatorNamespace types.NamespacedName
33-
Version string
18+
APIPollInterval time.Duration
19+
E2eSettings string
20+
TestProfileBundleName string
21+
OpenShiftBundleName string
22+
RHCOSBundleName string
23+
Profile string
24+
Product string
25+
Platform string
26+
ContentImage string
27+
ContentDir string
28+
LogDir string
29+
InstallOperator bool
30+
BypassRemediations bool
31+
TestType string
32+
OperatorNamespace types.NamespacedName
33+
Version string
34+
ManualRemediationTimeout time.Duration
3435
}
3536

3637
var (
37-
contentDir string
38-
product string
39-
profile string
40-
platform string
41-
contentImage string
42-
logDir string
43-
installOperator bool
44-
bypassRemediations bool
45-
testType string
38+
contentDir string
39+
product string
40+
profile string
41+
platform string
42+
contentImage string
43+
logDir string
44+
installOperator bool
45+
bypassRemediations bool
46+
testType string
47+
manualRemediationTimeout time.Duration
4648
)
4749

4850
// NewTestConfig creates a new TestConfig from the parsed flags and sets the
@@ -60,22 +62,23 @@ func NewTestConfig() *TestConfig {
6062
}
6163

6264
return &TestConfig{
63-
APIPollInterval: 5 * time.Second,
64-
E2eSettings: "e2e-debug",
65-
TestProfileBundleName: "e2e",
66-
OpenShiftBundleName: "e2e-ocp4",
67-
RHCOSBundleName: "e2e-rhcos4",
68-
Profile: profile,
69-
Product: product,
70-
Platform: platform,
71-
ContentImage: contentImage,
72-
ContentDir: "", // Will be set during setup
73-
LogDir: logDir,
74-
InstallOperator: installOperator,
75-
BypassRemediations: bypassRemediations,
76-
TestType: testType,
77-
OperatorNamespace: types.NamespacedName{Name: "compliance-operator", Namespace: "openshift-compliance"},
78-
Version: version,
65+
APIPollInterval: 5 * time.Second,
66+
E2eSettings: "e2e-debug",
67+
TestProfileBundleName: "e2e",
68+
OpenShiftBundleName: "e2e-ocp4",
69+
RHCOSBundleName: "e2e-rhcos4",
70+
Profile: profile,
71+
Product: product,
72+
Platform: platform,
73+
ContentImage: contentImage,
74+
ContentDir: contentDir,
75+
LogDir: logDir,
76+
InstallOperator: installOperator,
77+
BypassRemediations: bypassRemediations,
78+
TestType: testType,
79+
OperatorNamespace: types.NamespacedName{Name: "compliance-operator", Namespace: "openshift-compliance"},
80+
Version: version,
81+
ManualRemediationTimeout: manualRemediationTimeout,
7982
}
8083
}
8184

@@ -94,6 +97,8 @@ func DefineFlags() {
9497
flag.BoolVar(&bypassRemediations, "bypass-remediations", false,
9598
"Do not apply remediations and summarize results after the first scan")
9699
flag.StringVar(&testType, "test-type", "all", "Type of rules to test: 'platform', 'node', or 'all' (default)")
100+
flag.DurationVar(&manualRemediationTimeout,
101+
"manual-remediation-timeout", 30*time.Minute, "Timeout for manual remediation scripts")
97102
}
98103

99104
// ValidateFlags checks that required flags are provided.

0 commit comments

Comments
 (0)