Skip to content

Commit 9cf9161

Browse files
authored
Merge pull request #93 from angelabriel/master
Fix problems found by the test
2 parents 1dcfece + 40e0dcb commit 9cf9161

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

95 files changed

+3056
-575
lines changed

Diff for: .github/workflows/saptune-ut.yml

+2-2
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ name: saptuneUnittst
44
on:
55
# Triggers the workflow on pull request events but only for the master and sle-12 branch
66
push:
7-
branches: [ saptune_test ]
7+
branches: [ master, saptune_test ]
88
pull_request:
99
branches: [ master ]
1010

@@ -54,7 +54,7 @@ jobs:
5454

5555
- name: Code Climate report coverage
5656
run: ./cc-test-reporter after-build --debug --prefix ${{ env.CC_PREFIX }} --exit-code $?
57-
if: github.event_name != 'pull_request'
57+
if: ${{ env.CC_TEST_REPORTER_ID }}
5858

5959
- name: Stop and remove Docker Image
6060
run: |

Diff for: README.md

+17-5
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11

2-
[![Build Status](https://travis-ci.org/SUSE/saptune.svg?branch=master)](https://travis-ci.org/SUSE/saptune)
2+
[![Build Status](https://github.com/SUSE/saptune/actions/workflows/saptune-ut.yml/badge.svg)](https://github.com/SUSE/saptune/actions/workflows/saptune-ut.yml/badge.svg)
33
[![Test Coverage](https://api.codeclimate.com/v1/badges/5375e2ca293dd0e8b322/test_coverage)](https://codeclimate.com/github/SUSE/saptune/test_coverage)
44
[![Maintainability](https://api.codeclimate.com/v1/badges/5375e2ca293dd0e8b322/maintainability)](https://codeclimate.com/github/SUSE/saptune/maintainability)
55

@@ -47,7 +47,7 @@ They give our administrators and our partners a simple way to implement their ow
4747

4848
# Migration:
4949

50-
Guide to help you migrate to the new saptune\
50+
Guide to help you migrate from saptune running version <b>1</b> to the saptune version 2 or 3\
5151
Migration? Isn’t a simple package update enough?
5252

5353
Not in every case.
@@ -57,8 +57,18 @@ If the update discovers applied saptune SAP notes or solutions, saptune will con
5757
The switch to version 2 has to be done deliberately.\
5858
To help you, we will provide a step-by-step guide. Just plan your switch when you are ready, no rush!
5959

60-
We will support saptune version 1 until end of the lifetime of SLES 12 / SLES 15 SP1, which should give enough time to move. Although please bear in mind that since saptune version 1 will be deprecated, we will only do bug fixing. New features, new SAP notes or new parameters will only be done for version 2!
60+
We will support saptune version 1 until end of the lifetime of SLES 12 / SLES 15 SP1, which should give enough time to move. Although please bear in mind that since saptune version 1 will be deprecated, we will only do bug fixing. New features, new SAP notes or new parameters will only be done for future versions of saptune!
6161

62+
With saptune version 3 the support for version 1 is <b>abandoned</b>.
63+
If the migration from version 1 to version 2 or 3 was not done before the package update, saptune will not work and that's expected.
64+
But all needed files for the migration are still available, so following the procedure described in the man page saptune-migrate(7) will bring you back to a working saptune.
65+
66+
For the update from version 2 to version 3 <b>NO</b> migration is needed.
67+
68+
But as we discontinued the use of tuned to get the tuning started during boot and instead use our own systemd service <b>saptune.service</b> we will need to stop the tuning of the system during the package update for a short timeframe to avoid tuned error messages.
69+
70+
If you are used to start saptune using tuned directly in the past, please move to <b>'saptune service start'</b> instead.
71+
If you use <b>'saptune daemon start'</b>, you will now get a 'deprecated' warning, but the command will still continue to work.
6272

6373
# Where to find documentation?
6474

@@ -68,12 +78,14 @@ When the technical blog series about the details of saptune and how to do a migr
6878
For now:\
6979
<https://www.suse.com/c/a-new-saptune-is-knocking-on-your-door/>\
7080
<https://www.suse.com/c/a-new-saptune-is-here/>\
71-
<https://www.suse.com/c/saptune-a-deep-dive/>
81+
<https://www.suse.com/c/saptune-a-deep-dive/>\
82+
<https://www.suse.com/c/saptune-3-is-on-the-horizon/>\
83+
<https://www.suse.com/c/saptune-3-is-here/>
7284

7385

7486
# Feedback
7587

76-
Supporters, contributors, colleagues, customers and partners are welcome to approach us with ideas and suggestions. If you miss something or you think something should be done better, then don’t hesitate to contact us. You are welcome to give further feedback via email at SapAlliance@suse.com, create an issue in this repository, carrier pigeon etc. and tell us your needs.\
88+
Supporters, contributors, colleagues, customers and partners are welcome to approach us with ideas and suggestions. If you miss something or you think something should be done better, then don’t hesitate to contact us. You are welcome to give further feedback via email at sapalliance@suse.com, create an issue in this repository, carrier pigeon etc. and tell us your needs.\
7789
With each new version of saptune we implement many of them, but the journey will continue and you can expect further enhancements in the future.
7890

7991

Diff for: actions/actions.go

+14-9
Original file line numberDiff line numberDiff line change
@@ -74,7 +74,7 @@ var dfltColorScheme = "full-red-noncmpl"
7474

7575
// SelectAction selects the chosen action depending on the first command line
7676
// argument
77-
func SelectAction(stApp *app.App, saptuneVers string) {
77+
func SelectAction(writer io.Writer, stApp *app.App, saptuneVers string) {
7878
// switch off color and highlighting, if Stdout is not a terminal
7979
switchOffColor()
8080
system.JnotSupportedYet()
@@ -86,21 +86,21 @@ func SelectAction(stApp *app.App, saptuneVers string) {
8686

8787
switch system.CliArg(1) {
8888
case "daemon":
89-
DaemonAction(os.Stdout, system.CliArg(2), saptuneVers, stApp)
89+
DaemonAction(writer, system.CliArg(2), saptuneVers, stApp)
9090
case "service":
91-
ServiceAction(system.CliArg(2), saptuneVers, stApp)
91+
ServiceAction(writer, system.CliArg(2), saptuneVers, stApp)
9292
case "note":
93-
NoteAction(system.CliArg(2), system.CliArg(3), system.CliArg(4), stApp)
93+
NoteAction(writer, system.CliArg(2), system.CliArg(3), system.CliArg(4), stApp)
9494
case "solution":
95-
SolutionAction(system.CliArg(2), system.CliArg(3), system.CliArg(4), stApp)
95+
SolutionAction(writer, system.CliArg(2), system.CliArg(3), system.CliArg(4), stApp)
9696
case "revert":
97-
RevertAction(os.Stdout, system.CliArg(2), stApp)
97+
RevertAction(writer, system.CliArg(2), stApp)
9898
case "staging":
9999
StagingAction(system.CliArg(2), system.CliArgs(3), stApp)
100100
case "status":
101-
ServiceAction("status", saptuneVers, stApp)
101+
ServiceAction(writer, "status", saptuneVers, stApp)
102102
default:
103-
PrintHelpAndExit(os.Stdout, 1)
103+
PrintHelpAndExit(writer, 1)
104104
}
105105
}
106106

@@ -139,15 +139,20 @@ func rememberMessage(writer io.Writer) {
139139

140140
// VerifyAllParameters Verify that all system parameters do not deviate from any of the enabled solutions/notes.
141141
func VerifyAllParameters(writer io.Writer, tuneApp *app.App) {
142+
result := system.JPNotes{}
142143
if len(tuneApp.NoteApplyOrder) == 0 {
143144
fmt.Fprintf(writer, "No notes or solutions enabled, nothing to verify.\n")
144145
} else {
145146
unsatisfiedNotes, comparisons, err := tuneApp.VerifyAll()
146147
if err != nil {
147148
system.ErrorExit("Failed to inspect the current system: %v", err)
148149
}
149-
PrintNoteFields(writer, "NONE", comparisons, true)
150+
PrintNoteFields(writer, "NONE", comparisons, true, &result)
150151
tuneApp.PrintNoteApplyOrder(writer)
152+
result.NotesOrder = tuneApp.NoteApplyOrder
153+
sysComp := len(unsatisfiedNotes) == 0
154+
result.SysCompliance = &sysComp
155+
system.Jcollect(result)
151156
if len(unsatisfiedNotes) == 0 {
152157
fmt.Fprintf(writer, "%s%sThe running system is currently well-tuned according to all of the enabled notes.%s%s\n", setGreenText, setBoldText, resetBoldText, resetTextColor)
153158
} else {

Diff for: actions/actionsMatchtxt_test.go

+112
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,112 @@
1+
package actions
2+
3+
import (
4+
"fmt"
5+
"github.com/SUSE/saptune/system"
6+
)
7+
8+
var noteListMatchText = `
9+
All notes (+ denotes manually enabled notes, * denotes notes enabled by solutions, - denotes notes enabled by solutions but reverted manually later, O denotes override file exists for note, C denotes custom note):
10+
900929 Linux: STORAGE_PARAMETERS_WRONG_SET and 'mmap() failed'
11+
Version 7 from 31.07.2017
12+
https://launchpad.support.sap.com/#/notes/900929
13+
NEWSOL2NOTE
14+
extraNote Configuration drop in for extra tests
15+
Version 0 from 04.06.2019
16+
oldFile Name_syntax
17+
simpleNote Configuration drop in for simple tests
18+
Version 1 from 09.07.2019
19+
wrongFileNamesyntax
20+
21+
Remember: if you wish to automatically activate the solution's tuning options after a reboot, you must enable and start saptune.service by running:
22+
saptune service enablestart
23+
`
24+
25+
var solutionListMatchText = `
26+
All solutions (* denotes enabled solution, O denotes override file exists for solution, C denotes custom solutions, D denotes deprecated solutions):
27+
BWA - SAP_BWA
28+
HANA - 941735 1771258 1980196 1984787 2205917 2382421 2534844
29+
MAXDB - 941735 1771258 1984787
30+
NETW - 941735 1771258 1980196 1984787 2534844
31+
32+
Remember: if you wish to automatically activate the solution's tuning options after a reboot, you must enable and start saptune.service by running:
33+
saptune service enablestart
34+
`
35+
36+
var saptuneStatusMatchText = fmt.Sprintf(`
37+
saptune.service: disabled/active
38+
saptune package: 'undef'
39+
configured version: '3'
40+
enabled Solution: sol1 (simpleNote)
41+
applied Solution:
42+
additional enabled Notes: 2205917
43+
enabled Notes: 2205917
44+
applied Notes:
45+
staging: disabled
46+
staged Notes:
47+
staged Solutions:
48+
49+
sapconf.service: not available
50+
tuned.service: disabled/active (profile: '%s')
51+
system state: running
52+
virtualization: %s
53+
54+
Remember: if you wish to automatically activate the note's and solution's tuning options after a reboot, you must enable saptune.service by running:
55+
'saptune service enable'.
56+
57+
`, system.GetTunedAdmProfile(), system.GetVirtStatus())
58+
59+
var saptuneStatMatchText = fmt.Sprintf(`
60+
saptune.service: disabled/inactive
61+
saptune package: 'undef'
62+
configured version: '3'
63+
enabled Solution:
64+
applied Solution:
65+
additional enabled Notes:
66+
enabled Notes:
67+
applied Notes:
68+
staging: disabled
69+
staged Notes:
70+
staged Solutions:
71+
72+
sapconf.service: not available
73+
tuned.service: disabled/active (profile: '%s')
74+
system state: running
75+
virtualization: %s
76+
77+
Remember: if you wish to automatically activate the note's and solution's tuning options after a reboot, you must enable saptune.service by running:
78+
'saptune service enablestart'.
79+
Your system has not yet been tuned. Please visit `+"`"+`saptune note`+"`"+` and `+"`"+`saptune solution`+"`"+` to start tuning.
80+
81+
`, system.GetTunedAdmProfile(), system.GetVirtStatus())
82+
83+
var PrintHelpAndExitMatchText = `saptune: Comprehensive system optimisation management for SAP solutions.
84+
Daemon control:
85+
saptune daemon [ start | status | stop ] ATTENTION: deprecated
86+
saptune service [ start | status | stop | restart | takeover | enable | disable | enablestart | disablestop ]
87+
Tune system according to SAP and SUSE notes:
88+
saptune note [ list | revertall | enabled | applied ]
89+
saptune note [ apply | simulate | customise | create | edit | revert | show | delete ] NoteID
90+
saptune note verify [--colorscheme=<color scheme>] [--show-non-compliant] [NoteID]
91+
saptune note rename NoteID newNoteID
92+
Tune system for all notes applicable to your SAP solution:
93+
saptune solution [ list | verify | enabled | applied ]
94+
saptune solution [ apply | simulate | verify | customise | create | edit | revert | show | delete ] SolutionName
95+
saptune solution rename SolutionName newSolutionName
96+
Staging control:
97+
saptune staging [ status | enable | disable | is-enabled | list | diff | analysis | release ]
98+
saptune staging [ analysis | diff ] [ NoteID... | SolutionID... | all ]
99+
saptune staging release [--force|--dry-run] [ NoteID... | SolutionID... | all ]
100+
Revert all parameters tuned by the SAP notes or solutions:
101+
saptune revert all
102+
Remove the pending lock file from a former saptune call
103+
saptune lock remove
104+
Call external script '/usr/sbin/saptune_check'
105+
saptune check
106+
Print current saptune status:
107+
saptune status
108+
Print current saptune version:
109+
saptune version
110+
Print this message:
111+
saptune help
112+
`

Diff for: actions/actions_test.go

+19-65
Original file line numberDiff line numberDiff line change
@@ -16,9 +16,10 @@ import (
1616

1717
var SolutionSheetsInGOPATH = path.Join(os.Getenv("GOPATH"), "/src/github.com/SUSE/saptune/testdata/sol/sols") + "/"
1818
var ExtraFilesInGOPATH = path.Join(os.Getenv("GOPATH"), "/src/github.com/SUSE/saptune/testdata/extra") + "/"
19+
var ExtraTstFilesInGOPATH = path.Join(os.Getenv("GOPATH"), "/src/github.com/SUSE/saptune/testdata/etc/saptune/extra") + "/"
1920
var OverTstFilesInGOPATH = path.Join(os.Getenv("GOPATH"), "/src/github.com/SUSE/saptune/testdata/etc/saptune/override") + "/"
2021
var DeprecFilesInGOPATH = path.Join(os.Getenv("GOPATH"), "/src/github.com/SUSE/saptune/testdata/sol/deprecated") + "/"
21-
var TstFilesInGOPATH = path.Join(os.Getenv("GOPATH"), "/src/github.com/SUSE/saptune/testdata/")
22+
var TstFilesInGOPATH = path.Join(os.Getenv("GOPATH"), "/src/github.com/SUSE/saptune/testdata") + "/"
2223

2324
var AllTestSolutions = map[string]solution.Solution{
2425
"sol1": {"simpleNote"},
@@ -40,6 +41,18 @@ var tstErrorExitOut = func(str string, out ...interface{}) error {
4041
return fmt.Errorf(str+"\n", out...)
4142
}
4243

44+
var switchOnColor = func(t *testing.T) {
45+
setGreenText = "\033[32m"
46+
setRedText = "\033[31m"
47+
setYellowText = "\033[33m"
48+
setBlueText = "\033[34m"
49+
setBoldText = "\033[1m"
50+
resetBoldText = "\033[22m"
51+
setStrikeText = "\033[9m"
52+
resetTextColor = "\033[0m"
53+
dfltColorScheme = "full-red-noncmpl"
54+
}
55+
4356
var checkOut = func(t *testing.T, got, want string) {
4457
t.Helper()
4558
if got != want {
@@ -118,39 +131,9 @@ Parameters tuned by the notes and solutions have been successfully reverted.
118131
// this errExitMatchText differs from the 'real' text by the last 2 lines
119132
// because of test situation, the 'exit 1' in PrintHelpAndExit is not
120133
// executed (as designed for testing)
121-
errExitMatchText := fmt.Sprintf(`saptune: Comprehensive system optimisation management for SAP solutions.
122-
Daemon control:
123-
saptune daemon [ start | status | stop ] ATTENTION: deprecated
124-
saptune service [ start | status | stop | restart | takeover | enable | disable | enablestart | disablestop ]
125-
Tune system according to SAP and SUSE notes:
126-
saptune note [ list | revertall | enabled | applied ]
127-
saptune note [ apply | simulate | customise | create | edit | revert | show | delete ] NoteID
128-
saptune note verify [--colorscheme=<color scheme>] [--show-non-compliant] [NoteID]
129-
saptune note rename NoteID newNoteID
130-
Tune system for all notes applicable to your SAP solution:
131-
saptune solution [ list | verify | enabled | applied ]
132-
saptune solution [ apply | simulate | verify | customise | create | edit | revert | show | delete ] SolutionName
133-
saptune solution rename SolutionName newSolutionName
134-
Staging control:
135-
saptune staging [ status | enable | disable | is-enabled | list | diff | analysis | release ]
136-
saptune staging [ analysis | diff ] [ NoteID... | SolutionID... | all ]
137-
saptune staging release [--force|--dry-run] [ NoteID... | SolutionID... | all ]
138-
Revert all parameters tuned by the SAP notes or solutions:
139-
saptune revert all
140-
Remove the pending lock file from a former saptune call
141-
saptune lock remove
142-
Call external script '/usr/sbin/saptune_check'
143-
saptune check
144-
Print current saptune status:
145-
saptune status
146-
Print current saptune version:
147-
saptune version
148-
Print this message:
149-
saptune help
150-
Reverting all notes and solutions, this may take some time...
134+
errExitMatchText := PrintHelpAndExitMatchText + `Reverting all notes and solutions, this may take some time...
151135
Parameters tuned by the notes and solutions have been successfully reverted.
152-
`)
153-
136+
`
154137
buffer.Reset()
155138
// reset tApp variables, which were deleted by 'revert all'
156139
tearDown(t)
@@ -206,7 +189,7 @@ func TestGetFileName(t *testing.T) {
206189
// test with non-existing extra note
207190
nID = "hugo"
208191
getFnameMatchText := fmt.Sprintf("ERROR: Note %s not found in %s or %s.\n", nID, "", ExtraFilesInGOPATH)
209-
fname, extra = getFileName(nID, "", ExtraFilesInGOPATH)
192+
_, _ = getFileName(nID, "", ExtraFilesInGOPATH)
210193
if tstRetErrorExit != 1 {
211194
t.Errorf("error exit should be '1' and NOT '%v'\n", tstRetErrorExit)
212195
}
@@ -215,7 +198,7 @@ func TestGetFileName(t *testing.T) {
215198
}
216199

217200
func TestReadYesNo(t *testing.T) {
218-
yesnoMatchText := fmt.Sprintf("Answer is [y/n]: ")
201+
yesnoMatchText := "Answer is [y/n]: "
219202
buffer := bytes.Buffer{}
220203
input := "yes\n"
221204
if !readYesNo("Answer is", strings.NewReader(input), &buffer) {
@@ -242,36 +225,7 @@ func TestPrintHelpAndExit(t *testing.T) {
242225
defer func() { system.ErrorExitOut = oldErrorExitOut }()
243226
system.ErrorExitOut = tstErrorExitOut
244227

245-
errExitMatchText := fmt.Sprintf(`saptune: Comprehensive system optimisation management for SAP solutions.
246-
Daemon control:
247-
saptune daemon [ start | status | stop ] ATTENTION: deprecated
248-
saptune service [ start | status | stop | restart | takeover | enable | disable | enablestart | disablestop ]
249-
Tune system according to SAP and SUSE notes:
250-
saptune note [ list | revertall | enabled | applied ]
251-
saptune note [ apply | simulate | customise | create | edit | revert | show | delete ] NoteID
252-
saptune note verify [--colorscheme=<color scheme>] [--show-non-compliant] [NoteID]
253-
saptune note rename NoteID newNoteID
254-
Tune system for all notes applicable to your SAP solution:
255-
saptune solution [ list | verify | enabled | applied ]
256-
saptune solution [ apply | simulate | verify | customise | create | edit | revert | show | delete ] SolutionName
257-
saptune solution rename SolutionName newSolutionName
258-
Staging control:
259-
saptune staging [ status | enable | disable | is-enabled | list | diff | analysis | release ]
260-
saptune staging [ analysis | diff ] [ NoteID... | SolutionID... | all ]
261-
saptune staging release [--force|--dry-run] [ NoteID... | SolutionID... | all ]
262-
Revert all parameters tuned by the SAP notes or solutions:
263-
saptune revert all
264-
Remove the pending lock file from a former saptune call
265-
saptune lock remove
266-
Call external script '/usr/sbin/saptune_check'
267-
saptune check
268-
Print current saptune status:
269-
saptune status
270-
Print current saptune version:
271-
saptune version
272-
Print this message:
273-
saptune help
274-
`)
228+
errExitMatchText := PrintHelpAndExitMatchText
275229
errExitbuffer := bytes.Buffer{}
276230
tstwriter = &errExitbuffer
277231
buffer := bytes.Buffer{}

Diff for: actions/footnote.go

+5-2
Original file line numberDiff line numberDiff line change
@@ -122,7 +122,9 @@ func setUsNa(actVal, compliant, comment string, footnote []string) (string, stri
122122
compliant = compliant + " [16]"
123123
compliant = strings.Replace(compliant, "no ", " - ", 1)
124124
comment = comment + " [16]"
125-
footnote[15] = footnote16
125+
if !system.IsFlagSet("show-non-compliant") {
126+
footnote[15] = footnote16
127+
}
126128
}
127129
return compliant, comment, footnote
128130
}
@@ -165,7 +167,8 @@ func setSecBoot(mapKey, compliant, comment string, footnote []string) (string, s
165167
// setFLdiffs sets footnote for diffs in force_latency parameter
166168
func setFLdiffs(mapKey, compliant, comment, info string, footnote []string) (string, string, []string) {
167169
if mapKey == "force_latency" && info == "hasDiffs" {
168-
compliant = "no [4]"
170+
compliant = compliant + " [4]"
171+
compliant = strings.Replace(compliant, " - ", "no ", 1)
169172
comment = comment + " [4]"
170173
footnote[3] = footnote4
171174
}

0 commit comments

Comments
 (0)