Skip to content
GitLab
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
Mashudu modika
Cli
Commits
21b03a66
Commit
21b03a66
authored
Sep 16, 2021
by
Addshore
🏄
Browse files
dev hosts: Also add other created hosts
parent
6c0bf137
Changes
6
Hide whitespace changes
Inline
Side-by-side
internal/util/files/files.go
View file @
21b03a66
...
...
@@ -52,6 +52,10 @@ func AddLineUnique(line string, fileName string) {
/*Lines reads all lines from a file*/
func
Lines
(
fileName
string
)
[]
string
{
_
,
err
:=
os
.
Stat
(
fileName
)
if
err
!=
nil
{
return
[]
string
{}
}
file
,
err
:=
os
.
Open
(
fileName
)
if
err
!=
nil
{
panic
(
err
)
...
...
internal/util/files/files_test.go
View file @
21b03a66
...
...
@@ -36,19 +36,21 @@ func writeContentToTmpFile(content string) string {
return
tmpFile
.
Name
()
}
func
TestAddLinesUnique
(
t
*
testing
.
T
)
{
type
args
struct
{
lines
[]
string
filename
string
}
func
randomString
()
string
{
// A bit of randomness so that we dont need to open a file for our non existant test
chars
:=
[]
rune
(
"ABCDEFGHIJKLMNOPQRSTUVWXYZ"
)
var
b
strings
.
Builder
for
i
:=
0
;
i
<
10
;
i
++
{
b
.
WriteRune
(
chars
[
rand
.
Intn
(
len
(
chars
))])
}
rndstr
:=
b
.
String
()
return
b
.
String
()
}
func
TestAddLinesUnique
(
t
*
testing
.
T
)
{
type
args
struct
{
lines
[]
string
filename
string
}
tests
:=
[]
struct
{
name
string
...
...
@@ -59,7 +61,7 @@ func TestAddLinesUnique(t *testing.T) {
name
:
"Non Existant"
,
args
:
args
{
lines
:
[]
string
{
"foo"
},
filename
:
"/tmp/mwcli-test-files-empty-"
+
rnd
str
,
filename
:
"/tmp/mwcli-test-files-empty-"
+
r
a
nd
omString
()
,
},
want
:
"foo
\n
"
,
},
...
...
@@ -111,13 +113,21 @@ func TestLines(t *testing.T) {
type
args
struct
{
fileName
string
}
tests
:=
[]
struct
{
name
string
args
args
want
[]
string
}{
{
name
:
"None"
,
name
:
"Non Existant"
,
args
:
args
{
fileName
:
"/tmp/mwcli-test-files-empty-"
+
randomString
(),
},
want
:
[]
string
{},
},
{
name
:
"Empty"
,
args
:
args
{
fileName
:
writeContentToTmpFile
(
""
),
},
...
...
tests/docker-mw-extra-commands.sh
View file @
21b03a66
...
...
@@ -8,6 +8,9 @@ trap 'last_command=$current_command; current_command=$BASH_COMMAND' DEBUG
# echo an error message before exiting
trap
'echo "\"${last_command}\" command filed with exit code $?."'
EXIT
# Setup the default hosts in hosts file
./bin/mw docker hosts add
# Create
./bin/mw docker mediawiki create
...
...
@@ -47,6 +50,10 @@ cd ./../../../
# Destroy it all
./bin/mw docker destroy
# Remove hosts
./bin/mw docker hosts delete
# And make sure only 1 exists after
docker ps
docker ps |
wc
-l
|
grep
-q
"1"
\ No newline at end of file
tests/docker-mw-install-all-the-dbs.sh
View file @
21b03a66
...
...
@@ -8,6 +8,9 @@ trap 'last_command=$current_command; current_command=$BASH_COMMAND' DEBUG
# echo an error message before exiting
trap
'echo "\"${last_command}\" command filed with exit code $?."'
EXIT
# Setup the default hosts in hosts file
./bin/mw docker hosts add
# Create
./bin/mw docker mediawiki create
...
...
@@ -25,6 +28,8 @@ CURL=$(curl -s -L -N http://default.mediawiki.mwdd.localhost:8080) && echo $CURL
./bin/mw docker mediawiki
install
--dbname
mysqlwiki
--dbtype
mysql
./bin/mw docker mediawiki
install
--dbname
postgreswiki
--dbtype
postgres
./bin/mw docker mediawiki
install
--dbtype
sqlite
# Update the hosts file as we used new wiki names
./bin/mw docker hosts add
# Check the DB tools (phpmyadmin, adminer)
CURL
=
$(
curl
-s
-L
-N
http://phpmyadmin.mwdd.localhost:8080
)
&&
echo
$CURL
&&
echo
$CURL
|
grep
-q
"Open new phpMyAdmin window"
...
...
tests/docker-mw-mysql-suspend-resume-destroy.sh
View file @
21b03a66
...
...
@@ -8,6 +8,9 @@ trap 'last_command=$current_command; current_command=$BASH_COMMAND' DEBUG
# echo an error message before exiting
trap
'echo "\"${last_command}\" command filed with exit code $?."'
EXIT
# Setup the default hosts in hosts file
./bin/mw docker hosts add
# Create
./bin/mw docker mediawiki create
./bin/mw docker mediawiki create
...
...
@@ -17,8 +20,9 @@ trap 'echo "\"${last_command}\" command filed with exit code $?."' EXIT
./bin/mw docker docker-compose ps
./bin/mw docker
env
list
# Install & check
# Install
, add host
& check
./bin/mw docker mediawiki
install
--dbname
mysqlwiki
--dbtype
mysql
./bin/mw docker hosts add
CURL
=
$(
curl
-s
-L
-N
http://mysqlwiki.mediawiki.mwdd.localhost:8080
)
&&
echo
$CURL
&&
echo
$CURL
|
grep
-q
"MediaWiki has been installed"
# Suspend and resume and check the site is still there
...
...
tests/setup.sh
View file @
21b03a66
...
...
@@ -17,15 +17,6 @@ docker-compose version
./bin/mw docker
env
list
cat
$(
./bin/mw docker
env
where
)
# Setup hosts file for used domains
# TODO make the CLI manage this one day https://phabricator.wikimedia.org/T282337
echo
"127.0.0.1 default.mediawiki.mwdd.localhost"
>>
/etc/hosts
echo
"127.0.0.1 postgreswiki.mediawiki.mwdd.localhost"
>>
/etc/hosts
echo
"127.0.0.1 mysqlwiki.mediawiki.mwdd.localhost"
>>
/etc/hosts
echo
"127.0.0.1 phpmyadmin.mwdd.localhost"
>>
/etc/hosts
echo
"127.0.0.1 adminer.mwdd.localhost"
>>
/etc/hosts
cat
/etc/hosts
# Create a fresh LocalSettings.php file
rm
-f
mediawiki/LocalSettings.php
echo
"<?php"
>>
mediawiki/LocalSettings.php
...
...
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment