Compare commits
4 commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
b813a07f7e | ||
|
|
35193e7f84 | ||
|
|
9f373d34ba | ||
|
|
363171d04e |
14 changed files with 308 additions and 106 deletions
29
Dockerfile
Normal file
29
Dockerfile
Normal file
|
|
@ -0,0 +1,29 @@
|
||||||
|
FROM docker.io/fedora:25
|
||||||
|
|
||||||
|
MAINTAINER "James Antill" <james.antill@redhat.com>
|
||||||
|
|
||||||
|
RUN dnf install -y --setopt=tsflags=nodocs samba && \
|
||||||
|
dnf install -y --setopt=tsflags=nodocs /usr/bin/pidof && \
|
||||||
|
dnf install -y --setopt=tsflags=nodocs python-mako PyYAML && \
|
||||||
|
dnf -y clean all
|
||||||
|
|
||||||
|
ADD files /files
|
||||||
|
|
||||||
|
# mkdir -p /srv/samba/Demo/
|
||||||
|
RUN mkdir -p /srv/samba
|
||||||
|
RUN /files/config.sh
|
||||||
|
|
||||||
|
RUN sh -c 'date > /srv/samba/tst-build'
|
||||||
|
|
||||||
|
EXPOSE 138/udp
|
||||||
|
EXPOSE 139
|
||||||
|
EXPOSE 445
|
||||||
|
EXPOSE 137/udp
|
||||||
|
EXPOSE 445/udp
|
||||||
|
|
||||||
|
|
||||||
|
# VOLUME ['/var/log', '/srv/samba']
|
||||||
|
|
||||||
|
# USER samba
|
||||||
|
|
||||||
|
CMD ["/files/start.sh"]
|
||||||
16
Makefile
Normal file
16
Makefile
Normal file
|
|
@ -0,0 +1,16 @@
|
||||||
|
IMAGE_NAME = samba
|
||||||
|
|
||||||
|
MODULEMDURL=file://samba.yaml
|
||||||
|
|
||||||
|
default: run
|
||||||
|
|
||||||
|
build:
|
||||||
|
docker build --tag=$(IMAGE_NAME) .
|
||||||
|
|
||||||
|
run: build
|
||||||
|
docker run -d $(IMAGE_NAME)
|
||||||
|
|
||||||
|
test: build
|
||||||
|
cd tests; MODULE=docker MODULEMD=$(MODULEMDURL) URL="docker=$(IMAGE_NAME)" make all
|
||||||
|
cd tests; MODULE=rpm MODULEMD=$(MODULEMDURL) URL="docker=$(IMAGE_NAME)" make all
|
||||||
|
|
||||||
6
files/config.sh
Executable file
6
files/config.sh
Executable file
|
|
@ -0,0 +1,6 @@
|
||||||
|
#! /bin/sh -e
|
||||||
|
|
||||||
|
echo Config.
|
||||||
|
python /files/mako-render.py /files/smb.conf.mako /files/config.yaml \
|
||||||
|
> /etc/samba/smb.conf
|
||||||
|
|
||||||
2
files/config.yaml
Normal file
2
files/config.yaml
Normal file
|
|
@ -0,0 +1,2 @@
|
||||||
|
mounts:
|
||||||
|
- /srv/samba
|
||||||
23
files/mako-render.py
Normal file
23
files/mako-render.py
Normal file
|
|
@ -0,0 +1,23 @@
|
||||||
|
#!/usr/bin/python
|
||||||
|
|
||||||
|
from __future__ import print_function, unicode_literals
|
||||||
|
|
||||||
|
import argparse
|
||||||
|
import mako.template
|
||||||
|
import yaml
|
||||||
|
|
||||||
|
def main():
|
||||||
|
parser = argparse.ArgumentParser()
|
||||||
|
parser.add_argument("template")
|
||||||
|
parser.add_argument("data")
|
||||||
|
options = parser.parse_args()
|
||||||
|
|
||||||
|
with open(options.template) as stream:
|
||||||
|
template = mako.template.Template(stream.read())
|
||||||
|
with open(options.data) as stream:
|
||||||
|
data = yaml.load(stream)
|
||||||
|
|
||||||
|
print(template.render(**data))
|
||||||
|
|
||||||
|
if __name__ == '__main__':
|
||||||
|
main()
|
||||||
20
files/smb.conf.mako
Normal file
20
files/smb.conf.mako
Normal file
|
|
@ -0,0 +1,20 @@
|
||||||
|
|
||||||
|
[global]
|
||||||
|
server string = Samba Server Version %v
|
||||||
|
security = user
|
||||||
|
map to guest = bad user
|
||||||
|
# guest account = samba
|
||||||
|
hosts allow = *
|
||||||
|
dead time = 15
|
||||||
|
socket options = TCP_NODELAY SO_KEEPALIVE SO_RCVBUF=17520 SO_SNDBUF=17520 IPTOS_LOWDELAY
|
||||||
|
|
||||||
|
[public]
|
||||||
|
comment = Public test
|
||||||
|
path = /srv/samba
|
||||||
|
public = yes
|
||||||
|
guest ok = yes
|
||||||
|
read only = yes
|
||||||
|
printable = no
|
||||||
|
writeable = no
|
||||||
|
browseable = yes
|
||||||
|
|
||||||
38
files/start.sh
Executable file
38
files/start.sh
Executable file
|
|
@ -0,0 +1,38 @@
|
||||||
|
#! /bin/sh -e
|
||||||
|
|
||||||
|
function first
|
||||||
|
{
|
||||||
|
echo $1
|
||||||
|
}
|
||||||
|
|
||||||
|
function rest
|
||||||
|
{
|
||||||
|
shift
|
||||||
|
echo $@
|
||||||
|
}
|
||||||
|
|
||||||
|
date > /srv/samba/tst-run
|
||||||
|
|
||||||
|
/usr/sbin/nmbd -D
|
||||||
|
/usr/sbin/smbd -D
|
||||||
|
|
||||||
|
waits="1 1 2 4 8 16 32 64 360"
|
||||||
|
|
||||||
|
while pidof smbd > /dev/null && pidof nmbd > /dev/null ; do
|
||||||
|
date
|
||||||
|
echo "SMBd proces" $(pidof smbd)
|
||||||
|
echo "NMBd proces" $(pidof nmbd)
|
||||||
|
sleep $(first $waits)
|
||||||
|
if [ "x$(rest $waits)" != "x" ]; then
|
||||||
|
waits="$(rest $waits)"
|
||||||
|
fi
|
||||||
|
echo
|
||||||
|
done
|
||||||
|
|
||||||
|
if ! pidof nmbd; then
|
||||||
|
echo "NMBd is not running."
|
||||||
|
fi
|
||||||
|
|
||||||
|
if ! pidof smbd; then
|
||||||
|
echo "SMBd is not running."
|
||||||
|
fi
|
||||||
125
samba.yaml
125
samba.yaml
|
|
@ -1,109 +1,22 @@
|
||||||
document: modulemd
|
document: modulemd
|
||||||
version: 1
|
version: 1
|
||||||
data:
|
data:
|
||||||
summary: samba module
|
name: ''
|
||||||
description: This samba module has been generated.
|
stream: ''
|
||||||
license:
|
summary: Server and Client software to interoperate with Windows machines
|
||||||
module:
|
version: 0
|
||||||
- MIT
|
dependencies:
|
||||||
dependencies:
|
buildrequires: {bootstrap: f26}
|
||||||
buildrequires:
|
requires: {bootstrap: f26}
|
||||||
bootstrap: master
|
description: 'Samba is the standard Windows interoperability suite of programs for
|
||||||
requires:
|
Linux and Unix.'
|
||||||
platform: master
|
license:
|
||||||
python2: master
|
content: [GPLv3+ and LGPLv3+]
|
||||||
python2-ecosystem: master
|
module: [MIT]
|
||||||
libtom: master
|
api:
|
||||||
references:
|
rpms: [samba, samba-common, samba-client]
|
||||||
community: https://docs.pagure.org/modularity/
|
components:
|
||||||
documentation: https://github.com/modularity-modules/samba
|
rpms:
|
||||||
tracker: https://github.com/modularity-modules/samba
|
samba: {buildorder: 10, rationale: Runtime dependency.}
|
||||||
api:
|
|
||||||
rpms:
|
|
||||||
- libldb
|
|
||||||
- libsmbclient
|
|
||||||
- libtdb
|
|
||||||
- libwbclient
|
|
||||||
- python2-samba
|
|
||||||
- samba
|
|
||||||
- samba-client-libs
|
|
||||||
- samba-common
|
|
||||||
- samba-common-libs
|
|
||||||
- samba-common-tools
|
|
||||||
- samba-dc-libs
|
|
||||||
- samba-libs
|
|
||||||
- samba-winbind
|
|
||||||
- samba-winbind-modules
|
|
||||||
profiles:
|
|
||||||
default:
|
|
||||||
description: A generated profile based on top-lvl package list.
|
|
||||||
rpms:
|
|
||||||
- libldb
|
|
||||||
- libsmbclient
|
|
||||||
- libtdb
|
|
||||||
- libwbclient
|
|
||||||
- python2-samba
|
|
||||||
- samba
|
|
||||||
- samba-client-libs
|
|
||||||
- samba-common
|
|
||||||
- samba-common-libs
|
|
||||||
- samba-common-tools
|
|
||||||
- samba-dc-libs
|
|
||||||
- samba-libs
|
|
||||||
- samba-winbind
|
|
||||||
- samba-winbind-modules
|
|
||||||
client:
|
|
||||||
description: SMB File sharing client
|
|
||||||
rpms:
|
|
||||||
- libsmbclient
|
|
||||||
- libtdb
|
|
||||||
- samba-client
|
|
||||||
- samba-client-libs
|
|
||||||
- samba-common
|
|
||||||
- samba-common-libs
|
|
||||||
- samba-common-tools
|
|
||||||
server:
|
|
||||||
description: SMB File sharing server
|
|
||||||
rpms:
|
|
||||||
- libldb
|
|
||||||
- libtdb
|
|
||||||
- samba
|
|
||||||
- samba-common
|
|
||||||
- samba-common-libs
|
|
||||||
- samba-common-tools
|
|
||||||
- samba-libs
|
|
||||||
domainclient:
|
|
||||||
description: SMB Domain Client
|
|
||||||
rpms:
|
|
||||||
- libtdb
|
|
||||||
- libwbclient
|
|
||||||
- samba-client-libs
|
|
||||||
- samba-common
|
|
||||||
- samba-common-libs
|
|
||||||
- samba-common-tools
|
|
||||||
- samba-libs
|
|
||||||
- samba-winbind
|
|
||||||
- samba-winbind-modules
|
|
||||||
domaincontroller:
|
|
||||||
description: Windows Domain Controller
|
|
||||||
rpms:
|
|
||||||
- samba-dc
|
|
||||||
components:
|
|
||||||
rpms:
|
|
||||||
avahi:
|
|
||||||
rationale: Generated.
|
|
||||||
ref: 64b07e2fc1d770e12b97ef0296a62f80984d88c0
|
|
||||||
cups:
|
|
||||||
rationale: Generated.
|
|
||||||
ref: b85c292042537a333350465e946606907214aeb5
|
|
||||||
libldb:
|
|
||||||
rationale: Generated.
|
|
||||||
ref: df8cc6a1d9e2bb5296a46287ce03390b1201e5da
|
|
||||||
buildorder: 5
|
|
||||||
libtdb:
|
|
||||||
rationale: Generated.
|
|
||||||
ref: 94c6c6d0e350e5e35776aace06cd0fafbaaa800d
|
|
||||||
samba:
|
|
||||||
rationale: Generated.
|
|
||||||
ref: 8b94bf9ddc2a818eace810b47957650b47383389
|
|
||||||
buildorder: 10
|
|
||||||
|
|
|
||||||
7
tests/Makefile
Normal file
7
tests/Makefile
Normal file
|
|
@ -0,0 +1,7 @@
|
||||||
|
MODULE_LINT=/usr/share/moduleframework/tools/modulelint.py
|
||||||
|
CMD=python -m avocado run --filter-by-tags=-WIP $(MODULE_LINT) *.py
|
||||||
|
|
||||||
|
#
|
||||||
|
all:
|
||||||
|
generator
|
||||||
|
$(CMD)
|
||||||
23
tests/config.yaml
Normal file
23
tests/config.yaml
Normal file
|
|
@ -0,0 +1,23 @@
|
||||||
|
document: modularity-testing
|
||||||
|
version: 1
|
||||||
|
name: samba
|
||||||
|
modulemd-url: http://pkgs.fedoraproject.org/cgit/modules/samba.git/tree/samba.yaml
|
||||||
|
service:
|
||||||
|
port: [138/udp, 139, 445, 137/udp, 445/udp]
|
||||||
|
packages:
|
||||||
|
rpms:
|
||||||
|
- samba
|
||||||
|
module:
|
||||||
|
docker:
|
||||||
|
start: "docker run -it -P"
|
||||||
|
labels:
|
||||||
|
description: "Server and Client software to interoperate with Windows machines"
|
||||||
|
io.k8s.description: "Server and Client software to interoperate with Windows machines"
|
||||||
|
source: https://github.com/container-images/samba.git
|
||||||
|
container: docker.io/modularitycontainers/samba
|
||||||
|
rpm:
|
||||||
|
start: /usr/sbin/smbd &
|
||||||
|
repo: https://kojipkgs.stg.fedoraproject.org/compose/branched/jkaluza/latest-Fedora-Modular-26/compose/Server/x86_64/os/
|
||||||
|
test:
|
||||||
|
processrunning:
|
||||||
|
- 'ls /proc/*/exe -alh | grep smbd'
|
||||||
17
tests/generated.py
Normal file
17
tests/generated.py
Normal file
|
|
@ -0,0 +1,17 @@
|
||||||
|
#!/usr/bin/python
|
||||||
|
|
||||||
|
import socket
|
||||||
|
from avocado import main
|
||||||
|
from moduleframework import module_framework
|
||||||
|
|
||||||
|
if __name__ == '__main__':
|
||||||
|
main()
|
||||||
|
|
||||||
|
class GeneratedTestsConfig(module_framework.AvocadoTest):
|
||||||
|
"""
|
||||||
|
:avocado: enable
|
||||||
|
"""
|
||||||
|
|
||||||
|
def test_processrunning(self):
|
||||||
|
self.start()
|
||||||
|
self.run("ls /proc/*/exe -alh | grep smbd")
|
||||||
BIN
tests/generated.pyc
Normal file
BIN
tests/generated.pyc
Normal file
Binary file not shown.
51
tests/sanity.py
Normal file
51
tests/sanity.py
Normal file
|
|
@ -0,0 +1,51 @@
|
||||||
|
#!/usr/bin/python
|
||||||
|
# -*- coding: utf-8 -*-
|
||||||
|
#
|
||||||
|
# This Modularity Testing Framework helps you to write tests for modules
|
||||||
|
# Copyright (C) 2017 Red Hat, Inc.
|
||||||
|
#
|
||||||
|
# This program is free software; you can redistribute it and/or modify
|
||||||
|
# it under the terms of the GNU General Public License as published by
|
||||||
|
# he Free Software Foundation; either version 2 of the License, or
|
||||||
|
# (at your option) any later version.
|
||||||
|
#
|
||||||
|
# This program is distributed in the hope that it will be useful,
|
||||||
|
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
# GNU General Public License for more details.
|
||||||
|
#
|
||||||
|
# You should have received a copy of the GNU General Public License along
|
||||||
|
# with this program; if not, write to the Free Software Foundation, Inc.,
|
||||||
|
# 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
|
||||||
|
#
|
||||||
|
# Authors: Dominika Hodovska <dhodovsk@redhat.com>
|
||||||
|
#
|
||||||
|
|
||||||
|
from avocado import main
|
||||||
|
from avocado.core import exceptions
|
||||||
|
from moduleframework import module_framework
|
||||||
|
|
||||||
|
|
||||||
|
class SanityCheck(module_framework.AvocadoTest):
|
||||||
|
"""
|
||||||
|
:avocado: enable
|
||||||
|
"""
|
||||||
|
|
||||||
|
def test(self):
|
||||||
|
"""
|
||||||
|
Simple sanity test
|
||||||
|
"""
|
||||||
|
|
||||||
|
self.start()
|
||||||
|
self.run("ls / | grep bin")
|
||||||
|
|
||||||
|
def testSambaVersion(self):
|
||||||
|
"""
|
||||||
|
Check if httpd is installed in correct version
|
||||||
|
"""
|
||||||
|
version = "4.5"
|
||||||
|
self.start()
|
||||||
|
self.run("smbcontrol -V | grep {}".format(version))
|
||||||
|
|
||||||
|
if __name__ == '__main__':
|
||||||
|
main()
|
||||||
57
tests/smbconfig.py
Normal file
57
tests/smbconfig.py
Normal file
|
|
@ -0,0 +1,57 @@
|
||||||
|
#!/usr/bin/python
|
||||||
|
# -*- coding: utf-8 -*-
|
||||||
|
#
|
||||||
|
# This Modularity Testing Framework helps you to write tests for modules
|
||||||
|
# Copyright (C) 2017 Red Hat, Inc.
|
||||||
|
#
|
||||||
|
# This program is free software; you can redistribute it and/or modify
|
||||||
|
# it under the terms of the GNU General Public License as published by
|
||||||
|
# he Free Software Foundation; either version 2 of the License, or
|
||||||
|
# (at your option) any later version.
|
||||||
|
#
|
||||||
|
# This program is distributed in the hope that it will be useful,
|
||||||
|
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
# GNU General Public License for more details.
|
||||||
|
#
|
||||||
|
# You should have received a copy of the GNU General Public License along
|
||||||
|
# with this program; if not, write to the Free Software Foundation, Inc.,
|
||||||
|
# 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
|
||||||
|
#
|
||||||
|
# Authors: Dominika Hodovska <dhodovsk@redhat.com>
|
||||||
|
#
|
||||||
|
|
||||||
|
from avocado import main
|
||||||
|
from avocado.core import exceptions
|
||||||
|
from moduleframework import module_framework
|
||||||
|
|
||||||
|
|
||||||
|
class SmbConfCheck(module_framework.AvocadoTest):
|
||||||
|
"""
|
||||||
|
:avocado: enable
|
||||||
|
"""
|
||||||
|
def testTestParamFail(self):
|
||||||
|
"""
|
||||||
|
Valid failure of testparam
|
||||||
|
"""
|
||||||
|
|
||||||
|
self.start()
|
||||||
|
|
||||||
|
self.run("testparm -s > /smb-fail")
|
||||||
|
self.run("printf \"\\n[fail]\\n\\tcomment = bad config\\n\" >> /smb-fail")
|
||||||
|
# No path
|
||||||
|
self.run("testparm -s /smb-fail > /out.txt")
|
||||||
|
self.run("cat out.txt | grep \"available = No\"")
|
||||||
|
|
||||||
|
self.run("rm /out.txt")
|
||||||
|
self.run("testparm -s > /smb-fail")
|
||||||
|
|
||||||
|
# bad mask
|
||||||
|
self.run("printf \"\\n[fail]\\n\\tcomment = bad config\\n\" >> /smb-fail")
|
||||||
|
self.run("printf \"\\tcreate mask = 9999\\n\" >> /smb-fail")
|
||||||
|
self.run("testparm -s /smb-fail > /out.txt; [ $? -ne 0 ]")
|
||||||
|
|
||||||
|
self.run("[ ! -s /out.txt ]")
|
||||||
|
|
||||||
|
if __name__ == '__main__':
|
||||||
|
main()
|
||||||
Loading…
Add table
Add a link
Reference in a new issue