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
dCache
cta
Commits
762a76b7
Commit
762a76b7
authored
Feb 04, 2020
by
Cedric CAFFY
Browse files
Renamed StatisticsCmd in StatisticsSaveCmd
Added the enty in the cta.spec.in
parent
55d7cd85
Changes
8
Hide whitespace changes
Inline
Side-by-side
cta.spec.in
View file @
762a76b7
...
...
@@ -318,6 +318,7 @@ Scripts and utilities to faciliate working with the CTA catalogue
%attr(0755,root,root) %{_bindir}/cta-catalogue-schema-drop
%attr(0755,root,root) %{_bindir}/cta-catalogue-schema-verify
%attr(0755,root,root) %{_bindir}/cta-database-poll
%attr(0755,root,root) %{_bindir}/cta-statistics-save
%attr(0644,root,root) %doc /usr/share/man/man1/cta-catalogue-admin-user-create.1cta.gz
%attr(0644,root,root) %doc /usr/share/man/man1/cta-catalogue-schema-create.1cta.gz
%attr(0644,root,root) %doc /usr/share/man/man1/cta-catalogue-schema-drop.1cta.gz
...
...
statistics/CMakeLists.txt
View file @
762a76b7
...
...
@@ -23,9 +23,9 @@ include_directories (${ORACLE-INSTANTCLIENT_INCLUDE_DIRS})
set
(
CMAKE_CXX_FLAGS
"
${
CMAKE_CXX_FLAGS
}
-Wshadow"
)
set
(
STATISTICS_LIB_SRC_FILES
StatisticsCmd.cpp
StatisticsCmdLineArgs.cpp
StatisticsCmdMain.cpp
Statistics
Save
Cmd.cpp
Statistics
Save
CmdLineArgs.cpp
Statistics
Save
CmdMain.cpp
StatisticsSchema.cpp
)
...
...
@@ -68,27 +68,16 @@ install (FILES ${CMAKE_SOURCE_DIR}/catalogue/cta-catalogue.conf.example
DESTINATION
${
CMAKE_INSTALL_SYSCONFDIR
}
/cta
PERMISSIONS OWNER_READ OWNER_WRITE GROUP_READ WORLD_READ
)
add_executable
(
cta-statistics
StatisticsCmd.cpp
StatisticsCmdLineArgs.cpp
StatisticsCmdMain.cpp
add_executable
(
cta-statistics
-save
Statistics
Save
Cmd.cpp
Statistics
Save
CmdLineArgs.cpp
Statistics
Save
CmdMain.cpp
MysqlStatisticsSchema.cpp
)
target_link_libraries
(
cta-statistics ctastatistics ctacatalogue ctaschemachecker
)
target_link_libraries
(
cta-statistics
-save
ctastatistics ctacatalogue ctaschemachecker
)
set_property
(
TARGET cta-statistics APPEND PROPERTY INSTALL_RPATH
${
PROTOBUF3_RPATH
}
)
set_property
(
TARGET cta-
catalogue-schema-creat
e APPEND PROPERTY INSTALL_RPATH
${
ORACLE-INSTANTCLIENT_RPATH
}
)
set_property
(
TARGET cta-statistics
-save
APPEND PROPERTY INSTALL_RPATH
${
PROTOBUF3_RPATH
}
)
set_property
(
TARGET cta-
statistics-sav
e APPEND PROPERTY INSTALL_RPATH
${
ORACLE-INSTANTCLIENT_RPATH
}
)
install
(
TARGETS cta-statistics DESTINATION /usr/bin
)
set
(
STATISTICS_CMD_LINE_UNIT_TESTS_LIB_SRC_FILES
StatisticsCmdLineArgsTest.cpp
)
add_library
(
ctastatisticscmdlineunittests SHARED
${
STATISTICS_CMD_LINE_UNIT_TESTS_LIB_SRC_FILES
}
)
set_property
(
TARGET ctastatisticscmdlineunittests PROPERTY SOVERSION
"
${
CTA_SOVERSION
}
"
)
set_property
(
TARGET ctastatisticscmdlineunittests PROPERTY VERSION
"
${
CTA_LIBVERSION
}
"
)
install
(
TARGETS ctastatisticscmdlineunittests DESTINATION usr/
${
CMAKE_INSTALL_LIBDIR
}
)
install
(
TARGETS cta-statistics-save DESTINATION /usr/bin
)
\ No newline at end of file
statistics/StatisticsCmdLineArgsTest.cpp
deleted
100644 → 0
View file @
55d7cd85
/*
* The CERN Tape Archive(CTA) project
* Copyright(C) 2015 CERN
*
* 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
* the Free Software Foundation, either version 3 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, see <http://www.gnu.org/licenses/>.
*/
#include
"common/exception/Exception.hpp"
#include
"catalogue/VerifySchemaCmdLineArgs.hpp"
#include
<gtest/gtest.h>
#include
<list>
namespace
unitTests
{
class
cta_catalogue_VerifySchemaCmdLineArgsTest
:
public
::
testing
::
Test
{
protected:
struct
Argcv
{
int
argc
;
char
**
argv
;
Argcv
()
:
argc
(
0
),
argv
(
NULL
)
{
}
};
typedef
std
::
list
<
Argcv
*>
ArgcvList
;
ArgcvList
m_argsList
;
/**
* Creates a duplicate string using the new operator.
*/
char
*
dupString
(
const
char
*
str
)
{
const
size_t
len
=
strlen
(
str
);
char
*
duplicate
=
new
char
[
len
+
1
];
strncpy
(
duplicate
,
str
,
len
);
duplicate
[
len
]
=
'\0'
;
return
duplicate
;
}
virtual
void
SetUp
()
{
// Allow getopt_long to be called again
optind
=
0
;
}
virtual
void
TearDown
()
{
// Allow getopt_long to be called again
optind
=
0
;
for
(
ArgcvList
::
const_iterator
itor
=
m_argsList
.
begin
();
itor
!=
m_argsList
.
end
();
itor
++
)
{
for
(
int
i
=
0
;
i
<
(
*
itor
)
->
argc
;
i
++
)
{
delete
[]
(
*
itor
)
->
argv
[
i
];
}
delete
[]
(
*
itor
)
->
argv
;
delete
*
itor
;
}
}
};
TEST_F
(
cta_catalogue_VerifySchemaCmdLineArgsTest
,
help_short
)
{
using
namespace
cta
::
catalogue
;
Argcv
*
args
=
new
Argcv
();
m_argsList
.
push_back
(
args
);
args
->
argc
=
2
;
args
->
argv
=
new
char
*
[
3
];
args
->
argv
[
0
]
=
dupString
(
"cta-catalogue-schema-verify"
);
args
->
argv
[
1
]
=
dupString
(
"-h"
);
args
->
argv
[
2
]
=
NULL
;
VerifySchemaCmdLineArgs
cmdLine
(
args
->
argc
,
args
->
argv
);
ASSERT_TRUE
(
cmdLine
.
help
);
ASSERT_TRUE
(
cmdLine
.
dbConfigPath
.
empty
());
}
TEST_F
(
cta_catalogue_VerifySchemaCmdLineArgsTest
,
help_long
)
{
using
namespace
cta
::
catalogue
;
Argcv
*
args
=
new
Argcv
();
m_argsList
.
push_back
(
args
);
args
->
argc
=
2
;
args
->
argv
=
new
char
*
[
3
];
args
->
argv
[
0
]
=
dupString
(
"cta-catalogue-schema-verify"
);
args
->
argv
[
1
]
=
dupString
(
"--help"
);
args
->
argv
[
2
]
=
NULL
;
VerifySchemaCmdLineArgs
cmdLine
(
args
->
argc
,
args
->
argv
);
ASSERT_TRUE
(
cmdLine
.
help
);
ASSERT_TRUE
(
cmdLine
.
dbConfigPath
.
empty
());
}
TEST_F
(
cta_catalogue_VerifySchemaCmdLineArgsTest
,
dbConfigPath
)
{
using
namespace
cta
::
catalogue
;
Argcv
*
args
=
new
Argcv
();
m_argsList
.
push_back
(
args
);
args
->
argc
=
2
;
args
->
argv
=
new
char
*
[
3
];
args
->
argv
[
0
]
=
dupString
(
"cta-catalogue-schema-verify"
);
args
->
argv
[
1
]
=
dupString
(
"dbConfigPath"
);
args
->
argv
[
2
]
=
NULL
;
VerifySchemaCmdLineArgs
cmdLine
(
args
->
argc
,
args
->
argv
);
ASSERT_FALSE
(
cmdLine
.
help
);
ASSERT_EQ
(
std
::
string
(
"dbConfigPath"
),
cmdLine
.
dbConfigPath
);
}
}
// namespace unitTests
statistics/StatisticsCmd.cpp
→
statistics/Statistics
Save
Cmd.cpp
View file @
762a76b7
...
...
@@ -18,7 +18,7 @@
#include
"rdbms/ConnPool.hpp"
#include
"rdbms/AutocommitMode.hpp"
#include
"StatisticsCmd.hpp"
#include
"Statistics
Save
Cmd.hpp"
#include
"StatisticsSchema.hpp"
#include
"catalogue/SchemaChecker.hpp"
#include
"MysqlStatisticsSchema.hpp"
...
...
@@ -30,22 +30,22 @@ namespace statistics {
//------------------------------------------------------------------------------
// constructor
//------------------------------------------------------------------------------
StatisticsCmd
::
StatisticsCmd
(
std
::
istream
&
inStream
,
std
::
ostream
&
outStream
,
std
::
ostream
&
errStream
)
:
Statistics
Save
Cmd
::
Statistics
Save
Cmd
(
std
::
istream
&
inStream
,
std
::
ostream
&
outStream
,
std
::
ostream
&
errStream
)
:
CmdLineTool
(
inStream
,
outStream
,
errStream
)
{
}
//------------------------------------------------------------------------------
// destructor
//------------------------------------------------------------------------------
StatisticsCmd
::~
StatisticsCmd
()
noexcept
{
Statistics
Save
Cmd
::~
Statistics
Save
Cmd
()
noexcept
{
}
//------------------------------------------------------------------------------
// exceptionThrowingMain
//------------------------------------------------------------------------------
int
StatisticsCmd
::
exceptionThrowingMain
(
const
int
argc
,
char
*
const
*
const
argv
)
{
int
Statistics
Save
Cmd
::
exceptionThrowingMain
(
const
int
argc
,
char
*
const
*
const
argv
)
{
using
namespace
cta
::
catalogue
;
const
StatisticsCmdLineArgs
cmdLineArgs
(
argc
,
argv
);
const
Statistics
Save
CmdLineArgs
cmdLineArgs
(
argc
,
argv
);
if
(
cmdLineArgs
.
help
)
{
printUsage
(
m_out
);
...
...
@@ -87,7 +87,7 @@ int StatisticsCmd::exceptionThrowingMain(const int argc, char *const *const argv
//------------------------------------------------------------------------------
// tableExists
//------------------------------------------------------------------------------
bool
StatisticsCmd
::
tableExists
(
const
std
::
string
tableName
,
rdbms
::
Conn
&
conn
)
const
{
bool
Statistics
Save
Cmd
::
tableExists
(
const
std
::
string
tableName
,
rdbms
::
Conn
&
conn
)
const
{
const
auto
names
=
conn
.
getTableNames
();
for
(
const
auto
&
name
:
names
)
{
if
(
tableName
==
name
)
{
...
...
@@ -100,8 +100,8 @@ bool StatisticsCmd::tableExists(const std::string tableName, rdbms::Conn &conn)
//------------------------------------------------------------------------------
// printUsage
//------------------------------------------------------------------------------
void
StatisticsCmd
::
printUsage
(
std
::
ostream
&
os
)
{
StatisticsCmdLineArgs
::
printUsage
(
os
);
void
Statistics
Save
Cmd
::
printUsage
(
std
::
ostream
&
os
)
{
Statistics
Save
CmdLineArgs
::
printUsage
(
os
);
}
...
...
statistics/StatisticsCmd.hpp
→
statistics/Statistics
Save
Cmd.hpp
View file @
762a76b7
...
...
@@ -22,7 +22,7 @@
#include
"catalogue/CatalogueSchema.hpp"
#include
"rdbms/Conn.hpp"
#include
"rdbms/Login.hpp"
#include
"StatisticsCmdLineArgs.hpp"
#include
"Statistics
Save
CmdLineArgs.hpp"
namespace
cta
{
namespace
statistics
{
...
...
@@ -30,7 +30,7 @@ namespace statistics {
/**
* Command-line tool for verifying the catalogue schema.
*/
class
StatisticsCmd
:
public
cta
::
catalogue
::
CmdLineTool
{
class
Statistics
Save
Cmd
:
public
cta
::
catalogue
::
CmdLineTool
{
public:
/**
...
...
@@ -40,12 +40,12 @@ public:
* @param outStream Standard output stream.
* @param errStream Standard error stream.
*/
StatisticsCmd
(
std
::
istream
&
inStream
,
std
::
ostream
&
outStream
,
std
::
ostream
&
errStream
);
Statistics
Save
Cmd
(
std
::
istream
&
inStream
,
std
::
ostream
&
outStream
,
std
::
ostream
&
errStream
);
/**
* Destructor.
*/
~
StatisticsCmd
()
noexcept
;
~
Statistics
Save
Cmd
()
noexcept
;
enum
class
VerifyStatus
{
OK
,
INFO
,
ERROR
,
UNKNOWN
};
...
...
statistics/StatisticsCmdLineArgs.cpp
→
statistics/Statistics
Save
CmdLineArgs.cpp
View file @
762a76b7
...
...
@@ -16,7 +16,7 @@
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#include
"StatisticsCmdLineArgs.hpp"
#include
"Statistics
Save
CmdLineArgs.hpp"
#include
"common/exception/CommandLineNotParsed.hpp"
#include
<getopt.h>
...
...
@@ -29,7 +29,7 @@ namespace statistics {
//------------------------------------------------------------------------------
// constructor
//------------------------------------------------------------------------------
StatisticsCmdLineArgs
::
StatisticsCmdLineArgs
(
const
int
argc
,
char
*
const
*
const
argv
)
:
Statistics
Save
CmdLineArgs
::
Statistics
Save
CmdLineArgs
(
const
int
argc
,
char
*
const
*
const
argv
)
:
help
(
false
)
{
static
struct
option
longopts
[]
=
{
...
...
@@ -101,10 +101,10 @@ StatisticsCmdLineArgs::StatisticsCmdLineArgs(const int argc, char *const *const
//------------------------------------------------------------------------------
// printUsage
//------------------------------------------------------------------------------
void
StatisticsCmdLineArgs
::
printUsage
(
std
::
ostream
&
os
)
{
void
Statistics
Save
CmdLineArgs
::
printUsage
(
std
::
ostream
&
os
)
{
os
<<
"Usage:"
<<
std
::
endl
<<
" cta-statistics --catalogueconf catalogueDbConnectionFile --statisticsconf statisticsDbConnectionFile [options]"
<<
std
::
endl
<<
" cta-statistics
-save
--catalogueconf catalogueDbConnectionFile --statisticsconf statisticsDbConnectionFile [options]"
<<
std
::
endl
<<
"Where:"
<<
std
::
endl
<<
" catalogueDbConnectionFile"
<<
std
::
endl
<<
" The path to the file containing the connection details of the CTA"
<<
std
::
endl
<<
...
...
statistics/StatisticsCmdLineArgs.hpp
→
statistics/Statistics
Save
CmdLineArgs.hpp
View file @
762a76b7
...
...
@@ -27,7 +27,7 @@ namespace statistics {
* Structure to store the command-line arguments of the command-line tool
* named cta-statistics
*/
struct
StatisticsCmdLineArgs
{
struct
Statistics
Save
CmdLineArgs
{
/**
* True if the usage message should be printed.
*/
...
...
@@ -52,7 +52,7 @@ struct StatisticsCmdLineArgs {
* executable.
* @param argv The vector of command-line arguments.
*/
StatisticsCmdLineArgs
(
const
int
argc
,
char
*
const
*
const
argv
);
Statistics
Save
CmdLineArgs
(
const
int
argc
,
char
*
const
*
const
argv
);
/**
* Prints the usage message of the command-line tool.
...
...
statistics/StatisticsCmdMain.cpp
→
statistics/Statistics
Save
CmdMain.cpp
View file @
762a76b7
...
...
@@ -16,7 +16,7 @@
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#include
"StatisticsCmd.hpp"
#include
"Statistics
Save
Cmd.hpp"
#include
<iostream>
...
...
@@ -24,6 +24,6 @@
// main
//------------------------------------------------------------------------------
int
main
(
const
int
argc
,
char
*
const
*
const
argv
)
{
cta
::
statistics
::
StatisticsCmd
cmd
(
std
::
cin
,
std
::
cout
,
std
::
cerr
);
cta
::
statistics
::
Statistics
Save
Cmd
cmd
(
std
::
cin
,
std
::
cout
,
std
::
cerr
);
return
cmd
.
main
(
argc
,
argv
);
}
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